Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeting Yang <ketyang@microsoft.com>2019-08-29 00:19:37 +0300
committerKeting Yang <ketyang@microsoft.com>2019-08-29 00:19:37 +0300
commit6682ed357c60c822114c9901bdea499a5add2a6b (patch)
tree6c28b421f07e1690f71d2ccbf1a02593a9bfef28 /main/src/addins/MonoDevelop.UnitTesting
parentc31db83fe4a5d65e1f04a0d4fab1cb86fe9934fb (diff)
[Test Tools] let unit tests support "Show Test Source Code"
Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/973891/
Diffstat (limited to 'main/src/addins/MonoDevelop.UnitTesting')
-rw-r--r--main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestTestClass.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestTestClass.cs b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestTestClass.cs
index 1cd77f293a..189e156b4d 100644
--- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestTestClass.cs
+++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestTestClass.cs
@@ -29,6 +29,10 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using MonoDevelop.Core.Execution;
using MonoDevelop.Projects;
using MonoDevelop.UnitTesting;
+using MonoDevelop.Ide;
+using System;
+using MonoDevelop.Ide.TypeSystem;
+using System.Linq;
namespace MonoDevelop.UnitTesting.VsTest
{
@@ -36,6 +40,7 @@ namespace MonoDevelop.UnitTesting.VsTest
{
public Project Project { get; private set; }
IVsTestTestRunner testRunner;
+ SourceCodeLocation sourceCodeLocation;
public VsTestTestClass (IVsTestTestRunner testRunner, Project project, VsTestUnitTest vsTestUnit)
: base (vsTestUnit.FixtureTypeName)
@@ -44,6 +49,25 @@ namespace MonoDevelop.UnitTesting.VsTest
this.testRunner = testRunner;
FixtureTypeName = vsTestUnit.FixtureTypeName;
TestSourceCodeDocumentId = string.IsNullOrEmpty (vsTestUnit.FixtureTypeNamespace) ? FixtureTypeName : vsTestUnit.FixtureTypeNamespace + "." + FixtureTypeName;
+
+ if (sourceCodeLocation == null) {
+ IdeApp.TypeSystemService.GetCompilationAsync (Project).ContinueWith ((t) => {
+ var className = TestSourceCodeDocumentId;
+
+ var compilation = t.Result;
+ if (compilation == null)
+ return;
+ var cls = compilation.GetTypeByMetadataName (className);
+ if (cls == null)
+ return;
+ var source = cls.Locations.FirstOrDefault (l => l.IsInSource);
+ if (source == null)
+ return;
+ var line = source.GetLineSpan ();
+
+ sourceCodeLocation = new SourceCodeLocation (source.SourceTree.FilePath, line.StartLinePosition.Line, line.StartLinePosition.Character);
+ }).Ignore();
+ }
}
protected override UnitTestResult OnRun (TestContext testContext)
@@ -68,5 +92,12 @@ namespace MonoDevelop.UnitTesting.VsTest
}
}
}
+
+ public override SourceCodeLocation SourceCodeLocation {
+ get {
+ return sourceCodeLocation;
+ }
+ }
+
}
}