Пример #1
0
        public static string CreateId(ContextElement parent, string fieldName)
        {
            var id = String.Format("{0}.{1}", parent.Id, fieldName);

            System.Diagnostics.Debug.WriteLine("BE  " + id);
            return(id);
        }
    public static BehaviorElement GetOrCreateBehavior(MSpecUnitTestProvider provider,
                                                      IProject project,
                                                      ProjectModelElementEnvoy projectEnvoy,
                                                      ContextElement context,
                                                      string declaringTypeName,
                                                      string fieldName,
                                                      bool isIgnored,
                                                      string fullyQualifiedTypeName)
    {
#if RESHARPER_6
      var id = BehaviorElement.CreateId(context, fieldName);
      var behavior = provider.UnitTestManager.GetElementById(project, id) as BehaviorElement;
      if (behavior != null)
      {
        behavior.Parent = context;
        behavior.State = UnitTestElementState.Valid;
        return behavior;
      }
#endif

      return new BehaviorElement(provider,
                                 context,
                                 projectEnvoy,
                                 declaringTypeName,
                                 fieldName,
                                 isIgnored,
                                 fullyQualifiedTypeName);
    }
 public UnitTestTask CreateContextTask(ContextElement context)
 {
   return new UnitTestTask(context,
                           new ContextTask(_providerId,
                                           context.AssemblyLocation,
                                           context.GetTypeClrName().FullName));
 }
    public static ContextSpecificationElement GetOrCreateContextSpecification(MSpecUnitTestProvider provider,
                                                                              IProject project,
                                                                              ContextElement context,
                                                                              ProjectModelElementEnvoy projectEnvoy,
                                                                              string declaringTypeName,
                                                                              string fieldName,
                                                                              ICollection<string> tags,
                                                                              bool isIgnored)
    {
#if RESHARPER_6
      var id = ContextSpecificationElement.CreateId(context, fieldName);
      var contextSpecification = provider.UnitTestManager.GetElementById(project, id) as ContextSpecificationElement;
      if (contextSpecification != null)
      {
        contextSpecification.Parent = context;
        contextSpecification.State = UnitTestElementState.Valid;
        return contextSpecification;
      }
#endif

      return new ContextSpecificationElement(provider,
                                             context,
                                             projectEnvoy,
                                             declaringTypeName,
                                             fieldName,
                                             tags,
                                             isIgnored);
    }
Пример #5
0
 protected virtual void PresentContext(ContextElement element,
                                       IPresentableItem item,
                                       TreeModelNode modelNode,
                                       PresentationState state)
 {
     PresentItem(item, element, state, UnitTestElementImage.TestContainer);
 }
 public ContextSpecificationElement CreateContextSpecification(ContextElement context, IMetadataField specification)
 {
   return GetOrCreateContextSpecification(context,
                                          _reflectionTypeNameCache.GetClrName(specification.DeclaringType),
                                          specification.Name,
                                          specification.IsIgnored());
 }
Пример #7
0
 protected virtual void PresentContext(ContextElement element,
                                   IPresentableItem item,
                                   TreeModelNode modelNode,
                                   PresentationState state)
 {
     PresentItem(item, element, state, UnitTestElementImage.TestContainer);
 }
 public UnitTestTask CreateContextTask(ContextElement context, bool isExplicit)
 {
   return new UnitTestTask(context,
                           new ContextTask(_providerId,
                                           context.AssemblyLocation,
                                           context.GetTypeClrName(),
                                           false));
 }
 public UnitTestTask CreateContextSpecificationTask(ContextElement context,
                                                    ContextSpecificationElement contextSpecification)
 {
   return new UnitTestTask(contextSpecification,
                           new ContextSpecificationTask(_providerId,
                                                        context.AssemblyLocation,
                                                        context.GetTypeClrName().FullName,
                                                        contextSpecification.FieldName));
 }
 public ContextSpecificationElement CreateContextSpecification(ContextElement context, IMetadataField specification)
 {
   return new ContextSpecificationElement(_provider,
                                          context,
                                          _projectEnvoy,
                                          specification.DeclaringType.FullyQualifiedName,
                                          specification.Name,
                                          specification.IsIgnored());
 }
 public UnitTestTask CreateBehaviorTask(ContextElement context, BehaviorElement behavior, bool isExplicit)
 {
   return new UnitTestTask(behavior,
                           new BehaviorTask(_providerId,
                                            context.AssemblyLocation,
                                            context.GetTypeClrName(),
                                            behavior.FieldName,
                                            false));
 }
