public XunitTestClassElement GetOrCreateTestClass(string id, IProject project, IClrTypeName typeName, string assemblyLocation, OneToSetMap <string, string> traits) { lock (lockObject) { var elementId = services.CreateId(project, id); var element = GetElementById <XunitTestClassElement>(elementId); if (element == null) { element = new XunitTestClassElement(services, elementId, typeName.GetPersistent(), assemblyLocation); CacheElement(elementId, element); } element.State = UnitTestElementState.Valid; // Assembly location might have changed if someone e.g. switches from debug to release element.AssemblyLocation = assemblyLocation; services.ElementManager.RemoveElements(element.Children.Where(c => c.State == UnitTestElementState.Invalid).ToSet()); UpdateCategories(element, traits); return(element); } }
public ContextElement GetOrCreateContext(string assemblyPath, IProject project, IClrTypeName contextTypeName, string subject, ICollection <string> tags, bool isIgnored) { UnitTestElementId id = ContextElement.CreateId(_elementIdFactory, _provider, project, subject, contextTypeName.FullName, tags); var contextElement = this._manager.GetElementById(id) as ContextElement; if (contextElement != null) { contextElement.AssemblyLocation = assemblyPath; return(contextElement); } return(new ContextElement(this._provider, id, contextTypeName.GetPersistent(), this._cachingService, this._manager, assemblyPath, subject, tags, isIgnored, _categoryFactory)); }
public IUnitTestElement GetOrCreateTestMethod(IProject project, IClrTypeName typeName, string methodName, string assemblyLocation, bool isParameterized) { var classElementId = GetClassElementId(project, typeName); var classElement = unitTestManager.GetElementById(project, classElementId) as TestClassElement; var id = string.Format("{0}.{1}", classElementId, methodName); var element = unitTestManager.GetElementById(project, id) as TestMethodElement; if (element != null) { element.State = UnitTestElementState.Valid; } else { element = new TestMethodElement( provider, classElement, new ProjectModelElementEnvoy(project), declaredElementProvider, id, typeName.GetPersistent(), methodName, assemblyLocation, isParameterized); } if (!classElement.Children.Contains(element)) { classElement.Children.Add(element); } return(element); }
public BehaviorElement GetOrCreateBehavior(ContextElement context, IClrTypeName declaringTypeName, string fieldName, bool isIgnored, string fieldType) { var id = BehaviorElement.CreateId(_elementIdFactory, _provider, context, fieldType, fieldName); var behavior = this._manager.GetElementById(id) as BehaviorElement; if (behavior != null) { behavior.Parent = context; return(behavior); } return(new BehaviorElement(this._provider, id, context, declaringTypeName.GetPersistent(), this._cachingService, this._manager, fieldName, isIgnored, fieldType)); }
public SpecificationContainerElement GetOrCreateSpecificationContainerElement(IProject project, IClrTypeName typeName, string assemblyLocation) { var id = "simple:" + typeName.FullName; var element = _unitTestManager.GetElementById(project, id); if (element != null) { element.State = UnitTestElementState.Valid; return element as SpecificationContainerElement; } return new SpecificationContainerElement(_provider, new ProjectModelElementEnvoy(project), _cacheManager, _psiModuleManager, id, typeName.GetPersistent(), assemblyLocation); }
public SpecificationElement GetOrCreateSpecificationElement(IProject project, SpecificationContainerElement parent, IClrTypeName typeName, string methodName, string skipReason) { var id = string.Format("simple:{0}.{1}", parent.TypeName.FullName, methodName); var element = _unitTestManager.GetElementById(project, id); if (element != null) { element.State = UnitTestElementState.Valid; return element as SpecificationElement; } return new SpecificationElement(_provider, parent, new ProjectModelElementEnvoy(project), _cacheManager, _psiModuleManager, id, typeName.GetPersistent(), methodName, skipReason); }
public static XunitTestMethodElement CreateTestMethod(IUnitTestProvider provider, IProject project, DeclaredElementProvider declaredElementProvider, XunitTestClassElement classElement, IClrTypeName typeName, string methodName, string skipReason, IEnumerable<UnitTestElementCategory> categories, bool isDynamic = false) { var id = GetTestMethodId(classElement, typeName, methodName); return new XunitTestMethodElement(provider, classElement, new ProjectModelElementEnvoy(project), declaredElementProvider, id, typeName.GetPersistent(), methodName, skipReason, categories, isDynamic); }
public static XunitTestMethodElement CreateTestMethod(IUnitTestProvider provider, IProject project, DeclaredElementProvider declaredElementProvider, XunitTestClassElement classElement, IClrTypeName typeName, string methodName, string skipReason, JetHashSet <string> categories, bool isDynamic = false) { var id = GetTestMethodId(classElement, typeName, methodName); return(new XunitTestMethodElement(provider, classElement, new ProjectModelElementEnvoy(project), declaredElementProvider, id, typeName.GetPersistent(), methodName, skipReason, categories, isDynamic)); }
public TestClassElement GetOrCreateTestClass( IProject project, IClrTypeName typeName, string assemblyLocation) { var id = GetClassElementId(project, typeName); var element = unitTestManager.GetElementById(project, id); if (element != null) { element.State = UnitTestElementState.Valid; var classElement = element as TestClassElement; return classElement; } return new TestClassElement( provider, new ProjectModelElementEnvoy(project), declaredElementProvider, id, typeName.GetPersistent(), assemblyLocation); }
public XunitTestClassElement GetOrCreateTestClass(IProject project, IClrTypeName typeName, string assemblyLocation, MultiValueDictionary<string, string> traits) { var categories = GetCategories(traits); // dotCover displays the ids of covering tests, rather than a more presentable // name. That makes the "xunit" and project identifiers rather ugly. Fortunately, // dotCover will ignore any text in square brackets var id = string.Format("[xunit:{0}]{1}", project.GetPersistentID(), typeName.FullName); var element = unitTestManager.GetElementById(project, id); if (element != null) { element.State = UnitTestElementState.Valid; var classElement = element as XunitTestClassElement; if (classElement != null) // Shouldn't be null, unless someone else has the same id { classElement.AssemblyLocation = assemblyLocation; // In case it's changed, e.g. someone's switched from Debug to Release classElement.SetCategories(categories); } return classElement; } return new XunitTestClassElement(provider, new ProjectModelElementEnvoy(project), declaredElementProvider, id, typeName.GetPersistent(), assemblyLocation, categories); }
public TestClassElement GetOrCreateTestClass( IProject project, IClrTypeName typeName, string assemblyLocation) { var id = GetClassElementId(project, typeName); var element = unitTestManager.GetElementById(project, id); if (element != null) { element.State = UnitTestElementState.Valid; var classElement = element as TestClassElement; return(classElement); } return(new TestClassElement( provider, new ProjectModelElementEnvoy(project), declaredElementProvider, id, typeName.GetPersistent(), assemblyLocation)); }
public BehaviorSpecificationElement GetOrCreateBehaviorSpecification(BehaviorElement behavior, IClrTypeName declaringTypeName, string fieldName, bool isIgnored) { var id = BehaviorSpecificationElement.CreateId(_elementIdFactory, _provider, behavior, fieldName); var behaviorSpecification = this._manager.GetElementById(id) as BehaviorSpecificationElement; if (behaviorSpecification != null) { behaviorSpecification.Parent = behavior; return(behaviorSpecification); } return(new BehaviorSpecificationElement(this._provider, id, behavior, declaringTypeName.GetPersistent(), this._cachingService, this._manager, fieldName, isIgnored)); }
public ContextSpecificationElement GetOrCreateContextSpecification(ContextElement context, IClrTypeName declaringTypeName, string fieldName, bool isIgnored) { var id = ContextSpecificationElement.CreateId(_elementIdFactory, _provider, context, fieldName); var contextSpecification = this._manager.GetElementById(id) as ContextSpecificationElement; if (contextSpecification != null) { contextSpecification.Parent = context; return(contextSpecification); } return(new ContextSpecificationElement(this._provider, id, context, declaringTypeName.GetPersistent(), this._cachingService, this._manager, fieldName, isIgnored)); }
public XunitInheritedTestMethodContainerElement GetOrCreateInheritedTestMethodContainer(IProject project, IClrTypeName typeName, string methodName) { lock (lockObject) { var id = typeName.FullName + "." + methodName; var elementId = services.CreateId(project, id); var element = GetElementById <XunitInheritedTestMethodContainerElement>(elementId); if (element == null) { element = new XunitInheritedTestMethodContainerElement(services, elementId, typeName.GetPersistent(), methodName); CacheElement(elementId, element); } return(element); } }
public IUnitTestElement GetOrCreateTestMethod(IProject project, IClrTypeName typeName, string methodName, string assemblyLocation, bool isParameterized) { var classElementId = GetClassElementId(project, typeName); var classElement = unitTestManager.GetElementById(project, classElementId) as TestClassElement; var id = string.Format("{0}.{1}", classElementId, methodName); var element = unitTestManager.GetElementById(project, id) as TestMethodElement; if (element != null) { element.State = UnitTestElementState.Valid; } else { element = new TestMethodElement( provider, classElement, new ProjectModelElementEnvoy(project), declaredElementProvider, id, typeName.GetPersistent(), methodName, assemblyLocation, isParameterized); } if (!classElement.Children.Contains(element)) classElement.Children.Add(element); return element; }
public XunitTestClassElement GetOrCreateTestClass(IProject project, IClrTypeName typeName, string assemblyLocation, MultiValueDictionary <string, string> traits) { var categories = GetCategories(traits); // dotCover displays the ids of covering tests, rather than a more presentable // name. That makes the "xunit" and project identifiers rather ugly. Fortunately, // dotCover will ignore any text in square brackets var id = string.Format("[xunit:{0}]{1}", project.GetPersistentID(), typeName.FullName); var element = unitTestManager.GetElementById(project, id); if (element != null) { element.State = UnitTestElementState.Valid; var classElement = element as XunitTestClassElement; if (classElement != null) // Shouldn't be null, unless someone else has the same id { classElement.AssemblyLocation = assemblyLocation; // In case it's changed, e.g. someone's switched from Debug to Release classElement.SetCategories(categories); } return(classElement); } return(new XunitTestClassElement(provider, new ProjectModelElementEnvoy(project), declaredElementProvider, id, typeName.GetPersistent(), assemblyLocation, categories)); }
public XunitInheritedTestMethodContainerElement GetOrCreateInheritedTestMethodContainer(IProject project, IClrTypeName typeName, string methodName) { // See the comment in GetOrCreateTestClass re: dotCover showing ids instead of names. // This element never becomes a genuine test element, so dotCover will never see it, // but keep the id format the same var id = string.Format("[xunit:{0}]{1}.{2}", project.GetPersistentID(), typeName.FullName, methodName); var element = unitTestManager.GetElementById(project, id); if (element != null) { return(element as XunitInheritedTestMethodContainerElement); } return(new XunitInheritedTestMethodContainerElement(provider, new ProjectModelElementEnvoy(project), id, typeName.GetPersistent(), methodName)); }
public XunitInheritedTestMethodContainerElement GetOrCreateInheritedTestMethodContainer(IProject project, IClrTypeName typeName, string methodName) { // See the comment in GetOrCreateTestClass re: dotCover showing ids instead of names. // This element never becomes a genuine test element, so dotCover will never see it, // but keep the id format the same var id = string.Format("[xunit:{0}]{1}.{2}", project.GetPersistentID(), typeName.FullName, methodName); var element = unitTestManager.GetElementById(project, id); if (element != null) return element as XunitInheritedTestMethodContainerElement; return new XunitInheritedTestMethodContainerElement(provider, new ProjectModelElementEnvoy(project), id, typeName.GetPersistent(), methodName); }