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 ContextElement GetOrCreateContext(string assemblyPath, IProject project, IClrTypeName typeName, string subject, ICollection <string> tags, bool isIgnored) { var id = ContextElement.CreateId(_provider, project, subject, typeName.FullName, tags); var contextElement = this._manager.GetElementById(id) as ContextElement; if (contextElement != null) { contextElement.State = UnitTestElementState.Valid; contextElement.AssemblyLocation = assemblyPath; return(contextElement); } return(new ContextElement(this._provider, this._psiModuleManager, this._cacheManager, new ProjectModelElementEnvoy(project), typeName, assemblyPath, subject, tags, isIgnored, _categoryFactory)); }
public UnitTestTask CreateContextTask(ContextElement context) { return(new UnitTestTask(context, new ContextTask(_providerId, context.AssemblyLocation, context.GetTypeClrName().FullName))); }
public BehaviorElement GetOrCreateBehavior(ContextElement context, IClrTypeName declaringTypeName, string fieldName, bool isIgnored, string fieldType) { var id = BehaviorElement.CreateId(context, fieldType, fieldName); var behavior = _manager.GetElementById(context.GetProject(), id) as BehaviorElement; if (behavior != null) { behavior.Parent = context; behavior.State = UnitTestElementState.Valid; return(behavior); } return(new BehaviorElement(_provider, _psiModuleManager, _cacheManager, context, new ProjectModelElementEnvoy(context.GetProject()), declaringTypeName, fieldName, isIgnored, fieldType)); }
public static ContextElement GetOrCreateContext(MSpecUnitTestProvider provider, IUnitTestElementManager manager, PsiModuleManager psiModuleManager, CacheManager cacheManager, IProject project, ProjectModelElementEnvoy projectEnvoy, IClrTypeName typeName, string assemblyLocation, string subject, ICollection <string> tags, bool isIgnored) { var id = ContextElement.CreateId(subject, typeName.FullName, tags); var contextElement = manager.GetElementById(project, id) as ContextElement; if (contextElement != null) { contextElement.State = UnitTestElementState.Valid; return(contextElement); } return(new ContextElement(provider, psiModuleManager, cacheManager, projectEnvoy, typeName, assemblyLocation, subject, tags, isIgnored)); }
protected virtual void PresentContext(ContextElement element, IPresentableItem item, TreeModelNode modelNode, PresentationState state) { PresentItem(item, element, state, UnitTestElementImage.TestContainer); }
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 BehaviorElement CreateBehavior(ContextElement context, IMetadataField behavior) { var typeContainingBehaviorSpecifications = behavior.GetFirstGenericArgument(); var fullyQualifiedTypeName = behavior.FirstGenericArgumentClass().FullyQualifiedName(); var typeName = GetNormalizedTypeName(fullyQualifiedTypeName); var behaviorElement = GetOrCreateBehavior(_provider, #if RESHARPER_61 _manager, _psiModuleManager, _cacheManager, #endif _project, _projectEnvoy, context, behavior.DeclaringType.FullyQualifiedName, behavior.Name, behavior.IsIgnored() || typeContainingBehaviorSpecifications.IsIgnored(), fullyQualifiedTypeName); if (!TypeNameCache.ContainsKey(typeName)) { TypeNameCache.Add(typeName, fullyQualifiedTypeName); } return(behaviorElement); }
public static BehaviorElement GetOrCreateBehavior(MSpecUnitTestProvider provider, IUnitTestElementManager manager, PsiModuleManager psiModuleManager, CacheManager cacheManager, IProject project, ProjectModelElementEnvoy projectEnvoy, ContextElement context, IClrTypeName declaringTypeName, string fieldName, bool isIgnored, string fieldType) { var id = BehaviorElement.CreateId(context, fieldType, fieldName); var behavior = manager.GetElementById(project, id) as BehaviorElement; if (behavior != null) { behavior.Parent = context; behavior.State = UnitTestElementState.Valid; return(behavior); } return(new BehaviorElement(provider, psiModuleManager, cacheManager, context, projectEnvoy, declaringTypeName, fieldName, isIgnored, fieldType)); }
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 ContextSpecificationElement CreateContextSpecification(ContextElement context, IMetadataField specification) { return(this.GetOrCreateContextSpecification(context, this._reflectionTypeNameCache.GetClrName(specification.DeclaringType), specification.Name, specification.IsIgnored())); }
public static ContextSpecificationElement GetOrCreateContextSpecification(MSpecUnitTestProvider provider, IUnitTestElementManager manager, PsiModuleManager psiModuleManager, CacheManager cacheManager, IProject project, ContextElement context, ProjectModelElementEnvoy projectEnvoy, IClrTypeName declaringTypeName, string fieldName, bool isIgnored) { var id = ContextSpecificationElement.CreateId(context, fieldName); var contextSpecification = manager.GetElementById(project, id) as ContextSpecificationElement; if (contextSpecification != null) { contextSpecification.Parent = context; contextSpecification.State = UnitTestElementState.Valid; return(contextSpecification); } return(new ContextSpecificationElement(provider, psiModuleManager, cacheManager, context, projectEnvoy, declaringTypeName, fieldName, isIgnored)); }
public ContextSpecificationElement CreateContextSpecification(ContextElement context, IMetadataField specification) { return this.GetOrCreateContextSpecification(context, this._reflectionTypeNameCache.GetClrName(specification.DeclaringType), specification.Name, specification.IsIgnored()); }
public UnitTestTask CreateContextTask(ContextElement context) { return new UnitTestTask(context, new ContextTask(this._providerId, context.AssemblyLocation, context.GetTypeClrName().FullName)); }
public void Explore(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver consumer, IMetadataTypeInfo metadataTypeInfo) { if (!metadataTypeInfo.IsContext()) { return; } ContextElement contextElement = this._factories.Contexts.CreateContext(project, assembly.Location.FullPath, metadataTypeInfo); consumer.OnUnitTestElement(contextElement); metadataTypeInfo.GetSpecifications() .ForEach(x => { var contextSpecificationElement = this._factories.ContextSpecifications.CreateContextSpecification(contextElement, x); consumer.OnUnitTestElement(contextSpecificationElement); }); metadataTypeInfo.GetBehaviors().ForEach(x => { var behaviorElement = this._factories.Behaviors.CreateBehavior(contextElement, x); consumer.OnUnitTestElement(behaviorElement); this._factories.BehaviorSpecifications .CreateBehaviorSpecificationsFromBehavior(behaviorElement, x) .ForEach(consumer.OnUnitTestElement); consumer.OnUnitTestElementChanged(behaviorElement); }); consumer.OnUnitTestElementChanged(contextElement); }
public UnitTestTask CreateContextTask(ContextElement context, bool isExplicit) { return(new UnitTestTask(context, new ContextTask(_providerId, context.AssemblyLocation, context.GetTypeClrName(), false))); }
/// <summary> /// Updates the entity with the specified id /// </summary> /// <returns>The response object</returns> public async Task <ContextResponse> UpdateEntityAsync(string entityId, ContextElement entity) { RESTClient <ContextResponse> client = new RESTClient <ContextResponse>(OrionConfig.AuthHeaderKey, _config.Token); string uri = string.Format(OrionConfig.ConvenienceUrlFormat, _config.BaseUrl, _config.Version1Path, OrionConfig.ContextEntitiesPath, entityId); string body = JsonConvert.SerializeObject(entity, jsonSettings); return(await client.PutAsync(uri, body)); }
public UnitTestTask CreateContextSpecificationTask(ContextElement context, ContextSpecificationElement contextSpecification) { return(new UnitTestTask(contextSpecification, new ContextSpecificationTask(_providerId, context.AssemblyLocation, context.GetTypeClrName().FullName, contextSpecification.FieldName))); }
/// <summary> /// 初始化一个<see cref="DbContextConfig"/>类型的新实例 /// </summary> internal DbContextConfig(ContextElement element) { Name = element.Name; Enabled = element.Enabled; DataLoggingEnabled = element.DataLoggingEnabled; ConnectionStringName = element.ConnectionStringName; ContextType = Type.GetType(element.ContextTypeName); InitializerConfig = new DbContextInitializerConfig(element.DbContextInitializer); }
public UnitTestTask CreateContextSpecificationTask(ContextElement context, ContextSpecificationElement contextSpecification) { return new UnitTestTask(contextSpecification, new ContextSpecificationTask(this._providerId, context.AssemblyLocation, context.GetTypeClrName().FullName, contextSpecification.FieldName)); }
public ElementSelector GetElementSelector(ContextElement elementType, string elementId) { if (Elements.ContainsKey(elementType) && Elements[elementType].ContainsKey(elementId)) { return(new ElementSelector(Elements[elementType][elementId])); } throw new NotSupportedException("Element is not supported by current context"); }
public UnitTestTask CreateBehaviorTask(ContextElement context, BehaviorElement behavior, bool isExplicit) { return(new UnitTestTask(behavior, new BehaviorTask(_providerId, context.AssemblyLocation, context.GetTypeClrName(), behavior.FieldName, false))); }
public ContextSpecificationElement CreateContextSpecification(ContextElement context, IMetadataField specification) { return(new ContextSpecificationElement(_provider, context, _project, specification.DeclaringType.FullyQualifiedName, specification.Name, specification.IsIgnored())); }
/// <summary> /// 初始化一个<see cref="DbContextConfig"/>类型的新实例 /// </summary> internal DbContextConfig(ContextElement element) { Name = element.Name; Enabled = element.Enabled; DataLoggingEnabled = element.DataLoggingEnabled; ConnectionStringName = element.ConnectionStringName; ReadConnectionStringNames = element.ReadConnectionStringNames.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); ContextType = Type.GetType(element.ContextTypeName); InitializerConfig = new DbContextInitializerConfig(element.DbContextInitializer); }
public BehaviorElement CreateBehavior(ContextElement context, IMetadataField behavior) { IMetadataTypeInfo typeContainingBehaviorSpecifications = behavior.GetFirstGenericArgument(); return(new BehaviorElement(_provider, context, _project, behavior.DeclaringType.FullyQualifiedName, behavior.Name, behavior.IsIgnored() || typeContainingBehaviorSpecifications.IsIgnored())); }
public UnitTestTask CreateBehaviorSpecificationTask(ContextElement context, BehaviorSpecificationElement behaviorSpecification) { return new UnitTestTask(behaviorSpecification, new BehaviorSpecificationTask(this._providerId, context.AssemblyLocation, context.GetTypeClrName().FullName, behaviorSpecification.Behavior.FieldName, behaviorSpecification.FieldName, behaviorSpecification.Behavior.FieldType)); }
public void AddContext(ITypeElement type, ContextElement context) { if (!this._contexts.ContainsKey(type)) { this._contexts.Add(type, context); } else { this._contexts[type] = context; } }
public void AddContext(ITypeElement type, ContextElement context) { if (!_contexts.ContainsKey(type)) { _contexts.Add(type, context); } else { _contexts[type] = context; } }
public void CanGetHashCode() { With(() => { var id = CreateId("id"); var element = new ContextElement(id, Substitute.For <IClrTypeName>(), ServiceProvider, "subject", false); Assert.That(element.GetHashCode(), Is.Not.EqualTo(0)); }); }
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 AddContext(ITypeElement contextType, ContextElement context) { if (!this._contexts.ContainsKey(contextType)) { this._contexts.Add(contextType, context); } else { this._contexts[contextType] = context; } }
/// <summary> /// 初始化一个<see cref="DbContextConfig"/>类型的新实例 /// </summary> internal DbContextConfig(ContextElement element) { Name = element.Name; Enabled = element.Enabled; ConnectionStringName = element.ConnectionStringName; ContextType = Type.GetType(element.ContextTypeName); if (ContextType == null) { throw new InvalidOperationException(Resources.ConfigFile_NameToTypeIsNull.FormatWith(element.ContextTypeName)); } InitializerConfig = new DbContextInitializerConfig(element.DbContextInitializer); }
public void ContextWithNoSubjectPresentationIsValid() { With(() => { var id = CreateId("id"); var type = new ClrTypeName("Namespace.Elements.my_class_name"); var element = new ContextElement(id, type, ServiceProvider, null, false); Assert.That(element.GetPresentation(null, false), Is.EqualTo("my class name")); }); }
public ContextSpecificationElement CreateContextSpecification(ContextElement context, IMetadataField specification) { return(GetOrCreateContextSpecification(_provider, _manager, _psiModuleManager, _cacheManager, _project, context, _projectEnvoy, _reflectionTypeNameCache.GetClrName(specification.DeclaringType), specification.Name, specification.IsIgnored())); }
public void ContextsWithSamePropertiesAreEqual() { With(() => { var id = CreateId("id"); var type = Substitute.For <IClrTypeName>(); var element1 = new ContextElement(id, type, ServiceProvider, "subject", false); var element2 = new ContextElement(id, type, ServiceProvider, "subject", false); Assert.That(element1, Is.EqualTo(element2)); }); }
public ContextSpecificationElement CreateContextSpecification(ContextElement context, IMetadataField specification) { return(GetOrCreateContextSpecification(_provider, #if RESHARPER_61 _manager, _psiModuleManager, _cacheManager, #endif _project, context, _projectEnvoy, specification.DeclaringType.FullyQualifiedName, specification.Name, specification.DeclaringType.GetTags(), specification.IsIgnored())); }
public BehaviorElement CreateBehavior(ContextElement context, IMetadataField behavior) { var typeContainingBehaviorSpecifications = behavior.GetFirstGenericArgument(); var metadataTypeName = behavior.FirstGenericArgumentClass().FullyQualifiedName(); var fieldType = new NormalizedTypeName(metadataTypeName); var behaviorElement = this.GetOrCreateBehavior(context, this._reflectionTypeNameCache.GetClrName(behavior.DeclaringType), behavior.Name, behavior.IsIgnored() || typeContainingBehaviorSpecifications.IsIgnored(), fieldType); return behaviorElement; }
public ContextSpecificationElement(MSpecUnitTestProvider provider, IPsi psiModuleManager, ICache cacheManager, ProjectModelElementEnvoy project, ContextElement context, IClrTypeName declaringTypeName, string fieldName, bool isIgnored) : base(provider, psiModuleManager, cacheManager, context, project, declaringTypeName, fieldName, isIgnored || context.Explicit) { this._id = CreateId(provider, context, fieldName); }
public ContextSpecificationElement GetOrCreateContextSpecification(ContextElement context, IClrTypeName declaringTypeName, string fieldName, bool isIgnored) { var id = ContextSpecificationElement.CreateId(_provider, context, fieldName); var contextSpecification = this._manager.GetElementById(id) as ContextSpecificationElement; if (contextSpecification != null) { contextSpecification.Parent = context; contextSpecification.State = UnitTestElementState.Valid; return contextSpecification; } return new ContextSpecificationElement(this._provider, this._psiModuleManager, this._cacheManager, new ProjectModelElementEnvoy(context.GetProject()), context, declaringTypeName, fieldName, isIgnored); }
public BehaviorElement(MSpecUnitTestProvider provider, IPsi psiModuleManager, ICache cacheManager, UnitTestElementId id, ContextElement context, ProjectModelElementEnvoy projectEnvoy, IClrTypeName declaringTypeName, string fieldName, bool isIgnored, string fieldType) : base(provider, psiModuleManager, cacheManager, context, projectEnvoy, declaringTypeName, fieldName, isIgnored || context.Explicit) { this.FieldType = fieldType; this._id = id; }
public BehaviorElement(MSpecUnitTestProvider provider, IPsi psiModuleManager, ICache cacheManager, // ReSharper disable SuggestBaseTypeForParameter ContextElement context, // ReSharper restore SuggestBaseTypeForParameter ProjectModelElementEnvoy projectEnvoy, IClrTypeName declaringTypeName, string fieldName, bool isIgnored, string fieldType) : base(provider, psiModuleManager, cacheManager, context, projectEnvoy, declaringTypeName, fieldName, isIgnored || context.Explicit) { this.FieldType = fieldType; this._id = CreateId(provider, context, fieldType, fieldName); }
public UnitTestTask CreateRunAssemblyTask(ContextElement context) { return new UnitTestTask(null, new RunAssemblyTask(this._providerId, context.AssemblyLocation)); }
public static UnitTestElementId CreateId(IUnitTestElementIdFactory elementIdFactory, IUnitTestProvider provider, ContextElement contextElement, string fieldName) { var result = new[] { contextElement.Id, fieldName }; var id = result.Where(s => !string.IsNullOrEmpty(s)).AggregateString("."); return elementIdFactory.Create(provider, new PersistentProjectId(contextElement.GetProject()), id); }
public BehaviorElement GetOrCreateBehavior(ContextElement context, IClrTypeName declaringTypeName, string fieldName, bool isIgnored, string fieldType) { var id = BehaviorElement.CreateId(_provider, context, fieldType, fieldName); var behavior = this._manager.GetElementById(id) as BehaviorElement; if (behavior != null) { behavior.Parent = context; behavior.State = UnitTestElementState.Valid; return behavior; } return new BehaviorElement(this._provider, this._psiModuleManager, this._cacheManager, context, new ProjectModelElementEnvoy(context.GetProject()), declaringTypeName, fieldName, isIgnored, fieldType); }