C# – Can’t pass decimal parameter in DataTestMethod

I have a parameterized unit test with decimal parameters. When I run the test, I get the following exception: System.ArgumentException: Object of type ‘System.Double’ cannot be converted to type ‘System.Decimal’. Solution Change the parameters to doubles and convert them to decimals inside the test method. Why is it throwing an exception? You have to pass … Read more C# – Can’t pass decimal parameter in DataTestMethod

C# – Parameterized tests with MSTest v2

Here’s an example of how to parameterize your tests using the built-in MSTest v2 test framework: There are 3 steps: Add parameters to your test method. Use [DataTestMethod] instead of [TestMethod]. For each test case, add [DataRow(…)] to pass in the parameters for that test case. What parameters can you pass in? You pass in … Read more C# – Parameterized tests with MSTest v2

C# – Attribute constructor parameter is not a valid attribute parameter type

Problem I have created a custom attribute class and I am trying to pass in a value. It looks like this: I’m getting the following error message: Attribute constructor parameter has type Color which is not a valid attribute parameter type I have also gotten this error message, which has the same underlying cause: An … Read more C# – Attribute constructor parameter is not a valid attribute parameter type