diff options
author | Mike Krüger <mikkrg@microsoft.com> | 2018-12-12 16:47:39 +0300 |
---|---|---|
committer | Mike Krüger <mikkrg@microsoft.com> | 2018-12-12 16:59:32 +0300 |
commit | df3a84899c27b384396b1eb6790897b1df3d39c5 (patch) | |
tree | 0ab7ebe0b2fd96a5e62ec3be033aa7eb64b0711c /main/src/addins/MonoDevelop.UnitTesting | |
parent | 7ea797cc8e9f0dec5319f4a79c1f0126dfa8c805 (diff) |
Fixes VSTS Bug 731943: [Feedback] xUnit Fact DisplayName not shown in
test explorer if string has a period at the end.
https://devdiv.visualstudio.com/DevDiv/_workitems/edit/731943
Diffstat (limited to 'main/src/addins/MonoDevelop.UnitTesting')
2 files changed, 5 insertions, 13 deletions
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 4ae6127211..8fa4dcb98d 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 @@ -59,6 +59,7 @@ namespace MonoDevelop.UnitTesting.Tests [TestCase ("A.B.MyTest", "A.B.MyTestDisplayName", "A", "B", "MyTestDisplayName")] [TestCase ("A.B.MyTest", "A.B.MyTest(text: \"ab\")", "A", "B", "MyTest(text: \"ab\")")] [TestCase ("A.B.MyTest", "A.B.MyTest(text: \"a.b\")", "A", "B", "MyTest(text: \"a.b\")")] + [TestCase ("MyClass.MyTest", "Name with dot.", "", "MyClass", "Name with dot.")] public void TestName ( string fullyQualifiedName, string displayName, diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestUnitTest.cs b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestUnitTest.cs index e78a0a9903..64af96eb9e 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestUnitTest.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestUnitTest.cs @@ -91,7 +91,6 @@ namespace MonoDevelop.UnitTesting.VsTest sourceCodeLocation = new SourceCodeLocation (source.SourceTree.FilePath, line.StartLinePosition.Line, line.StartLinePosition.Character); }).Ignore (); } - int index = test.FullyQualifiedName.LastIndexOf ('.'); if (index > 0) { FixtureTypeName = test.FullyQualifiedName.Substring (0, index); @@ -107,18 +106,10 @@ namespace MonoDevelop.UnitTesting.VsTest FixtureTypeNamespace = string.Empty; FixtureTypeName = string.Empty; } - - int openBraceIndex = test.DisplayName.IndexOf ('('); - if (openBraceIndex == -1) { - index = test.DisplayName.LastIndexOf ('.'); - } else { - index = test.DisplayName.LastIndexOf ('.', openBraceIndex); - } - - if (index > 0) { - name = test.DisplayName.Substring (index + 1); - } else { - name = test.DisplayName; + name = test.DisplayName; + var obsoletePrefix = string.IsNullOrEmpty (FixtureTypeNamespace) ? FixtureTypeName : FixtureTypeNamespace + "." + FixtureTypeName; + if (test.DisplayName.StartsWith(obsoletePrefix, StringComparison.Ordinal) && test.DisplayName [obsoletePrefix.Length] == '.') { + name = test.DisplayName.Substring (obsoletePrefix.Length + 1); } } |