示例#1
0
 protected virtual void PresentBehavior(BehaviorElement element,
                                    IPresentableItem item,
                                    TreeModelNode modelNode,
                                    PresentationState state)
 {
     PresentItem(item, element, state, UnitTestElementImage.TestContainer);
 }
 protected virtual void PresentBehavior(BehaviorElement element,
                                        IPresentableItem item,
                                        TreeModelNode modelNode,
                                        PresentationState state)
 {
     PresentItem(item, element, state, UnitTestElementImage.TestContainer);
 }
示例#3
0
        public static string CreateId(BehaviorElement parent, string fieldName)
        {
            var id = String.Format("{0}.{1}", parent.Id, fieldName);

            System.Diagnostics.Debug.WriteLine("BSE " + id);
            return(id);
        }
 BehaviorSpecificationElement CreateBehaviorSpecification(BehaviorElement behavior,
                                                          IMetadataField behaviorSpecification)
 {
   return GetOrCreateBehaviorSpecification(behavior,
                                           _reflectionTypeNameCache.GetClrName(behaviorSpecification.DeclaringType),
                                           behaviorSpecification.Name,
                                           behaviorSpecification.IsIgnored());
 }
 public UnitTestTask CreateBehaviorTask(ContextElement context, BehaviorElement behavior, bool isExplicit)
 {
   return new UnitTestTask(behavior,
                           new BehaviorTask(_providerId,
                                            context.AssemblyLocation,
                                            context.GetTypeClrName(),
                                            behavior.FieldName,
                                            false));
 }
 BehaviorSpecificationElement CreateBehaviorSpecification(BehaviorElement behavior,
                                                          IDeclaredElement behaviorSpecification)
 {
   return new BehaviorSpecificationElement(_provider,
                                           behavior,
                                           _projectEnvoy,
                                           behaviorSpecification.GetContainingType().CLRName,
                                           behaviorSpecification.ShortName,
                                           behaviorSpecification.IsIgnored());
 }
 internal BehaviorSpecificationElement CreateBehaviorSpecification(BehaviorElement behavior,
                                                                   IDeclaredElement behaviorSpecification)
 {
   return GetOrCreateBehaviorSpecification(behavior,
                                           ((ITypeMember) behaviorSpecification).GetContainingType()
                                                                                .GetClrName()
                                                                                .GetPersistent(),
                                           behaviorSpecification.ShortName,
                                           behaviorSpecification.IsIgnored());
 }
    public IEnumerable<BehaviorSpecificationElement> CreateBehaviorSpecificationsFromBehavior(BehaviorElement behavior,
                                                                                              IDeclaredElement behaviorSpecification)
    {
      IClass typeContainingBehaviorSpecifications = behaviorSpecification.GetFirstGenericArgument();

      foreach (IField specification in typeContainingBehaviorSpecifications.GetBehaviorSpecifications())
      {
        yield return CreateBehaviorSpecification(behavior, specification);
      }
    }
 BehaviorSpecificationElement CreateBehaviorSpecification(BehaviorElement behavior,
                                                          IMetadataField behaviorSpecification)
 {
   return new BehaviorSpecificationElement(_provider,
                                           behavior,
                                           _projectEnvoy,
                                           behaviorSpecification.DeclaringType.FullyQualifiedName,
                                           behaviorSpecification.Name,
                                           behaviorSpecification.IsIgnored());
 }