Пример #12
0
        public override bool Equals(object obj)
        {
            if (base.Equals(obj))
            {
                ContextElement other = (ContextElement)obj;
                return(Equals(AssemblyLocation, other.AssemblyLocation));
            }

            return(false);
        }
Пример #13
0
        public IList <UnitTestTask> GetTaskSequence(IEnumerable <IUnitTestElement> explicitElements)
#endif
        {
            if (this is ContextSpecificationElement)
            {
                var            contextSpecification = this as ContextSpecificationElement;
                ContextElement context = contextSpecification.Context;

                return(new List <UnitTestTask>
                {
                    _taskFactory.CreateAssemblyLoadTask(context),
                    _taskFactory.CreateContextTask(context, explicitElements.Contains(context)),
                    _taskFactory.CreateContextSpecificationTask(context,
                                                                contextSpecification,
                                                                explicitElements.Contains(contextSpecification))
                });
            }

            if (this is BehaviorElement)
            {
                var            behavior = this as BehaviorElement;
                ContextElement context  = behavior.Context;

                return(new List <UnitTestTask>
                {
                    _taskFactory.CreateAssemblyLoadTask(context),
                    _taskFactory.CreateContextTask(context, explicitElements.Contains(context)),
                    _taskFactory.CreateBehaviorTask(context, behavior, explicitElements.Contains(behavior))
                });
            }

            if (this is BehaviorSpecificationElement)
            {
                var             behaviorSpecification = this as BehaviorSpecificationElement;
                BehaviorElement behavior = behaviorSpecification.Behavior;
                ContextElement  context  = behavior.Context;

                return(new List <UnitTestTask>
                {
                    _taskFactory.CreateAssemblyLoadTask(context),
                    _taskFactory.CreateContextTask(context, explicitElements.Contains(context)),
                    _taskFactory.CreateBehaviorTask(context, behavior, explicitElements.Contains(behavior)),
                    _taskFactory.CreateBehaviorSpecificationTask(context,
                                                                 behaviorSpecification,
                                                                 explicitElements.Contains(behaviorSpecification))
                });
            }

            if (this is ContextElement)
            {
                return(EmptyArray <UnitTestTask> .Instance);
            }

            throw new ArgumentException(String.Format("Element is not a Machine.Specifications element: '{0}'", this));
        }
Пример #14
0
 public void AddContext(ITypeElement type, ContextElement context)
 {
   if (!_contexts.ContainsKey(type))
   {
     _contexts.Add(type, context);
   }
   else
   {
     _contexts[type] = context;
   }
 }
