|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 3 | + |
| 4 | +namespace Microsoft.MSTestV2.Smoke.DiscoveryAndExecutionTests |
| 5 | +{ |
| 6 | + using Microsoft.MSTestV2.CLIAutomation; |
| 7 | + using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel; |
| 8 | + using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 9 | + |
| 10 | + using System.IO; |
| 11 | + using System.Linq; |
| 12 | + |
| 13 | + [TestClass] |
| 14 | + public class TestDataSourceTests : CLITestBase |
| 15 | + { |
| 16 | + private const string TestAssembly = "DataSourceTestProject.dll"; |
| 17 | + |
| 18 | + [TestMethod] |
| 19 | + public void ExecuteCsvTestDataSourceTests() |
| 20 | + { |
| 21 | + // Arrange |
| 22 | + var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : this.GetAssetFullPath(TestAssembly); |
| 23 | + |
| 24 | + // Act |
| 25 | + var testCases = DiscoverTests(assemblyPath, "CsvTestMethod"); |
| 26 | + var testResults = RunTests(assemblyPath, testCases); |
| 27 | + |
| 28 | + // Assert |
| 29 | + Assert.That.ContainsTestsPassed(testResults, |
| 30 | + "CsvTestMethod (Data Row 0)", |
| 31 | + "CsvTestMethod (Data Row 2)" |
| 32 | + ); |
| 33 | + |
| 34 | + Assert.That.ContainsTestsFailed(testResults, |
| 35 | + "CsvTestMethod (Data Row 1)", |
| 36 | + "CsvTestMethod (Data Row 3)" |
| 37 | + ); |
| 38 | + } |
| 39 | + |
| 40 | + [TestMethod] |
| 41 | + public void ExecuteDynamicDataTests() |
| 42 | + { |
| 43 | + // Arrange |
| 44 | + var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : this.GetAssetFullPath(TestAssembly); |
| 45 | + |
| 46 | + // Act |
| 47 | + var testCases = DiscoverTests(assemblyPath, "DynamicDataTest"); |
| 48 | + var testResults = RunTests(assemblyPath, testCases); |
| 49 | + |
| 50 | + // Assert |
| 51 | + Assert.That.ContainsTestsPassed(testResults, |
| 52 | + "DynamicDataTest (John;Doe,DataSourceTestProject.ITestDataSourceTests.User)" |
| 53 | + ); |
| 54 | + |
| 55 | + Assert.That.FailedTestCount(testResults, 0); |
| 56 | + } |
| 57 | + |
| 58 | + [TestMethod] |
| 59 | + public void ExecuteDataRowTests_Enums() |
| 60 | + { |
| 61 | + // Arrange |
| 62 | + var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : this.GetAssetFullPath(TestAssembly); |
| 63 | + |
| 64 | + // Act |
| 65 | + var testCases = DiscoverTests(assemblyPath, "FullyQualifiedName~DataRowTests_Enums"); |
| 66 | + var testResults = RunTests(assemblyPath, testCases); |
| 67 | + |
| 68 | + // Assert |
| 69 | + Assert.That.TestsPassed(testResults, |
| 70 | + "DataRowEnums_SByte (Alfa)", |
| 71 | + "DataRowEnums_SByte (Beta)", |
| 72 | + "DataRowEnums_SByte (Gamma)", |
| 73 | + "DataRowEnums_Byte (Alfa)", |
| 74 | + "DataRowEnums_Byte (Beta)", |
| 75 | + "DataRowEnums_Byte (Gamma)", |
| 76 | + "DataRowEnums_Short (Alfa)", |
| 77 | + "DataRowEnums_Short (Beta)", |
| 78 | + "DataRowEnums_Short (Gamma)", |
| 79 | + "DataRowEnums_UShort (Alfa)", |
| 80 | + "DataRowEnums_UShort (Beta)", |
| 81 | + "DataRowEnums_UShort (Gamma)", |
| 82 | + "DataRowEnums_Int (Alfa)", |
| 83 | + "DataRowEnums_Int (Beta)", |
| 84 | + "DataRowEnums_Int (Gamma)", |
| 85 | + "DataRowEnums_UInt (Alfa)", |
| 86 | + "DataRowEnums_UInt (Beta)", |
| 87 | + "DataRowEnums_UInt (Gamma)", |
| 88 | + "DataRowEnum_Long (Alfa)", |
| 89 | + "DataRowEnum_Long (Beta)", |
| 90 | + "DataRowEnum_Long (Gamma)", |
| 91 | + "DataRowEnum_ULong (Alfa)", |
| 92 | + "DataRowEnum_ULong (Beta)", |
| 93 | + "DataRowEnum_ULong (Gamma)", |
| 94 | + |
| 95 | + "DataRowEnums_Nullable_SByte ()", |
| 96 | + "DataRowEnums_Nullable_SByte (Alfa)", |
| 97 | + "DataRowEnums_Nullable_SByte (Beta)", |
| 98 | + "DataRowEnums_Nullable_SByte (Gamma)", |
| 99 | + "DataRowEnums_Nullable_Byte ()", |
| 100 | + "DataRowEnums_Nullable_Byte (Alfa)", |
| 101 | + "DataRowEnums_Nullable_Byte (Beta)", |
| 102 | + "DataRowEnums_Nullable_Byte (Gamma)", |
| 103 | + "DataRowEnums_Nullable_Short ()", |
| 104 | + "DataRowEnums_Nullable_Short (Alfa)", |
| 105 | + "DataRowEnums_Nullable_Short (Beta)", |
| 106 | + "DataRowEnums_Nullable_Short (Gamma)", |
| 107 | + "DataRowEnums_Nullable_UShort ()", |
| 108 | + "DataRowEnums_Nullable_UShort (Alfa)", |
| 109 | + "DataRowEnums_Nullable_UShort (Beta)", |
| 110 | + "DataRowEnums_Nullable_UShort (Gamma)", |
| 111 | + "DataRowEnums_Nullable_Int ()", |
| 112 | + "DataRowEnums_Nullable_Int (Alfa)", |
| 113 | + "DataRowEnums_Nullable_Int (Beta)", |
| 114 | + "DataRowEnums_Nullable_Int (Gamma)", |
| 115 | + "DataRowEnums_Nullable_UInt ()", |
| 116 | + "DataRowEnums_Nullable_UInt (Alfa)", |
| 117 | + "DataRowEnums_Nullable_UInt (Beta)", |
| 118 | + "DataRowEnums_Nullable_UInt (Gamma)", |
| 119 | + "DataRowEnums_Nullable_Long ()", |
| 120 | + "DataRowEnums_Nullable_Long (Alfa)", |
| 121 | + "DataRowEnums_Nullable_Long (Beta)", |
| 122 | + "DataRowEnums_Nullable_Long (Gamma)", |
| 123 | + "DataRowEnums_Nullable_ULong ()", |
| 124 | + "DataRowEnums_Nullable_ULong (Alfa)", |
| 125 | + "DataRowEnums_Nullable_ULong (Beta)", |
| 126 | + "DataRowEnums_Nullable_ULong (Gamma)", |
| 127 | + |
| 128 | + "DataRowEnums_MixedTypes_Byte (Alfa,True,1)", |
| 129 | + "DataRowEnums_MixedTypes_Byte (Beta,False,2)", |
| 130 | + "DataRowEnums_MixedTypes_Byte (Gamma,True,3)" |
| 131 | + ); |
| 132 | + |
| 133 | + Assert.That.FailedTestCount(testResults, 0); |
| 134 | + } |
| 135 | + |
| 136 | + [TestMethod] |
| 137 | + public void ExecuteDataRowTests_NonSerializablePaths() |
| 138 | + { |
| 139 | + // Arrange |
| 140 | + var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : this.GetAssetFullPath(TestAssembly); |
| 141 | + |
| 142 | + // Act |
| 143 | + var testCases = DiscoverTests(assemblyPath, "FullyQualifiedName~DataRowTests_NonSerializablePaths"); |
| 144 | + var testResults = RunTests(assemblyPath, testCases); |
| 145 | + |
| 146 | + // Assert |
| 147 | + Assert.That.TestsPassed(testResults, |
| 148 | + "DataRowNonSerializable (System.String)", |
| 149 | + "DataRowNonSerializable (System.Int32)", |
| 150 | + "DataRowNonSerializable (DataSourceTestProject.ITestDataSourceTests.DataRowTests_Enums)"); |
| 151 | + Assert.That.FailedTestCount(testResults, 0); |
| 152 | + } |
| 153 | + |
| 154 | + [TestMethod] |
| 155 | + public void ExecuteRegular_DataRowTests() |
| 156 | + { |
| 157 | + // Arrange |
| 158 | + var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : this.GetAssetFullPath(TestAssembly); |
| 159 | + |
| 160 | + // Act |
| 161 | + var testCases = DiscoverTests(assemblyPath, "FullyQualifiedName~Regular_DataRowTests"); |
| 162 | + var testResults = RunTests(assemblyPath, testCases); |
| 163 | + |
| 164 | + // Assert |
| 165 | + Assert.That.TestsPassed(testResults, |
| 166 | + "DataRow1 (10)", |
| 167 | + "DataRow1 (20)", |
| 168 | + "DataRow1 (30)", |
| 169 | + "DataRow1 (40)", |
| 170 | + "DataRow2 (10,String parameter,True,False)", |
| 171 | + "DataRow2 (20,String parameter,True,False)", |
| 172 | + "DataRow2 (30,String parameter,True,False)", |
| 173 | + "DataRow2 (40,String parameter,True,False)", |
| 174 | + "DataRowTestMethodFailsWithInvalidArguments ()", |
| 175 | + "DataRowTestMethodFailsWithInvalidArguments (2)", |
| 176 | + "DataRowTestMethodFailsWithInvalidArguments (2,DerivedRequiredArgument,DerivedOptionalArgument,DerivedExtraArgument)", |
| 177 | + "DataRowTestDouble (10.01,20.01)", |
| 178 | + "DataRowTestDouble (10.02,20.02)", |
| 179 | + "DataRowTestMixed (1,10,10,10,10,10,10,10,10)", |
| 180 | + "DataRowTestMixed (2,10,10,10,10,10,10,10,10)", |
| 181 | + "DataRowTestMixed (3,10,10,10,10,10,10,10,10)", |
| 182 | + "DataRowTestMixed (4,10,10,10,10,10,10,10,10)", |
| 183 | + "NullValueInData ([email protected],abc123,)", |
| 184 | + "NullValueInData ([email protected],abc123,/unit/test)"); |
| 185 | + |
| 186 | + Assert.That.FailedTestCount(testResults, 0); |
| 187 | + } |
| 188 | + } |
| 189 | +} |
0 commit comments