diff options
author | Keting Yang <ketyang@microsoft.com> | 2020-01-10 22:47:41 +0300 |
---|---|---|
committer | Keting Yang <ketyang@microsoft.com> | 2020-01-10 22:47:41 +0300 |
commit | d123c0fd4b5f47717d2aaacd3b1e8948cdf0f11d (patch) | |
tree | 152978a1d13dfc53a3433bff0a1cefb5bd81f233 /main/src/addins/MonoDevelop.UnitTesting | |
parent | ef47f00a8a42523e4994b406e103d21f1fb26bab (diff) |
Unit Test for the new nesting
Diffstat (limited to 'main/src/addins/MonoDevelop.UnitTesting')
2 files changed, 140 insertions, 2 deletions
diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.Tests/MonoDevelop.UnitTesting.Tests.csproj b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.Tests/MonoDevelop.UnitTesting.Tests.csproj index 98c4976552..a0fc66f720 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.Tests/MonoDevelop.UnitTesting.Tests.csproj +++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.Tests/MonoDevelop.UnitTesting.Tests.csproj @@ -59,6 +59,10 @@ <Name>MonoDevelop.DotNetCore</Name> <Private>False</Private> </ProjectReference> + <ProjectReference Include="..\..\MonoDevelop.UnitTesting.NUnit\MonoDevelop.UnitTesting.NUnit.csproj"> + <Project>{6224D87E-2AC1-4D9F-91ED-714F797297BF}</Project> + <Name>MonoDevelop.UnitTesting.NUnit</Name> + </ProjectReference> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.Tests/MonoDevelop.UnitTesting.Tests/VsTestUnitTestTests.cs b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.Tests/MonoDevelop.UnitTesting.Tests/VsTestUnitTestTests.cs index df37e68ea1..4fa99f3af5 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.Tests/MonoDevelop.UnitTesting.Tests/VsTestUnitTestTests.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.Tests/MonoDevelop.UnitTesting.Tests/VsTestUnitTestTests.cs @@ -24,8 +24,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using Microsoft.VisualStudio.TestPlatform.ObjectModel;
-using MonoDevelop.UnitTesting.VsTest;
+using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using MonoDevelop.UnitTesting.NUnit; +using MonoDevelop.UnitTesting.VsTest; using NUnit.Framework; using System; using UnitTests; @@ -123,5 +124,138 @@ namespace MonoDevelop.UnitTesting.Tests FixtureTypeName = fixtureTypeName; } } + + [TestFixture] + class NUnitTestUnitTestTests : TestBase + { + + /// <summary> + /// VSTS Bug 1042673: [Bug] Make the nesting for Mono NUnit test consistent with the vstests (mstest, nunit, xunit) + /// </summary> + [Test] + public void TestVSTS1042673 () + { + var case1 = new NUnitTestSuite (null, directClassCase ()); + var case2 = new NUnitTestSuite (null, namespaceWithDot ()); + var case3 = new NUnitTestSuite (null, nestedNamespace ()); + var case4 = new NUnitTestSuite (null, namespaceNoDot ()); + + Assert.AreEqual(case1.Tests[0].Title, "TestClass"); + Assert.AreEqual(case2.Tests[0].Title, "A.B"); + Assert.AreEqual(case3.Tests[0].Title, "A.B.C"); + Assert.AreEqual(case4.Tests[0].Title, "A"); + + } + + NunitTestInfo directClassCase () + { + NunitTestInfo classInfo = new NunitTestInfo { + FixtureTypeName = "TestClass", + FixtureTypeNamespace = "", + Name = "TestClass" + }; + + NunitTestInfo methodInfo = new NunitTestInfo { + FixtureTypeName = "TestClass", + FixtureTypeNamespace = "", + Name = "TestMethod" + }; + classInfo.Tests [0] = methodInfo; + + return classInfo; + } + + NunitTestInfo namespaceWithDot () + { + NunitTestInfo namespaceInfo = new NunitTestInfo { + FixtureTypeName = "", + FixtureTypeNamespace = "", + Name = "A" + }; + NunitTestInfo namespaceInfo2 = new NunitTestInfo { + FixtureTypeName = "", + FixtureTypeNamespace = "", + Name = "B" + }; + namespaceInfo.Tests [0] = namespaceInfo2; + + NunitTestInfo classInfo = new NunitTestInfo { + FixtureTypeName = "TestClassAB", + FixtureTypeNamespace = "A.B", + Name = "TestClassAB" + }; + namespaceInfo2.Tests [0] = classInfo; + + NunitTestInfo methodInfo = new NunitTestInfo { + FixtureTypeName = "TestClassAB", + FixtureTypeNamespace = "A.B", + Name = "TestMethodAB" + }; + classInfo.Tests [0] = methodInfo; + + return namespaceInfo; + } + + NunitTestInfo nestedNamespace () + { + NunitTestInfo namespaceInfo = new NunitTestInfo { + FixtureTypeName = "", + FixtureTypeNamespace = "", + Name = "A" + }; + NunitTestInfo namespaceInfo2 = new NunitTestInfo { + FixtureTypeName = "", + FixtureTypeNamespace = "", + Name = "B" + }; + namespaceInfo.Tests [0] = namespaceInfo2; + NunitTestInfo namespaceInfo3 = new NunitTestInfo { + FixtureTypeName = "", + FixtureTypeNamespace = "", + Name = "C" + }; + namespaceInfo2.Tests [0] = namespaceInfo3; + + NunitTestInfo classInfo = new NunitTestInfo { + FixtureTypeName = "TestClassABC", + FixtureTypeNamespace = "A.B.C", + Name = "TestClassABC" + }; + namespaceInfo3.Tests [0] = classInfo; + + NunitTestInfo methodInfo = new NunitTestInfo { + FixtureTypeName = "TestClassABC", + FixtureTypeNamespace = "A.B.C", + Name = "TestMethodABC" + }; + classInfo.Tests [0] = methodInfo; + + return namespaceInfo; + } + + NunitTestInfo namespaceNoDot () + { + NunitTestInfo namespaceInfo = new NunitTestInfo { + FixtureTypeName = "", + FixtureTypeNamespace = "", + Name = "A" + }; + + NunitTestInfo classInfo = new NunitTestInfo { + FixtureTypeName = "TestClassA", + FixtureTypeNamespace = "A", + Name = "TestClassA" + }; + namespaceInfo.Tests [0] = classInfo; + + NunitTestInfo methodInfo = new NunitTestInfo { + FixtureTypeName = "TestClassA", + FixtureTypeNamespace = "A", + Name = "TestMethodA" + }; + classInfo.Tests [0] = methodInfo; + + return namespaceInfo; + } } } |