Пример #15
0
 public ContextSpecificationElement(IUnitTestProvider provider,
                                    // ReSharper disable SuggestBaseTypeForParameter
                                    ContextElement context,
                                    // ReSharper restore SuggestBaseTypeForParameter
                                    IProjectModelElement project,
                                    string declaringTypeName,
                                    string fieldName,
                                    bool isIgnored)
     : base(provider, context, project, declaringTypeName, fieldName, isIgnored || context.IsExplicit)
 {
 }
 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 ContextSpecificationElement(IUnitTestProvider provider,
                                    // ReSharper disable SuggestBaseTypeForParameter
                                    ContextElement context,
                                    // ReSharper restore SuggestBaseTypeForParameter
                                    IProjectModelElement project,
                                    string declaringTypeName,
                                    string fieldName,
                                    bool isIgnored)
   : base(provider, context, project, declaringTypeName, fieldName, isIgnored || context.IsExplicit)
 {
 }
 public BehaviorElement(IUnitTestProvider provider,
                        // ReSharper disable SuggestBaseTypeForParameter
                        ContextElement context,
                        // ReSharper restore SuggestBaseTypeForParameter
                        ProjectModelElementEnvoy projectEnvoy,
                        string declaringTypeName,
                        string fieldName,
                        bool isIgnored)
   : base(provider, context, projectEnvoy, declaringTypeName, fieldName, isIgnored || context.IsExplicit)
 {
 }
    public BehaviorElement CreateBehavior(ContextElement context, IMetadataField behavior)
    {
      IMetadataTypeInfo typeContainingBehaviorSpecifications = behavior.GetFirstGenericArgument();

      return new BehaviorElement(_provider,
                                 context,
                                 _projectEnvoy,
                                 behavior.DeclaringType.FullyQualifiedName,
                                 behavior.Name,
                                 behavior.IsIgnored() || typeContainingBehaviorSpecifications.IsIgnored());
    }
Пример #20
0
 public BehaviorElement(IUnitTestProvider provider,
                        // ReSharper disable SuggestBaseTypeForParameter
                        ContextElement context,
                        // ReSharper restore SuggestBaseTypeForParameter
                        ProjectModelElementEnvoy projectEnvoy,
                        string declaringTypeName,
                        string fieldName,
                        bool isIgnored,
                        string fullyQualifiedTypeName)
     : base(provider, context, projectEnvoy, declaringTypeName, fieldName, isIgnored || context.IsExplicit)
 {
     FullyQualifiedTypeName = fullyQualifiedTypeName;
 }
 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 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(new ClrTypeName(metadataTypeName));

      var behaviorElement = GetOrCreateBehavior(context,
                                                _reflectionTypeNameCache.GetClrName(behavior.DeclaringType),
                                                behavior.Name,
                                                behavior.IsIgnored() || typeContainingBehaviorSpecifications.IsIgnored(),
                                                fieldType);

      return behaviorElement;
    }
 public BehaviorElement(MSpecUnitTestProvider provider,
                        PsiModuleManager psiModuleManager,
                        CacheManager cacheManager,
   // ReSharper disable SuggestBaseTypeForParameter
                        ContextElement context,
   // ReSharper restore SuggestBaseTypeForParameter
                        ProjectModelElementEnvoy projectEnvoy,
                        string declaringTypeName,
                        string fieldName,
                        bool isIgnored,
                        string fullyQualifiedTypeName)
   : base(provider, psiModuleManager, cacheManager, context, projectEnvoy, declaringTypeName, fieldName, isIgnored || context.Explicit)
 {
   FullyQualifiedTypeName = fullyQualifiedTypeName;
 }
 public ContextSpecificationElement(IUnitTestProvider provider,
                                    // ReSharper disable SuggestBaseTypeForParameter
                                    ContextElement context,
                                    // ReSharper restore SuggestBaseTypeForParameter
                                    ProjectModelElementEnvoy project,
                                    string declaringTypeName,
                                    string fieldName,
                                    ICollection <string> tags,
                                    bool isIgnored)
     : base(provider, context, project, declaringTypeName, fieldName, isIgnored || context.IsExplicit)
 {
     if (tags != null)
     {
         AssignCategories(tags);
     }
 }
 public ContextSpecificationElement(IUnitTestProvider provider,
                                    // ReSharper disable SuggestBaseTypeForParameter
                                    ContextElement context,
                                    // ReSharper restore SuggestBaseTypeForParameter
                                    ProjectModelElementEnvoy project,
                                    string declaringTypeName,
                                    string fieldName,
                                    ICollection<string> tags,
                                    bool isIgnored)
   : base(provider, context, project, declaringTypeName, fieldName, isIgnored || context.IsExplicit)
 {
     if (tags != null)
     {
         AssignCategories(tags);
     }
 }
    public ContextElement CreateContext(ITypeElement type)
    {
      if (_cache.Classes.ContainsKey(type))
      {
        return _cache.Classes[type];
      }

      ContextElement context = new ContextElement(_provider,
                                                  _project,
                                                  type.CLRName,
                                                  _assemblyPath,
                                                  type.GetTags(),
                                                  type.IsIgnored());
      _cache.Classes.Add(type, context);
      return context;
    }
 public ContextSpecificationElement(MSpecUnitTestProvider provider,
   // ReSharper disable SuggestBaseTypeForParameter
                                    ContextElement context,
   // ReSharper restore SuggestBaseTypeForParameter
                                    ProjectModelElementEnvoy project,
                                    string declaringTypeName,
                                    string fieldName,
                                    IEnumerable<string> tags,
                                    bool isIgnored)
   : base(provider, context, project, declaringTypeName, fieldName, isIgnored || context.Explicit)
 {
   if (tags != null)
   {
     _categories = UnitTestElementCategory.Create(tags);
   }
 }
 public BehaviorElement(MSpecUnitTestProvider provider,
                        PsiModuleManager psiModuleManager,
                        CacheManager cacheManager,
                        // ReSharper disable SuggestBaseTypeForParameter
                        ContextElement context,
                        // ReSharper restore SuggestBaseTypeForParameter
                        ProjectModelElementEnvoy projectEnvoy,
                        string declaringTypeName,
                        string fieldName,
                        bool isIgnored,
                        string fullyQualifiedTypeName)
     : base(provider, psiModuleManager, cacheManager, context, projectEnvoy, declaringTypeName, fieldName, isIgnored || context.Explicit)
 {
     _id = CreateId(context, fieldName);
     FullyQualifiedTypeName = fullyQualifiedTypeName;
 }
    public ContextSpecificationElement CreateContextSpecification(ContextElement context, IMetadataField specification)
    {
      return GetOrCreateContextSpecification(_provider,
#if RESHARPER_61
                                             _manager, _psiModuleManager, _cacheManager, 
#endif
                                             _project,
                                             context,
                                             _projectEnvoy,
#if RESHARPER_61
                                             _reflectionTypeNameCache.GetClrName(specification.DeclaringType),
#else
                                             new ClrTypeName(specification.DeclaringType.FullyQualifiedName), // may work incorrect in ReSharper 6.0
#endif
                                             specification.Name,
                                             specification.DeclaringType.GetTags(),
                                             specification.IsIgnored());
    }
