public VsTestTestClass(IVsTestTestRunner testRunner, Project project, VsTestUnitTest vsTestUnit) : base(vsTestUnit.FixtureTypeName) { Project = project; this.testRunner = testRunner; FixtureTypeName = vsTestUnit.FixtureTypeName; TestSourceCodeDocumentId = string.IsNullOrEmpty(vsTestUnit.FixtureTypeNamespace) ? FixtureTypeName : vsTestUnit.FixtureTypeNamespace + "." + FixtureTypeName; cts = new CancellationTokenSource(); var token = cts.Token; IdeApp.TypeSystemService.GetCompilationAsync(Project, token).ContinueWith((t) => { if (token.IsCancellationRequested) { return; } 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); }, token, TaskContinuationOptions.NotOnFaulted, TaskScheduler.Default).Ignore(); }
public void AddTests(IEnumerable <TestCase> tests) { foreach (TestCase test in tests) { var VsTestTest = new VsTestUnitTest(testRunner, test, Project); AddTest(VsTestTest); } }
public VsTestTestClass(IVsTestTestRunner testRunner, Project project, VsTestUnitTest vsTestUnit) : base(vsTestUnit.FixtureTypeName) { this.Project = project; this.testRunner = testRunner; FixtureTypeName = vsTestUnit.FixtureTypeName; TestSourceCodeDocumentId = string.IsNullOrEmpty(vsTestUnit.FixtureTypeNamespace) ? FixtureTypeName : vsTestUnit.FixtureTypeNamespace + "." + FixtureTypeName; }
internal void AddTest(VsTestUnitTest VsTestTest) { string childNamespace = VsTestTest.FixtureTypeNamespace; if (currentNamespace == null || currentNamespace.Name != childNamespace) { currentNamespace = new VsTestNamespaceTestGroup(testRunner, currentNamespace, Project, childNamespace); currentNamespace.AddTest(VsTestTest); Tests.Add(currentNamespace); } else { if (currentNamespace.currentClass == null || currentNamespace.currentClass.FixtureTypeName != VsTestTest.FixtureTypeName) { currentNamespace.currentClass = new VsTestTestClass(testRunner, Project, VsTestTest); currentNamespace.Tests.Add(currentNamespace.currentClass); } currentNamespace.currentClass.Tests.Add(VsTestTest); } }
void AddTest(VsTestUnitTest VsTestTest) { string childNamespace = VsTestTest.GetChildNamespace(FixtureTypeNamespace); if (string.IsNullOrEmpty(childNamespace)) { if (currentClass == null || currentClass.FixtureTypeName != VsTestTest.FixtureTypeName) { currentClass = new VsTestTestClass(testRunner, Project, VsTestTest.FixtureTypeName); Tests.Add(currentClass); } currentClass.Tests.Add(VsTestTest); } else if (currentNamespace.Name == childNamespace) { currentNamespace.AddTest(VsTestTest); } else { currentNamespace = new VsTestNamespaceTestGroup(testRunner, currentNamespace, Project, childNamespace); currentNamespace.AddTest(VsTestTest); Tests.Add(currentNamespace); } }