diff --git a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs index 737d2e7f23..969abfad44 100644 --- a/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs +++ b/src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs @@ -95,15 +95,24 @@ public DataRowAttribute(params object?[]? data) /// private static string? GetObjectString(object? obj) { + if (TestIdGenerationStrategy != TestIdGenerationStrategy.FullyQualified) + { + return obj?.ToString(); + } + if (obj == null) { - return null; + return "null"; } - if (TestIdGenerationStrategy != TestIdGenerationStrategy.FullyQualified - || !obj.GetType().IsArray) + if (!obj.GetType().IsArray) { - return obj.ToString(); + return obj switch + { + string s => $"\"{s}\"", + char c => $"'{c}'", + _ => obj.ToString(), + }; } // We need to box the object here so that we can support value types diff --git a/test/IntegrationTests/MSTest.IntegrationTests/ClsTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/ClsTests.cs index 919aff6141..042cf09853 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/ClsTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/ClsTests.cs @@ -25,8 +25,8 @@ public void TestsAreRun() testResults, "TestMethod", "IntDataRow (10)", - "StringDataRow (some string)", - "StringDataRow2 (some string)", - "StringDataRow2 (some other string)"); + "StringDataRow (\"some string\")", + "StringDataRow2 (\"some string\")", + "StringDataRow2 (\"some other string\")"); } } diff --git a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs index acc04e2ce3..e36a2f78ef 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs @@ -81,17 +81,17 @@ public void ExecuteCustomTestExtensibilityWithTestDataTests() // Assert VerifyE2E.TestsPassed( testResults, - "CustomTestMethod2 (B)", - "CustomTestMethod2 (B)", - "CustomTestMethod2 (B)"); + "CustomTestMethod2 (\"B\")", + "CustomTestMethod2 (\"B\")", + "CustomTestMethod2 (\"B\")"); VerifyE2E.TestsFailed( testResults, - "CustomTestMethod2 (A)", - "CustomTestMethod2 (A)", - "CustomTestMethod2 (A)", - "CustomTestMethod2 (C)", - "CustomTestMethod2 (C)", - "CustomTestMethod2 (C)"); + "CustomTestMethod2 (\"A\")", + "CustomTestMethod2 (\"A\")", + "CustomTestMethod2 (\"A\")", + "CustomTestMethod2 (\"C\")", + "CustomTestMethod2 (\"C\")", + "CustomTestMethod2 (\"C\")"); } } diff --git a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs index 2073218ab7..ab245fcaa6 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/Parameterized tests/DataRowTests.cs @@ -21,11 +21,11 @@ public void ExecuteOnlyDerivedClassDataRowsWhenBothBaseAndDerivedClassHasDataRow // Assert VerifyE2E.TestsPassed( testResults, - "DataRowTestMethod (BaseString1)", - "DataRowTestMethod (BaseString2)", - "DataRowTestMethod (BaseString3)", - "DataRowTestMethod (DerivedString1)", - "DataRowTestMethod (DerivedString2)"); + "DataRowTestMethod (\"BaseString1\")", + "DataRowTestMethod (\"BaseString2\")", + "DataRowTestMethod (\"BaseString3\")", + "DataRowTestMethod (\"DerivedString1\")", + "DataRowTestMethod (\"DerivedString2\")"); } public void ExecuteOnlyDerivedClassDataRowsWhenItOverridesBaseClassDataRows_SimpleDataRows() @@ -40,8 +40,8 @@ public void ExecuteOnlyDerivedClassDataRowsWhenItOverridesBaseClassDataRows_Simp // Assert VerifyE2E.TestsPassed( testResults, - "DataRowTestMethod (DerivedString1)", - "DataRowTestMethod (DerivedString2)"); + "DataRowTestMethod (\"DerivedString1\")", + "DataRowTestMethod (\"DerivedString2\")"); } public void DataRowsExecuteWithRequiredAndOptionalParameters() @@ -57,8 +57,8 @@ public void DataRowsExecuteWithRequiredAndOptionalParameters() VerifyE2E.TestsPassed( testResults, "DataRowTestMethodWithSomeOptionalParameters (123)", - "DataRowTestMethodWithSomeOptionalParameters (123,DerivedOptionalString1)", - "DataRowTestMethodWithSomeOptionalParameters (123,DerivedOptionalString2,DerivedOptionalString3)"); + "DataRowTestMethodWithSomeOptionalParameters (123,\"DerivedOptionalString1\")", + "DataRowTestMethodWithSomeOptionalParameters (123,\"DerivedOptionalString2\",\"DerivedOptionalString3\")"); } public void DataRowsExecuteWithParamsArrayParameter() @@ -74,9 +74,9 @@ public void DataRowsExecuteWithParamsArrayParameter() VerifyE2E.TestsPassed( testResults, "DataRowTestMethodWithParamsParameters (2)", - "DataRowTestMethodWithParamsParameters (2,DerivedSingleParamsArg)", - "DataRowTestMethodWithParamsParameters (2,DerivedParamsArg1,DerivedParamsArg2)", - "DataRowTestMethodWithParamsParameters (2,DerivedParamsArg1,DerivedParamsArg2,DerivedParamsArg3)"); + "DataRowTestMethodWithParamsParameters (2,\"DerivedSingleParamsArg\")", + "DataRowTestMethodWithParamsParameters (2,\"DerivedParamsArg1\",\"DerivedParamsArg2\")", + "DataRowTestMethodWithParamsParameters (2,\"DerivedParamsArg1\",\"DerivedParamsArg2\",\"DerivedParamsArg3\")"); } public void DataRowsFailWhenInvalidArgumentsProvided() @@ -93,7 +93,7 @@ public void DataRowsFailWhenInvalidArgumentsProvided() testResults, "DataRowTestMethodFailsWithInvalidArguments ()", "DataRowTestMethodFailsWithInvalidArguments (2)", - "DataRowTestMethodFailsWithInvalidArguments (2,DerivedRequiredArgument,DerivedOptionalArgument,DerivedExtraArgument)"); + "DataRowTestMethodFailsWithInvalidArguments (2,\"DerivedRequiredArgument\",\"DerivedOptionalArgument\",\"DerivedExtraArgument\")"); } public void DataRowsShouldSerializeDoublesProperly() @@ -124,7 +124,7 @@ public void DataRowsShouldSerializeMixedTypesProperly() // Assert VerifyE2E.TestsPassed( testResults, - "DataRowTestMixed (10,10,10,10,10,10,10,10)"); + "DataRowTestMixed (10,10,10,10,10,10,10,\"10\")"); } public void DataRowsShouldSerializeEnumsProperly() @@ -139,7 +139,7 @@ public void DataRowsShouldSerializeEnumsProperly() // Assert VerifyE2E.TestsPassed( testResults, - "DataRowEnums ()", + "DataRowEnums (null)", "DataRowEnums (Alfa)", "DataRowEnums (Beta)", "DataRowEnums (Gamma)"); @@ -202,35 +202,35 @@ public void ExecuteDataRowTests_Enums() "DataRowEnum_ULong (Alfa)", "DataRowEnum_ULong (Beta)", "DataRowEnum_ULong (Gamma)", - "DataRowEnums_Nullable_SByte ()", + "DataRowEnums_Nullable_SByte (null)", "DataRowEnums_Nullable_SByte (Alfa)", "DataRowEnums_Nullable_SByte (Beta)", "DataRowEnums_Nullable_SByte (Gamma)", - "DataRowEnums_Nullable_Byte ()", + "DataRowEnums_Nullable_Byte (null)", "DataRowEnums_Nullable_Byte (Alfa)", "DataRowEnums_Nullable_Byte (Beta)", "DataRowEnums_Nullable_Byte (Gamma)", - "DataRowEnums_Nullable_Short ()", + "DataRowEnums_Nullable_Short (null)", "DataRowEnums_Nullable_Short (Alfa)", "DataRowEnums_Nullable_Short (Beta)", "DataRowEnums_Nullable_Short (Gamma)", - "DataRowEnums_Nullable_UShort ()", + "DataRowEnums_Nullable_UShort (null)", "DataRowEnums_Nullable_UShort (Alfa)", "DataRowEnums_Nullable_UShort (Beta)", "DataRowEnums_Nullable_UShort (Gamma)", - "DataRowEnums_Nullable_Int ()", + "DataRowEnums_Nullable_Int (null)", "DataRowEnums_Nullable_Int (Alfa)", "DataRowEnums_Nullable_Int (Beta)", "DataRowEnums_Nullable_Int (Gamma)", - "DataRowEnums_Nullable_UInt ()", + "DataRowEnums_Nullable_UInt (null)", "DataRowEnums_Nullable_UInt (Alfa)", "DataRowEnums_Nullable_UInt (Beta)", "DataRowEnums_Nullable_UInt (Gamma)", - "DataRowEnums_Nullable_Long ()", + "DataRowEnums_Nullable_Long (null)", "DataRowEnums_Nullable_Long (Alfa)", "DataRowEnums_Nullable_Long (Beta)", "DataRowEnums_Nullable_Long (Gamma)", - "DataRowEnums_Nullable_ULong ()", + "DataRowEnums_Nullable_ULong (null)", "DataRowEnums_Nullable_ULong (Alfa)", "DataRowEnums_Nullable_ULong (Beta)", "DataRowEnums_Nullable_ULong (Gamma)", @@ -275,23 +275,23 @@ public void ExecuteDataRowTests_Regular() "DataRow1 (20)", "DataRow1 (30)", "DataRow1 (40)", - "DataRow2 (10,String parameter,True,False)", - "DataRow2 (20,String parameter,True,False)", - "DataRow2 (30,String parameter,True,False)", - "DataRow2 (40,String parameter,True,False)", + "DataRow2 (10,\"String parameter\",True,False)", + "DataRow2 (20,\"String parameter\",True,False)", + "DataRow2 (30,\"String parameter\",True,False)", + "DataRow2 (40,\"String parameter\",True,False)", "DataRowTestDouble (10.01,20.01)", "DataRowTestDouble (10.02,20.02)", - "DataRowTestMixed (1,10,10,10,10,10,10,10,10)", - "DataRowTestMixed (2,10,10,10,10,10,10,10,10)", - "DataRowTestMixed (3,10,10,10,10,10,10,10,10)", - "DataRowTestMixed (4,10,10,10,10,10,10,10,10)", - "NullValueInData (john.doe@example.com,abc123,)", - "NullValueInData (john.doe@example.com,abc123,/unit/test)", - "NullValue ()", - "OneStringArray ([])", - "TwoStringArrays ([],[1.4,message])", - "OneObjectArray ([,1])", - "TwoObjectArrays ([,1],[3])", + "DataRowTestMixed (1,10,10,10,10,10,10,10,\"10\")", + "DataRowTestMixed (2,10,10,10,10,10,10,10,\"10\")", + "DataRowTestMixed (3,10,10,10,10,10,10,10,\"10\")", + "DataRowTestMixed (4,10,10,10,10,10,10,10,\"10\")", + "NullValueInData (\"john.doe@example.com\",\"abc123\",null)", + "NullValueInData (\"john.doe@example.com\",\"abc123\",\"/unit/test\")", + "NullValue (null)", + "OneStringArray ([\"\"])", + "TwoStringArrays ([\"\"],[\"1.4\",\"message\"])", + "OneObjectArray ([\"\",1])", + "TwoObjectArrays ([\"\",1],[3])", "ThreeObjectArrays ([1],[2],[3])", "FourObjectArrays ([1],[2],[3],[4])", "FiveObjectArrays ([1],[2],[3],[4],[5])", @@ -312,6 +312,6 @@ public void ExecuteDataRowTests_Regular() testResults, "DataRowTestMethodFailsWithInvalidArguments ()", "DataRowTestMethodFailsWithInvalidArguments (2)", - "DataRowTestMethodFailsWithInvalidArguments (2,DerivedRequiredArgument,DerivedOptionalArgument,DerivedExtraArgument)"); + "DataRowTestMethodFailsWithInvalidArguments (2,\"DerivedRequiredArgument\",\"DerivedOptionalArgument\",\"DerivedExtraArgument\")"); } } diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs index 82483e0bfa..a43cc293ed 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.DefaultStrategy.cs @@ -45,10 +45,10 @@ public void TestIdUniqueness_DataRowString_DefaultStrategy() VerifyE2E.FailedTestCount(testResults, 0); VerifyE2E.TestsPassed( testResults, - "DataRowStringTests ()", - "DataRowStringTests ()", - "DataRowStringTests ( )", - "DataRowStringTests ( )"); + "DataRowStringTests (null)", + "DataRowStringTests (\"\")", + "DataRowStringTests (\" \")", + "DataRowStringTests (\" \")"); // We cannot assert the expected ID as it is path dependent testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); diff --git a/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs b/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs index 2a273ca46a..14e9c68444 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/TestId.FullyQualifiedStrategy.cs @@ -45,10 +45,10 @@ public void TestIdUniqueness_DataRowString_FullyQualifiedStrategy() VerifyE2E.FailedTestCount(testResults, 0); VerifyE2E.TestsPassed( testResults, - "DataRowStringTests ()", - "DataRowStringTests ()", - "DataRowStringTests ( )", - "DataRowStringTests ( )"); + "DataRowStringTests (null)", + "DataRowStringTests (\"\")", + "DataRowStringTests (\" \")", + "DataRowStringTests (\" \")"); // We cannot assert the expected ID as it is path dependent testResults.Select(x => x.TestCase.Id.ToString()).Should().OnlyHaveUniqueItems(); diff --git a/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs b/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs index 78c3dde3e1..4d25cc9a15 100644 --- a/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs +++ b/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataExtensibilityTests.cs @@ -65,17 +65,17 @@ public void ExecuteCustomTestExtensibilityWithTestDataTests() InvokeVsTestForExecution([TestAssetName], testCaseFilter: "FullyQualifiedName~CustomTestExTests.CustomTestMethod2"); ValidatePassedTests( - "CustomTestMethod2 (B)", - "CustomTestMethod2 (B)", - "CustomTestMethod2 (B)"); + "CustomTestMethod2 (\"B\")", + "CustomTestMethod2 (\"B\")", + "CustomTestMethod2 (\"B\")"); ValidateFailedTestsCount(6); ValidateFailedTestsContain( true, - "CustomTestMethod2 (A)", - "CustomTestMethod2 (A)", - "CustomTestMethod2 (A)", - "CustomTestMethod2 (C)", - "CustomTestMethod2 (C)", - "CustomTestMethod2 (C)"); + "CustomTestMethod2 (\"A\")", + "CustomTestMethod2 (\"A\")", + "CustomTestMethod2 (\"A\")", + "CustomTestMethod2 (\"C\")", + "CustomTestMethod2 (\"C\")", + "CustomTestMethod2 (\"C\")"); } } diff --git a/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs b/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs index cc96420e16..a5c7d9c0c1 100644 --- a/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs +++ b/test/IntegrationTests/MSTest.VstestConsoleWrapper.IntegrationTests/Parameterized tests/DataRowTests.cs @@ -14,11 +14,11 @@ public void ExecuteOnlyDerivedClassDataRowsWhenBothBaseAndDerivedClassHasDataRow InvokeVsTestForExecution([TestAssetName], testCaseFilter: "TestCategory~DataRowSimple"); ValidatePassedTestsContain( - "DataRowTestMethod (BaseString1)", - "DataRowTestMethod (BaseString2)", - "DataRowTestMethod (BaseString3)", - "DataRowTestMethod (DerivedString1)", - "DataRowTestMethod (DerivedString2)"); + "DataRowTestMethod (\"BaseString1\")", + "DataRowTestMethod (\"BaseString2\")", + "DataRowTestMethod (\"BaseString3\")", + "DataRowTestMethod (\"DerivedString1\")", + "DataRowTestMethod (\"DerivedString2\")"); // 3 tests of BaseClass.DataRowTestMethod - 3 data row results and no parent result // 2 tests of DerivedClass.DataRowTestMethod - 2 data row results and no parent result @@ -41,8 +41,8 @@ public void ExecuteOnlyDerivedClassDataRowsWhenItOverridesBaseClassDataRows_Simp InvokeVsTestForExecution([TestAssetName], testCaseFilter: "FullyQualifiedName~DerivedClass&TestCategory~DataRowSimple"); ValidatePassedTestsContain( - "DataRowTestMethod (DerivedString1)", - "DataRowTestMethod (DerivedString2)"); + "DataRowTestMethod (\"DerivedString1\")", + "DataRowTestMethod (\"DerivedString2\")"); // 2 tests of DerivedClass.DataRowTestMethod - 2 datarow result and no parent result ValidatePassedTestsCount(2); @@ -54,8 +54,8 @@ public void DataRowsExecuteWithRequiredAndOptionalParameters() ValidatePassedTestsContain( "DataRowTestMethodWithSomeOptionalParameters (123)", - "DataRowTestMethodWithSomeOptionalParameters (123,DerivedOptionalString1)", - "DataRowTestMethodWithSomeOptionalParameters (123,DerivedOptionalString2,DerivedOptionalString3)"); + "DataRowTestMethodWithSomeOptionalParameters (123,\"DerivedOptionalString1\")", + "DataRowTestMethodWithSomeOptionalParameters (123,\"DerivedOptionalString2\",\"DerivedOptionalString3\")"); // 3 tests of DerivedClass.DataRowTestMethodWithSomeOptionalParameters - 3 datarow result and no parent result ValidatePassedTestsCount(3); @@ -68,8 +68,8 @@ public void DataRowsExecuteWithAllOptionalParameters() ValidatePassedTestsContain( "DataRowTestMethodWithAllOptionalParameters ()", "DataRowTestMethodWithAllOptionalParameters (123)", - "DataRowTestMethodWithAllOptionalParameters (123,DerivedOptionalString4)", - "DataRowTestMethodWithAllOptionalParameters (123,DerivedOptionalString5,DerivedOptionalString6)"); + "DataRowTestMethodWithAllOptionalParameters (123,\"DerivedOptionalString4\")", + "DataRowTestMethodWithAllOptionalParameters (123,\"DerivedOptionalString5\",\"DerivedOptionalString6\")"); // 4 tests of DerivedClass.DataRowTestMethodWithAllOptionalParameters - 4 datarow result and no parent result ValidatePassedTestsCount(4); @@ -81,9 +81,9 @@ public void DataRowsExecuteWithParamsArrayParameter() ValidatePassedTestsContain( "DataRowTestMethodWithParamsParameters (2)", - "DataRowTestMethodWithParamsParameters (2,DerivedSingleParamsArg)", - "DataRowTestMethodWithParamsParameters (2,DerivedParamsArg1,DerivedParamsArg2)", - "DataRowTestMethodWithParamsParameters (2,DerivedParamsArg1,DerivedParamsArg2,DerivedParamsArg3)"); + "DataRowTestMethodWithParamsParameters (2,\"DerivedSingleParamsArg\")", + "DataRowTestMethodWithParamsParameters (2,\"DerivedParamsArg1\",\"DerivedParamsArg2\")", + "DataRowTestMethodWithParamsParameters (2,\"DerivedParamsArg1\",\"DerivedParamsArg2\",\"DerivedParamsArg3\")"); // 4 tests of DerivedClass.DataRowTestMethodWithParamsParameters - 4 datarow result and no parent result ValidatePassedTestsCount(4); @@ -97,7 +97,7 @@ public void DataRowsFailWhenInvalidArgumentsProvided() false, "DataRowTestMethodFailsWithInvalidArguments ()", "DataRowTestMethodFailsWithInvalidArguments (2)", - "DataRowTestMethodFailsWithInvalidArguments (2,DerivedRequiredArgument,DerivedOptionalArgument,DerivedExtraArgument)"); + "DataRowTestMethodFailsWithInvalidArguments (2,\"DerivedRequiredArgument\",\"DerivedOptionalArgument\",\"DerivedExtraArgument\")"); // 3 tests of DerivedClass.DataRowTestMethodFailsWithInvalidArguments - 3 datarow result and no parent result ValidateFailedTestsCount(3); @@ -136,35 +136,35 @@ public void ExecuteDataRowTests_Enums() "DataRowEnum_ULong (Alfa)", "DataRowEnum_ULong (Beta)", "DataRowEnum_ULong (Gamma)", - "DataRowEnums_Nullable_SByte ()", + "DataRowEnums_Nullable_SByte (null)", "DataRowEnums_Nullable_SByte (Alfa)", "DataRowEnums_Nullable_SByte (Beta)", "DataRowEnums_Nullable_SByte (Gamma)", - "DataRowEnums_Nullable_Byte ()", + "DataRowEnums_Nullable_Byte (null)", "DataRowEnums_Nullable_Byte (Alfa)", "DataRowEnums_Nullable_Byte (Beta)", "DataRowEnums_Nullable_Byte (Gamma)", - "DataRowEnums_Nullable_Short ()", + "DataRowEnums_Nullable_Short (null)", "DataRowEnums_Nullable_Short (Alfa)", "DataRowEnums_Nullable_Short (Beta)", "DataRowEnums_Nullable_Short (Gamma)", - "DataRowEnums_Nullable_UShort ()", + "DataRowEnums_Nullable_UShort (null)", "DataRowEnums_Nullable_UShort (Alfa)", "DataRowEnums_Nullable_UShort (Beta)", "DataRowEnums_Nullable_UShort (Gamma)", - "DataRowEnums_Nullable_Int ()", + "DataRowEnums_Nullable_Int (null)", "DataRowEnums_Nullable_Int (Alfa)", "DataRowEnums_Nullable_Int (Beta)", "DataRowEnums_Nullable_Int (Gamma)", - "DataRowEnums_Nullable_UInt ()", + "DataRowEnums_Nullable_UInt (null)", "DataRowEnums_Nullable_UInt (Alfa)", "DataRowEnums_Nullable_UInt (Beta)", "DataRowEnums_Nullable_UInt (Gamma)", - "DataRowEnums_Nullable_Long ()", + "DataRowEnums_Nullable_Long (null)", "DataRowEnums_Nullable_Long (Alfa)", "DataRowEnums_Nullable_Long (Beta)", "DataRowEnums_Nullable_Long (Gamma)", - "DataRowEnums_Nullable_ULong ()", + "DataRowEnums_Nullable_ULong (null)", "DataRowEnums_Nullable_ULong (Alfa)", "DataRowEnums_Nullable_ULong (Beta)", "DataRowEnums_Nullable_ULong (Gamma)", @@ -204,23 +204,23 @@ public void ExecuteRegular_DataRowTests() "DataRow1 (20)", "DataRow1 (30)", "DataRow1 (40)", - "DataRow2 (10,String parameter,True,False)", - "DataRow2 (20,String parameter,True,False)", - "DataRow2 (30,String parameter,True,False)", - "DataRow2 (40,String parameter,True,False)", + "DataRow2 (10,\"String parameter\",True,False)", + "DataRow2 (20,\"String parameter\",True,False)", + "DataRow2 (30,\"String parameter\",True,False)", + "DataRow2 (40,\"String parameter\",True,False)", "DataRowTestDouble (10.01,20.01)", "DataRowTestDouble (10.02,20.02)", - "DataRowTestMixed (1,10,10,10,10,10,10,10,10)", - "DataRowTestMixed (2,10,10,10,10,10,10,10,10)", - "DataRowTestMixed (3,10,10,10,10,10,10,10,10)", - "DataRowTestMixed (4,10,10,10,10,10,10,10,10)", - "NullValueInData (john.doe@example.com,abc123,)", - "NullValueInData (john.doe@example.com,abc123,/unit/test)", - "NullValue ()", - "OneStringArray ([])", - "TwoStringArrays ([],[1.4,message])", - "OneObjectArray ([,1])", - "TwoObjectArrays ([,1],[3])", + "DataRowTestMixed (1,10,10,10,10,10,10,10,\"10\")", + "DataRowTestMixed (2,10,10,10,10,10,10,10,\"10\")", + "DataRowTestMixed (3,10,10,10,10,10,10,10,\"10\")", + "DataRowTestMixed (4,10,10,10,10,10,10,10,\"10\")", + "NullValueInData (\"john.doe@example.com\",\"abc123\",null)", + "NullValueInData (\"john.doe@example.com\",\"abc123\",\"/unit/test\")", + "NullValue (null)", + "OneStringArray ([\"\"])", + "TwoStringArrays ([\"\"],[\"1.4\",\"message\"])", + "OneObjectArray ([\"\",1])", + "TwoObjectArrays ([\"\",1],[3])", "ThreeObjectArrays ([1],[2],[3])", "FourObjectArrays ([1],[2],[3],[4])", "FiveObjectArrays ([1],[2],[3],[4],[5])", @@ -241,6 +241,6 @@ public void ExecuteRegular_DataRowTests() false, "DataRowTestMethodFailsWithInvalidArguments ()", "DataRowTestMethodFailsWithInvalidArguments (2)", - "DataRowTestMethodFailsWithInvalidArguments (2,DerivedRequiredArgument,DerivedOptionalArgument,DerivedExtraArgument)"); + "DataRowTestMethodFailsWithInvalidArguments (2,\"DerivedRequiredArgument\",\"DerivedOptionalArgument\",\"DerivedExtraArgument\")"); } } diff --git a/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestMethodRunnerTests.cs b/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestMethodRunnerTests.cs index 8c47711976..45c7075390 100644 --- a/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestMethodRunnerTests.cs +++ b/test/UnitTests/MSTestAdapter.UnitTests/Execution/TestMethodRunnerTests.cs @@ -436,7 +436,7 @@ public void RunTestMethodShouldFillInDisplayNameWithDataRowArgumentsIfNoDisplayN UnitTestResult[] results = testMethodRunner.RunTestMethod(); Verify(results.Length == 1); - Verify(results[0].DisplayName == "DummyTestMethod (2,DummyString)"); + Verify(results[0].DisplayName == "DummyTestMethod (2,\"DummyString\")"); } public void RunTestMethodShouldSetResultFilesIfPresentForDataDrivenTests() diff --git a/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs b/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs index 5a13e56c1b..9a9bfd1c7f 100644 --- a/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs +++ b/test/UnitTests/TestFramework.UnitTests/Attributes/DataRowAttributeTests.cs @@ -89,13 +89,13 @@ public void GetDisplayNameShouldReturnAppropriateName() string[] data2 = ["First", null, "Second"]; string displayName = dataRowAttribute.GetDisplayName(testMethodInfo, data); - Verify(displayName == "DataRowTestMethod (First,Second,)"); + Verify(displayName == "DataRowTestMethod (\"First\",\"Second\",null)"); displayName = dataRowAttribute.GetDisplayName(testMethodInfo, data1); - Verify(displayName == "DataRowTestMethod (,First,Second)"); + Verify(displayName == "DataRowTestMethod (null,\"First\",\"Second\")"); displayName = dataRowAttribute.GetDisplayName(testMethodInfo, data2); - Verify(displayName == "DataRowTestMethod (First,,Second)"); + Verify(displayName == "DataRowTestMethod (\"First\",null,\"Second\")"); } public void GetDisplayNameShouldReturnSpecifiedDisplayName() @@ -125,7 +125,7 @@ public void GetDisplayNameForArrayOfOneItem() string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); // Assert - Verify(displayName == "MyMethod ([a])"); + Verify(displayName == "MyMethod ([\"a\"])"); } public void GetDisplayName_AfterOverriding_GetsTheNewDisplayName() @@ -152,7 +152,7 @@ public void GetDisplayNameForArrayOfMultipleItems() string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); // Assert - Verify(displayName == "MyMethod ([a,b,c])"); + Verify(displayName == "MyMethod ([\"a\",\"b\",\"c\"])"); } public void GetDisplayNameForMultipleArraysOfOneItem() @@ -166,7 +166,7 @@ public void GetDisplayNameForMultipleArraysOfOneItem() string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); // Assert - Verify(displayName == "MyMethod ([a],[1])"); + Verify(displayName == "MyMethod ([\"a\"],[\"1\"])"); } public void GetDisplayNameForMultipleArraysOfMultipleItems() @@ -180,7 +180,7 @@ public void GetDisplayNameForMultipleArraysOfMultipleItems() string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); // Assert - Verify(displayName == "MyMethod ([a,b,c],[1,2,3])"); + Verify(displayName == "MyMethod ([\"a\",\"b\",\"c\"],[\"1\",\"2\",\"3\"])"); } public void GetDisplayNameForMultipleArraysOfMultipleItemsValueTypes() @@ -200,7 +200,7 @@ public void GetDisplayNameForMultipleArraysOfMultipleItemsValueTypes() public void GetDisplayNameForMultipleArraysOfArraysOfMultipleItems() { // Arrange - var dataRow = new DataRowAttribute(new[] { new[] { "a", "b", "c" }, new[] { "d", "e", "f" }, new[] { "g", "h", "i" } }, new[] { new[] { "1", "2", "3" }, new[] { "4", "5", "6" }, new[] { "7", "8", "9" } }); + var dataRow = new DataRowAttribute(new[] { new[] { "a", "b", "c" }, new[] { "d", "e", "f" }, new[] { "gh", "ij", "kl" } }, new[] { 'm', 'n', 'o' }, new[] { new[] { "1", "2", "3" }, new[] { "4", "5", "6" }, new[] { "7", "8", "9" } }); var methodInfoMock = new Mock(); methodInfoMock.SetupGet(x => x.Name).Returns("MyMethod"); @@ -208,7 +208,7 @@ public void GetDisplayNameForMultipleArraysOfArraysOfMultipleItems() string displayName = dataRow.GetDisplayName(methodInfoMock.Object, dataRow.Data); // Assert - Verify(displayName == "MyMethod ([[a,b,c],[d,e,f],[g,h,i]],[[1,2,3],[4,5,6],[7,8,9]])"); + Verify(displayName == "MyMethod ([[\"a\",\"b\",\"c\"],[\"d\",\"e\",\"f\"],[\"gh\",\"ij\",\"kl\"]],['m','n','o'],[[\"1\",\"2\",\"3\"],[\"4\",\"5\",\"6\"],[\"7\",\"8\",\"9\"]])"); } private class DummyDataRowAttribute : DataRowAttribute