Пример #31
0
 public ContextSpecificationElement(MSpecUnitTestProvider provider,
                                    PsiModuleManager psiModuleManager,
                                    CacheManager cacheManager,
                                    // ReSharper disable SuggestBaseTypeForParameter
                                    ContextElement context,
                                    // ReSharper restore SuggestBaseTypeForParameter
                                    ProjectModelElementEnvoy project,
                                    string declaringTypeName,
                                    string fieldName,
                                    IEnumerable <string> tags,
                                    bool isIgnored)
     : base(provider, psiModuleManager, cacheManager, context, project, declaringTypeName, fieldName, isIgnored || context.Explicit)
 {
     if (tags != null)
     {
         _categories = UnitTestElementCategory.Create(tags);
     }
 }
 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)
 {
     _id = CreateId(context, fieldName);
 }
 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)
 {
   _id = CreateId(context, fieldName);
 }
    public ContextElement CreateContext(ITypeElement type)
    {
      if (_cache.Classes.ContainsKey(type))
      {
        return _cache.Classes[type];
      }

      ContextElement context = new ContextElement(_provider,
                                                  _projectEnvoy,
#if RESHARPER_6
                                                  type.GetClrName().FullName,
#else
                                                  type.CLRName,
#endif
                                                  _assemblyPath,
                                                  type.GetSubjectString(),
                                                  type.GetTags(),
                                                  type.IsIgnored());
      _cache.Classes.Add(type, context);
      return context;
    }