示例#10
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));
        }
 public void AddBehavior(IDeclaredElement type, BehaviorElement behavior)
 {
   if (!_behaviors.ContainsKey(type))
   {
     _behaviors.Add(type, behavior);
   }
   else
   {
     _behaviors[type] = behavior;
   }
 }
 public BehaviorSpecificationElement(MSpecUnitTestProvider provider,
   // ReSharper disable SuggestBaseTypeForParameter
                                     BehaviorElement behavior,
   // ReSharper restore SuggestBaseTypeForParameter
                                     ProjectModelElementEnvoy projectEnvoy,
                                     string declaringTypeName,
                                     string fieldName,
                                     bool isIgnored)
   : base(provider, behavior, projectEnvoy, declaringTypeName, fieldName, isIgnored || behavior.Explicit)
 {
 }
 public BehaviorSpecificationElement(IUnitTestProvider provider,
                                     // ReSharper disable SuggestBaseTypeForParameter
                                     BehaviorElement behavior,
                                     // ReSharper restore SuggestBaseTypeForParameter
                                     ProjectModelElementEnvoy projectEnvoy,
                                     string declaringTypeName,
                                     string fieldName,
                                     bool isIgnored)
     : base(provider, behavior, projectEnvoy, declaringTypeName, fieldName, isIgnored || behavior.IsExplicit)
 {
 }
    public IEnumerable<BehaviorSpecificationElement> CreateBehaviorSpecificationsFromBehavior(
      BehaviorElement behavior,
      IMetadataField behaviorSpecification)
    {
      IMetadataTypeInfo typeContainingBehaviorSpecifications = behaviorSpecification.GetFirstGenericArgument();

      foreach (var specification in typeContainingBehaviorSpecifications.GetSpecifications())
      {
        yield return CreateBehaviorSpecification(behavior, specification);
      }
    }
    BehaviorSpecificationElement CreateBehaviorSpecification(BehaviorElement behavior,
                                                             IMetadataField behaviorSpecification)
    {
      return GetOrCreateBehaviorSpecification(_provider,
#if RESHARPER_61
                                              _manager, _psiModuleManager, _cacheManager, 
#endif
                                              _project,
                                              behavior,
                                              _projectEnvoy,
                                              behavior.FullyQualifiedTypeName ?? behaviorSpecification.DeclaringType.FullyQualifiedName,
                                              behaviorSpecification.Name,
                                              behaviorSpecification.IsIgnored());
    }
 public BehaviorSpecificationElement(MSpecUnitTestProvider provider,
                                     PsiModuleManager psiModuleManager,
                                     CacheManager cacheManager,
   // ReSharper disable SuggestBaseTypeForParameter
                                     BehaviorElement behavior,
   // ReSharper restore SuggestBaseTypeForParameter
                                     ProjectModelElementEnvoy projectEnvoy,
                                     IClrTypeName declaringTypeName,
                                     string fieldName,
                                     bool isIgnored)
   : base(provider, psiModuleManager, cacheManager, behavior, projectEnvoy, declaringTypeName, fieldName, isIgnored || behavior.Explicit)
 {
   _id = CreateId(behavior, fieldName);
 }
    BehaviorSpecificationElement CreateBehaviorSpecification(BehaviorElement behavior,
                                                             IDeclaredElement behaviorSpecification)
    {
      return new BehaviorSpecificationElement(_provider,
                                              behavior,
                                              _projectEnvoy,
#if RESHARPER_6
                                              behavior.FullyQualifiedTypeName ?? ((ITypeMember)behaviorSpecification).GetContainingType().GetClrName().FullName,
#else
                                              behavior.FullyQualifiedTypeName ?? behaviorSpecification.GetContainingType().CLRName,
#endif
 behaviorSpecification.ShortName,
                                              behaviorSpecification.IsIgnored());
    }
    BehaviorSpecificationElement CreateBehaviorSpecification(BehaviorElement behavior,
                                                             IDeclaredElement behaviorSpecification)
    {
      return GetOrCreateBehaviorSpecification(_provider,
#if RESHARPER_61
                                              _manager, _psiModuleManager, _cacheManager, 
#endif
                                              _project,
                                              behavior,
                                              _projectEnvoy,
                                              ((ITypeMember)behaviorSpecification).GetContainingType().GetClrName().GetPersistent(),
 behaviorSpecification.ShortName,
                                              behaviorSpecification.IsIgnored());
    }
 public BehaviorSpecificationElement(MSpecUnitTestProvider provider,
                                     PsiModuleManager psiModuleManager,
                                     CacheManager cacheManager,
                                     // ReSharper disable SuggestBaseTypeForParameter
                                     BehaviorElement behavior,
                                     // ReSharper restore SuggestBaseTypeForParameter
                                     ProjectModelElementEnvoy projectEnvoy,
                                     string declaringTypeName,
                                     string fieldName,
                                     bool isIgnored)
     : base(provider, psiModuleManager, cacheManager, behavior, projectEnvoy, declaringTypeName, fieldName, isIgnored || behavior.Explicit)
 {
     _id = CreateId(behavior, fieldName);
 }
 BehaviorSpecificationElement CreateBehaviorSpecification(BehaviorElement behavior,
                                                          IMetadataField behaviorSpecification)
 {
   return GetOrCreateBehaviorSpecification(_provider,
                                           _manager,
                                           _psiModuleManager,
                                           _cacheManager,
                                           _project,
                                           behavior,
                                           _projectEnvoy,
                                           _reflectionTypeNameCache.GetClrName(behaviorSpecification.DeclaringType),
                                           behaviorSpecification.Name,
                                           behaviorSpecification.IsIgnored());
 }
    BehaviorSpecificationElement CreateBehaviorSpecification(BehaviorElement behavior,
                                                             IMetadataField behaviorSpecification)
    {
      return GetOrCreateBehaviorSpecification(_provider,
#if RESHARPER_61
                                              _manager, _psiModuleManager, _cacheManager, 
#endif
                                              _project,
                                              behavior,
                                              _projectEnvoy,
#if RESHARPER_61
                                              _reflectionTypeNameCache.GetClrName(behaviorSpecification.DeclaringType),
#else
                                              new ClrTypeName(behaviorSpecification.DeclaringType.FullyQualifiedName), // may work incorrect in ReSharper 6.0
#endif
                                              behaviorSpecification.Name,
                                              behaviorSpecification.IsIgnored());
    }
    public static BehaviorSpecificationElement GetOrCreateBehaviorSpecification(MSpecUnitTestProvider provider, IProject project, BehaviorElement behavior, ProjectModelElementEnvoy projectEnvoy, string declaringTypeName, string fieldName, bool isIgnored)
    {
#if RESHARPER_6
      var id = BehaviorSpecificationElement.CreateId(behavior, fieldName);
      var behaviorSpecification = provider.UnitTestManager.GetElementById(project, id) as BehaviorSpecificationElement;
      if (behaviorSpecification != null)
      {
        behaviorSpecification.Parent = behavior;
        behaviorSpecification.State = UnitTestElementState.Valid;
        return behaviorSpecification;
      }
#endif

      return new BehaviorSpecificationElement(provider,
                                              behavior,
                                              projectEnvoy,
                                              declaringTypeName,
                                              fieldName,
                                              isIgnored);
    }
 public BehaviorSpecificationElement(MSpecUnitTestProvider provider,
                                     IPsi psiModuleManager,
                                     ICache cacheManager,
                                     ProjectModelElementEnvoy projectEnvoy,
                                     BehaviorElement behavior,
                                     IClrTypeName declaringTypeName,
                                     string fieldName,
                                     bool isIgnored
   )
   : base(provider,
          psiModuleManager,
          cacheManager,
          behavior,
          projectEnvoy,
          declaringTypeName,
          fieldName,
          isIgnored || behavior.Explicit)
 {
   _id = CreateId(behavior, fieldName);
 }
