public PsiFileExplorer(UnitTestElementFactory unitTestElementFactory, TestIdentifier conventionCheck, UnitTestElementLocationConsumer consumer, IFile psiFile, Func<bool> interrupted) { this.unitTestElementFactory = unitTestElementFactory; this.conventionCheck = conventionCheck; this.consumer = consumer; this.psiFile = psiFile; this.interrupted = interrupted; }
public PsiFileExplorer(UnitTestElementFactory unitTestElementFactory, TestIdentifier conventionCheck, UnitTestElementLocationConsumer consumer, IFile psiFile, CheckForInterrupt interrupted) { this.unitTestElementFactory = unitTestElementFactory; this.conventionCheck = conventionCheck; this.consumer = consumer; this.psiFile = psiFile; this.interrupted = interrupted; }
protected override ICollection <IUnitTestElement> GetUnitTestElements(IProject testProject, string assemblyLocation) { var elements = base.GetUnitTestElements(testProject, assemblyLocation).ToList(); var services = testProject.GetComponent <XunitServiceProvider>(); var unitTestElementFactory = new UnitTestElementFactory(services, null); var theoryElement = unitTestElementFactory.GetOrCreateTestTheory(testProject, (XunitTestMethodElement)elements[1], "TestMethod(value: 42)"); elements.Add(theoryElement); return(elements); }
private TestUnitTestElementObserver GetMetadataObserver(IProject project, IMetadataAssembly assembly) { var serviceProvider = Solution.GetComponent <MspecServiceProvider>(); var observer = new TestUnitTestElementObserver(); var factory = new UnitTestElementFactory(serviceProvider, observer.TargetFrameworkId); var explorer = new MspecTestMetadataExplorer(factory, observer); explorer.ExploreAssembly(project, assembly, CancellationToken.None); return(observer); }
public void CanCreateBehavior() { With(project => { var factory = new UnitTestElementFactory(ServiceProvider, TargetFrameworkId.Default); var element = factory.GetOrCreateBehavior(project, CreateUnitTestElement(), new ClrTypeName("MyClass"), "my_field", false); Assert.That(element, Is.Not.Null); Assert.That(element.GetPresentation(), Is.EqualTo("behaves like my field")); }); }
private TestUnitTestElementObserver GetPsiObserver(IFile file) { var serviceProvider = Solution.GetComponent <MspecServiceProvider>(); var searchDomainFactory = Solution.GetComponent <SearchDomainFactory>(); var observer = new TestUnitTestElementObserver(); var factory = new UnitTestElementFactory(serviceProvider, observer.TargetFrameworkId); var explorer = new MspecPsiFileExplorer(searchDomainFactory, factory, observer, () => false); file.ProcessDescendants(explorer); return(observer); }
public void CanCreateBehaviorSpec() { With(project => { var factory = new UnitTestElementFactory(ServiceProvider, TargetFrameworkId.Default); var parent = factory.GetOrCreateContext(project, new ClrTypeName("Parent"), BaseTestDataPath, "subject", new string[0], false); var element = factory.GetOrCreateBehaviorSpecification(project, parent, new ClrTypeName("MyClass"), "my_field", false); Assert.That(element, Is.Not.Null); Assert.That(element.GetPresentation(), Is.EqualTo("my field")); }); }
public void CanCreateContext() { With(project => { var factory = new UnitTestElementFactory(ServiceProvider, TargetFrameworkId.Default); var element = factory.GetOrCreateContext(project, new ClrTypeName("MyClass"), BaseTestDataPath, "subject", new[] { "tag1" }, false); Assert.That(element, Is.Not.Null); Assert.That(element.GetPresentation(), Is.EqualTo("subject, MyClass")); Assert.That(element.OwnCategories.Any(x => x.Name == "tag1"), Is.True); }); }
protected override ICollection <IUnitTestElement> GetUnitTestElements(IProject testProject, string assemblyLocation) { var elements = base.GetUnitTestElements(testProject, assemblyLocation).ToList(); var element = elements.Single(e => e.ShortName == "HasRunWith") as XunitTestClassElement; var services = testProject.GetComponent <XunitServiceProvider>(); var unitTestElementFactory = new UnitTestElementFactory(services, null); var theoryElement = unitTestElementFactory.GetOrCreateTestMethod(testProject, element, element.TypeName, "TestMethodWithExistingTask", string.Empty, new OneToSetMap <string, string>(), isDynamic: true); elements.Add(theoryElement); return(elements); }
public void GetsExistingContextSpecFromElementManager() { With(project => { var factory = new UnitTestElementFactory(ServiceProvider, TargetFrameworkId.Default); var parent = factory.GetOrCreateContext(project, new ClrTypeName("Parent"), BaseTestDataPath, "subject", new string[0], false); var element1 = factory.GetOrCreateContextSpecification(project, parent, new ClrTypeName("MyClass"), "my_field", false); ServiceProvider.ElementManager.AddElements(new HashSet <IUnitTestElement> { element1 }); var element2 = factory.GetOrCreateContextSpecification(project, parent, new ClrTypeName("MyClass"), "my_field", false); Assert.That(element1, Is.Not.Null); Assert.That(element2, Is.Not.Null); Assert.That(element1, Is.SameAs(element2)); }); }
internal static IUnitTestElement ReadFromXml(XmlElement parent, IUnitTestElement parentElement, ISolution solution, UnitTestElementFactory unitTestElementFactory) { var testClass = parentElement as TestClassElement; if (testClass == null) throw new InvalidOperationException("parentElement should be Fixie test class"); var typeName = parent.GetAttribute(AttributeNames.TypeName); var methodName = parent.GetAttribute(AttributeNames.MethodName); var projectId = parent.GetAttribute(AttributeNames.ProjectId); var isParameterized = bool.Parse(parent.GetAttribute(AttributeNames.IsParameterized)); var project = (IProject)ProjectUtil.FindProjectElementByPersistentID(solution, projectId); if (project == null) return null; return unitTestElementFactory.GetOrCreateTestMethod(project, testClass, typeName, methodName, isParameterized); }
internal static IUnitTestElement ReadFromXml(XmlElement parent, IUnitTestElement parentElement, ISolution solution, UnitTestElementFactory unitTestElementFactory) { var projectId = parent.GetAttribute(AttributeNames.ProjectId); var typeName = parent.GetAttribute(AttributeNames.TypeName); var project = (IProject)ProjectUtil.FindProjectElementByPersistentID(solution, projectId); if (project == null) { return(null); } var assemblyLocation = project.GetOutputFilePath().FullPath; return(unitTestElementFactory.GetOrCreateTestClass(project, new ClrTypeName(typeName), assemblyLocation)); }
internal static IUnitTestElement ReadFromXml(XmlElement parent, IUnitTestElement parentElement, ISolution solution, UnitTestElementFactory unitTestElementFactory) { var testMethod = parentElement as TestMethodElement; if (testMethod == null) throw new InvalidOperationException("parentElement should be Fixie test method"); var name = parent.GetAttribute(AttributeNames.ShortName); var project = testMethod.GetProject(); if (project == null) return null; return unitTestElementFactory.GetOrCreateTestCase(project, testMethod, name); }
internal static IUnitTestElement ReadFromXml(XmlElement parent, IUnitTestElement parentElement, ISolution solution, UnitTestElementFactory unitTestElementFactory) { var testClass = parentElement as TestClassElement; if (testClass == null) { throw new InvalidOperationException("parentElement should be Fixie test class"); } var typeName = parent.GetAttribute(AttributeNames.TypeName); var methodName = parent.GetAttribute(AttributeNames.MethodName); var projectId = parent.GetAttribute(AttributeNames.ProjectId); var isParameterized = bool.Parse(parent.GetAttribute(AttributeNames.IsParameterized)); var project = (IProject)ProjectUtil.FindProjectElementByPersistentID(solution, projectId); if (project == null) { return(null); } return(unitTestElementFactory.GetOrCreateTestMethod(project, testClass, typeName, methodName, isParameterized)); }
internal static IUnitTestElement ReadFromXml(XmlElement parent, IUnitTestElement parentElement, ISolution solution, UnitTestElementFactory unitTestElementFactory) { var testMethod = parentElement as TestMethodElement; if (testMethod == null) { throw new InvalidOperationException("parentElement should be Fixie test method"); } var name = parent.GetAttribute(AttributeNames.ShortName); var project = testMethod.GetProject(); if (project == null) { return(null); } return(unitTestElementFactory.GetOrCreateTestCase(project, testMethod, name)); }