public static BehaviorSpecificationElement GetOrCreateBehaviorSpecification(MSpecUnitTestProvider provider, IUnitTestElementManager manager, PsiModuleManager psiModuleManager, CacheManager cacheManager, IProject project, BehaviorElement behavior, ProjectModelElementEnvoy projectEnvoy, IClrTypeName declaringTypeName, string fieldName, bool isIgnored) { var id = BehaviorSpecificationElement.CreateId(behavior, fieldName); var behaviorSpecification = manager.GetElementById(project, id) as BehaviorSpecificationElement; if (behaviorSpecification != null) { behaviorSpecification.Parent = behavior; behaviorSpecification.State = UnitTestElementState.Valid; return(behaviorSpecification); } return(new BehaviorSpecificationElement(provider, psiModuleManager, cacheManager, behavior, projectEnvoy, declaringTypeName, fieldName, isIgnored)); }
public IUnitTestElement DeserializeElement(XmlElement parent, IUnitTestElement parentElement) { var typeName = parent.GetAttribute("elementType"); if (Equals(typeName, "ContextElement")) { return(ContextElement.ReadFromXml(parent, _solution, _contextFactory)); } if (Equals(typeName, "BehaviorElement")) { return(BehaviorElement.ReadFromXml(parent, parentElement, _solution, _behaviorFactory)); } if (Equals(typeName, "BehaviorSpecificationElement")) { return(BehaviorSpecificationElement.ReadFromXml(parent, parentElement, _solution, _behaviorSpecificationFactory)); } if (Equals(typeName, "ContextSpecificationElement")) { return(ContextSpecificationElement.ReadFromXml(parent, parentElement, _solution, _contextSpecificationFactory)); } return(null); }
public UnitTestTask CreateBehaviorSpecificationTask(ContextElement context, BehaviorSpecificationElement behaviorSpecification) { return(new UnitTestTask(behaviorSpecification, new BehaviorSpecificationTask(_providerId, context.AssemblyLocation, context.GetTypeClrName().FullName, behaviorSpecification.Behavior.FieldName, behaviorSpecification.FieldName, behaviorSpecification.Behavior.FieldType))); }
public void BehaviorSpecPresentationIsValid() { With(() => { var id = CreateId("id"); var element = new BehaviorSpecificationElement(id, CreateUnitTestElement(), Substitute.For <IClrTypeName>(), ServiceProvider, "field_is_something", false); Assert.That(element.GetPresentation(null, false), Is.EqualTo("field is something")); }); }
public void CanGetHashCode() { With(() => { var id = CreateId("id"); var element = new BehaviorSpecificationElement(id, CreateUnitTestElement(), Substitute.For <IClrTypeName>(), ServiceProvider, "field", false); Assert.That(element.GetHashCode(), Is.Not.EqualTo(0)); }); }
public IUnitTestElement DeserializeElement(XmlElement parent, IUnitTestElement parentElement) { var typeName = parent.GetAttribute("elementType"); if (Equals(typeName, "ContextElement")) { return(ContextElement.ReadFromXml(parent, parentElement, _provider, _solution, _manager, _psiModuleManager, _cacheManager)); } if (Equals(typeName, "BehaviorElement")) { return(BehaviorElement.ReadFromXml(parent, parentElement, _provider, _solution, _manager, _psiModuleManager, _cacheManager)); } if (Equals(typeName, "BehaviorSpecificationElement")) { return(BehaviorSpecificationElement.ReadFromXml(parent, parentElement, _provider, _solution, _manager, _psiModuleManager, _cacheManager)); } if (Equals(typeName, "ContextSpecificationElement")) { return(ContextSpecificationElement.ReadFromXml(parent, parentElement, _provider, _solution, _manager, _psiModuleManager, _cacheManager)); } return(null); }
public void BehaviorSpecsWithSamePropertiesAreEqual() { With(() => { var id = CreateId("id"); var type = Substitute.For <IClrTypeName>(); var context = new ContextElement(id, Substitute.For <IClrTypeName>(), ServiceProvider, "subject", false); var parent = new BehaviorElement(id, context, Substitute.For <IClrTypeName>(), ServiceProvider, "field", false); var element1 = new BehaviorSpecificationElement(id, parent, type, ServiceProvider, "field", false); var element2 = new BehaviorSpecificationElement(id, parent, type, ServiceProvider, "field", false); Assert.That(element1, Is.EqualTo(element2)); }); }
public static BehaviorSpecificationElement GetOrCreateBehaviorSpecification(MSpecUnitTestProvider provider, #if RESHARPER_61 IUnitTestElementManager manager, PsiModuleManager psiModuleManager, CacheManager cacheManager, #endif IProject project, BehaviorElement behavior, ProjectModelElementEnvoy projectEnvoy, string declaringTypeName, string fieldName, bool isIgnored) { #if RESHARPER_6 var id = BehaviorSpecificationElement.CreateId(behavior, fieldName); #if RESHARPER_61 var behaviorSpecification = manager.GetElementById(project, id) as BehaviorSpecificationElement; #else var behaviorSpecification = provider.UnitTestManager.GetElementById(project, id) as BehaviorSpecificationElement; #endif if (behaviorSpecification != null) { behaviorSpecification.Parent = behavior; behaviorSpecification.State = UnitTestElementState.Valid; return(behaviorSpecification); } #endif return(new BehaviorSpecificationElement(provider, #if RESHARPER_6 #if RESHARPER_61 psiModuleManager, cacheManager, #else provider.PsiModuleManager, provider.CacheManager, #endif #endif behavior, projectEnvoy, declaringTypeName, fieldName, isIgnored)); }
public IEnumerable <UnitTestElementDisposition> AcceptElement(string assemblyPath, IFile file, ITreeNode element) { IDeclaration declaration = (IDeclaration)element; BehaviorElement behavior = this._factory.CreateBehavior(declaration.DeclaredElement); if (behavior == null) { yield break; } var projectFile = file.GetSourceFile().ToProjectFile(); var behaviorTextRange = declaration.GetNameDocumentRange().TextRange; var behaviorContainingRange = declaration.GetDocumentRange().TextRange; yield return(new UnitTestElementDisposition(behavior, projectFile, behaviorTextRange, behaviorContainingRange)); var behaviorContainer = declaration.DeclaredElement.GetFirstGenericArgument(); if (!behaviorContainer.IsBehaviorContainer()) { yield break; } foreach (var field in behaviorContainer.Fields) { if (!field.IsSpecification()) { continue; } BehaviorSpecificationElement behaviorSpecification = this._behaviorSpecifications.CreateBehaviorSpecification(behavior, field); yield return(new UnitTestElementDisposition(behaviorSpecification, projectFile, behaviorTextRange, behaviorContainingRange)); } }
public BehaviorSpecificationElement GetOrCreateBehaviorSpecification(BehaviorElement behavior, IClrTypeName declaringTypeName, string fieldName, bool isIgnored) { var id = BehaviorSpecificationElement.CreateId(_provider, behavior, fieldName); var behaviorSpecification = this._manager.GetElementById(id) as BehaviorSpecificationElement; if (behaviorSpecification != null) { behaviorSpecification.Parent = behavior; behaviorSpecification.State = UnitTestElementState.Valid; return(behaviorSpecification); } return(new BehaviorSpecificationElement(this._provider, this._psiModuleManager, this._cacheManager, new ProjectModelElementEnvoy(behavior.GetProject()), behavior, declaringTypeName, fieldName, isIgnored)); }
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)); }