Пример #35
0
 public ContextSpecificationElement(MSpecUnitTestProvider provider,
                                    PsiModuleManager psiModuleManager,
                                    CacheManager cacheManager,
                                    // ReSharper disable SuggestBaseTypeForParameter
                                    ContextElement context,
                                    // ReSharper restore SuggestBaseTypeForParameter
                                    ProjectModelElementEnvoy project,
                                    IClrTypeName declaringTypeName,
                                    string fieldName,
                                    bool isIgnored)
     : base(
         provider,
         psiModuleManager,
         cacheManager,
         context,
         project,
         declaringTypeName,
         fieldName,
         isIgnored || context.Explicit)
 {
     _id = CreateId(context, fieldName);
 }
    public ContextSpecificationElement GetOrCreateContextSpecification(ContextElement context,
                                                                       IClrTypeName declaringTypeName,
                                                                       string fieldName,
                                                                       bool isIgnored)
    {
      var id = ContextSpecificationElement.CreateId(context, fieldName);
      var contextSpecification = _manager.GetElementById(context.GetProject(), id) as ContextSpecificationElement;
      if (contextSpecification != null)
      {
        contextSpecification.Parent = context;
        contextSpecification.State = UnitTestElementState.Valid;
        return contextSpecification;
      }

      return new ContextSpecificationElement(_provider,
                                             _psiModuleManager,
                                             _cacheManager,
                                             new ProjectModelElementEnvoy(context.GetProject()),
                                             context,
                                             declaringTypeName,
                                             fieldName, isIgnored);
    }
    public BehaviorElement CreateBehavior(ContextElement context, IMetadataField behavior)
    {
      var typeContainingBehaviorSpecifications = behavior.GetFirstGenericArgument();

      var fullyQualifiedTypeName = behavior.FirstGenericArgumentClass().FullyQualifiedName();
      var typeName = GetNormalizedTypeName(fullyQualifiedTypeName);

      var behaviorElement = new BehaviorElement(_provider,
                                 context,
                                 _projectEnvoy,
                                 behavior.DeclaringType.FullyQualifiedName,
                                 behavior.Name,
                                 behavior.IsIgnored() || typeContainingBehaviorSpecifications.IsIgnored(),
                                 fullyQualifiedTypeName);

      if (!TypeNameCache.ContainsKey(typeName))
      {
        TypeNameCache.Add(typeName, fullyQualifiedTypeName);
      }

      return behaviorElement;
    }
 public ContextSpecificationElement(MSpecUnitTestProvider provider,
                                    PsiModuleManager psiModuleManager,
                                    CacheManager cacheManager,
                                    // ReSharper disable SuggestBaseTypeForParameter
                                    ContextElement context,
                                    // ReSharper restore SuggestBaseTypeForParameter
                                    ProjectModelElementEnvoy project,
                                    IClrTypeName declaringTypeName,
                                    string fieldName,
                                    bool isIgnored)
   : base(
     provider,
     psiModuleManager,
     cacheManager,
     context,
     project,
     declaringTypeName,
     fieldName,
     isIgnored || context.Explicit)
 {
   _id = CreateId(context, fieldName);
 }
 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)
 {
   FieldType = fieldType;
   _id = CreateId(context, fieldType, fieldName);
 }
 public UnitTestTask CreateRunAssemblyTask(ContextElement context)
 {
   return new UnitTestTask(null,
                           new RunAssemblyTask(_providerId, context.AssemblyLocation));
 }
Пример #41
0
 public static string CreateId(ContextElement contextElement, string fieldName)
 {
     return(String.Format("{0}.{1}", contextElement.Id, fieldName));
 }
    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 static string CreateId(ContextElement contextElement, string fieldType, string fieldName)
        {
            var result = new[] { contextElement.Id, fieldType, fieldName };

            return(result.Where(s => !string.IsNullOrEmpty(s)).AggregateString("."));
        }