示例#24
0
 public BehaviorSpecificationElement(MSpecUnitTestProvider provider,
                                     IPsi psiModuleManager,
                                     ICache cacheManager,
                                     ProjectModelElementEnvoy projectEnvoy,
                                     BehaviorElement behavior,
                                     IClrTypeName declaringTypeName,
                                     string fieldName,
                                     bool isIgnored
                                     )
     : base(provider,
            psiModuleManager,
            cacheManager,
            behavior,
            projectEnvoy,
            declaringTypeName,
            fieldName,
            isIgnored || behavior.Explicit)
 {
     _id = CreateId(behavior, fieldName);
 }
    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 BehaviorSpecificationElement GetOrCreateBehaviorSpecification(BehaviorElement behavior,
                                                                         IClrTypeName declaringTypeName,
                                                                         string fieldName,
                                                                         bool isIgnored)
    {
      var id = BehaviorSpecificationElement.CreateId(behavior, fieldName);
      var behaviorSpecification = _manager.GetElementById(behavior.GetProject(), id) as BehaviorSpecificationElement;
      if (behaviorSpecification != null)
      {
        behaviorSpecification.Parent = behavior;
        behaviorSpecification.State = UnitTestElementState.Valid;
        return behaviorSpecification;
      }

      return new BehaviorSpecificationElement(_provider,
                                              _psiModuleManager,
                                              _cacheManager,
                                              new ProjectModelElementEnvoy(behavior.GetProject()),
                                              behavior,
                                              declaringTypeName,
                                              fieldName,
                                              isIgnored);
    }
    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 static string CreateId(BehaviorElement behaviorElement, string fieldName)
 {
   return String.Format("{0}.{1}", behaviorElement.Id, fieldName);
 }
 public static string CreateId(BehaviorElement behaviorElement, string fieldName)
 {
   var result = new[] {behaviorElement.Id, fieldName};
   return result.Where(s => !string.IsNullOrEmpty(s)).AggregateString(".");
 }
    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.Id, 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 static string CreateId(BehaviorElement parent, string fieldName)
 {
   var id = String.Format("{0}.{1}", parent.Id, fieldName);
   System.Diagnostics.Debug.WriteLine("BSE " + id);
   return id;
 }
示例#32
0
        public static string CreateId(BehaviorElement behaviorElement, string fieldName)
        {
            var result = new[] { behaviorElement.Id, fieldName };

            return(result.Where(s => !string.IsNullOrEmpty(s)).AggregateString("."));
        }
示例#33
0
 public static string CreateId(BehaviorElement behaviorElement, string fieldName)
 {
     return(String.Format("{0}.{1}", behaviorElement.Id, fieldName));
 }