public static TestCase GetVSTestCaseFromMSpecTestCase(string source, MSpecTestCase mspecTestCase, bool disableFullTestNames, Uri testRunnerUri) { VisualStudioTestIdentifier vsTest = mspecTestCase.ToVisualStudioTestIdentifier(); TestCase testCase = new TestCase(vsTest.FullyQualifiedName, testRunnerUri, source) { DisplayName = disableFullTestNames ? mspecTestCase.SpecificationDisplayName : $"{mspecTestCase.ContextDisplayName} it {mspecTestCase.SpecificationDisplayName}", CodeFilePath = mspecTestCase.CodeFilePath, LineNumber = mspecTestCase.LineNumber }; Trait classTrait = new Trait(Strings.TRAIT_CLASS, mspecTestCase.ClassName); Trait subjectTrait = new Trait(Strings.TRAIT_SUBJECT, string.IsNullOrEmpty(mspecTestCase.Subject) ? Strings.TRAIT_SUBJECT_NOSUBJECT : mspecTestCase.Subject); testCase.Traits.Add(classTrait); testCase.Traits.Add(subjectTrait); if (mspecTestCase.Tags != null) { foreach (var tag in mspecTestCase.Tags) { if (!string.IsNullOrEmpty(tag)) { Trait tagTrait = new Trait(Strings.TRAIT_TAG, tag); testCase.Traits.Add(tagTrait); } } } Debug.WriteLine($"TestCase {testCase.FullyQualifiedName}"); return(testCase); }
public SingleBehaviorTestRunListenerWrapper(ISpecificationRunListener runListener, VisualStudioTestIdentifier listenFor) { if (listenFor == null) throw new ArgumentNullException(nameof(listenFor)); if (runListener == null) throw new ArgumentNullException(nameof(runListener)); this.runListener = runListener; this.listenFor = listenFor; }
public override bool Equals(object obj) { VisualStudioTestIdentifier test = obj as VisualStudioTestIdentifier; if (test != null) { return(FullyQualifiedName.Equals(test.FullyQualifiedName, StringComparison.Ordinal)); } else { return(base.Equals(obj)); } }
public static TestCase GetVSTestCaseFromMSpecTestCase(string source, MSpecTestCase mspecTestCase, bool disableFullTestNames, Uri testRunnerUri, Func <string, string, dynamic> traitCreator) { VisualStudioTestIdentifier vsTest = mspecTestCase.ToVisualStudioTestIdentifier(); TestCase testCase = new TestCase(vsTest.FullyQualifiedName, testRunnerUri, source) { DisplayName = disableFullTestNames ? mspecTestCase.SpecificationDisplayName : $"{mspecTestCase.ContextDisplayName} it {mspecTestCase.SpecificationDisplayName}", CodeFilePath = mspecTestCase.CodeFilePath, LineNumber = mspecTestCase.LineNumber }; if (MSpecTestAdapter.UseTraits) { dynamic dynTestCase = testCase; dynamic classTrait = traitCreator(Strings.TRAIT_CLASS, mspecTestCase.ClassName); dynamic subjectTrait = traitCreator(Strings.TRAIT_SUBJECT, string.IsNullOrEmpty(mspecTestCase.Subject) ? Strings.TRAIT_SUBJECT_NOSUBJECT : mspecTestCase.Subject); dynTestCase.Traits.Add(classTrait); dynTestCase.Traits.Add(subjectTrait); if (mspecTestCase.Tags != null) { foreach (var tag in mspecTestCase.Tags) { if (!string.IsNullOrEmpty(tag)) { dynamic tagTrait = traitCreator(Strings.TRAIT_TAG, tag); dynTestCase.Traits.Add(tagTrait); } } } } Debug.WriteLine(string.Format("TestCase {0}", (object)testCase.FullyQualifiedName)); return(testCase); }