public AddRequiresExecutor(ICSharpContextActionDataProvider provider, bool shouldBeGeneric,
     ICSharpFunctionDeclaration functionDeclaration, string parameterName, IClrTypeName propertyType)
     : this(provider, shouldBeGeneric, new []{functionDeclaration}, parameterName, propertyType)
 {
     Contract.Requires(provider != null);
     _provider = provider;
 }
        public ContextElement GetOrCreateContext(string assemblyPath,
                                                 IProject project,
                                                 IClrTypeName typeName,
                                                 string subject,
                                                 ICollection<string> tags,
                                                 bool isIgnored)
        {
            var id = ContextElement.CreateId(_elementIdFactory, _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,
                                      id,
                                      new ProjectModelElementEnvoy(project),
                                      typeName,
                                      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;
        }
        protected Element(MSpecUnitTestProvider provider,
                          IPsi psiModuleManager,
                          ICache cacheManager,
                          Element parent,
                          ProjectModelElementEnvoy projectEnvoy,
                          IClrTypeName declaringTypeName,
                          bool isIgnored)
        {
            if (declaringTypeName == null)
            {
                throw new ArgumentNullException("declaringTypeName");
            }

            if (projectEnvoy != null)
            {
                this._projectEnvoy = projectEnvoy;
            }

            this._provider = provider;
            this._declaringTypeName = declaringTypeName;
            this._psiModuleManager = psiModuleManager;
            this._cacheManager = cacheManager;

            if (isIgnored)
            {
                this.ExplicitReason = "Ignored";
            }

            this.TypeName = declaringTypeName;
            this.Parent = parent;

            this.Children = new List<IUnitTestElement>();
            this.State = UnitTestElementState.Valid;
            this._taskFactory = new UnitTestTaskFactory(this._provider.ID);
        }
    public ContextElement GetOrCreateContext(string assemblyPath,
                                             IProject project,
                                             IClrTypeName typeName,
                                             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,
                                new ProjectModelElementEnvoy(project),
                                typeName,
                                assemblyPath,
                                subject,
                                tags,
                                isIgnored);
    }
Exemplo n.º 6
0
 public UnityType(IClrTypeName typeName, IEnumerable<UnityEventFunction> eventFunctions, Version minimumVersion, Version maximumVersion)
 {
     myTypeName = typeName;
     myMinimumVersion = minimumVersion;
     myMaximumVersion = maximumVersion;
     myEventFunctions = eventFunctions;
 }
        public static List<OverridableMemberInstance> GetMissingMembersOf(
            this IClassLikeDeclaration declaration,
            IClrTypeName baseClassName)
        {
            Contract.Requires(declaration != null);
            Contract.Requires(declaration.DeclaredElement != null);
            Contract.Requires(baseClassName != null);
            Contract.Requires(baseClassName.FullName != null);
            

            Contract.Ensures(Contract.Result<List<OverridableMemberInstance>>() != null);

            var potentialOverrides =
                GenerateUtil.GetOverridableMembersOrder(declaration.DeclaredElement, false)
                    .Where(e => e.DeclaringType.GetClrName().FullName ==
                            baseClassName.FullName)
                    // This code provides two elements for property! So I'm trying to remove another instance!
                    .Where(x => !x.Member.ShortName.StartsWith("get_"))
                    .Where(x => !x.Member.ShortName.StartsWith("set_"))
                    .ToList();

            var alreadyOverriden = new HashSet<OverridableMemberInstance>(
                declaration.GetOverridenMembers());

            var notOverridenMembers = new List<OverridableMemberInstance>();
            foreach (var member in potentialOverrides)
            {
                if (!alreadyOverriden.Contains(member))
                    notOverridenMembers.Add(member);
            }

            return notOverridenMembers;

        }
        protected Element(MSpecUnitTestProvider provider,
                          Element parent,
                          IClrTypeName declaringTypeName,
                          UnitTestingCachingService cachingService,
                          IUnitTestElementManager elementManager,
                          bool isIgnored)
        {
            if (declaringTypeName == null)
            {
                throw new ArgumentNullException("declaringTypeName");
            }

            this._provider          = provider;
            this._declaringTypeName = declaringTypeName;
            this._cachingService    = cachingService;
            this._elementManager    = elementManager;

            if (isIgnored)
            {
                this.ExplicitReason = "Ignored";
            }

            this.Parent = parent;

            this.Children     = new BindableCollection <IUnitTestElement>(UT.Locks.ReadLock);
            this._taskFactory = new UnitTestTaskFactory(this._provider.ID);
        }
        public XunitTestClassElement GetOrCreateTestClass(IProject project, IClrTypeName typeName,
                                                          string assemblyLocation,
                                                          OneToSetMap <string, string> traits)
        {
            var id = typeName.FullName;

            return(GetOrCreateTestClass(id, project, typeName, assemblyLocation, traits));
        }
 public AnnotationAttributeInstance(IClrTypeName clrTypeName, IPsiModule externalAnnotationsModule,
                                    IProject project, AttributeValue[] ctorArguments)
 {
     myClrTypeName = clrTypeName;
     myExternalAnnotationsModule = externalAnnotationsModule;
     myProject       = project;
     myCtorArguments = ctorArguments;
 }
 public XunitTestFakeElement(IUnitTestProvider provider, IProject project, IClrTypeName typeName, string methodName)
 {
     Provider = provider;
     myProject = project;
     TypeName = typeName;
     myMethodName = methodName;
     State = UnitTestElementState.Fake;
 }
        protected ITypeElement CreateDeclaredType(IClrTypeName clrTypeName)
        {
            Contract.Requires(clrTypeName != null);
            Contract.Ensures(Contract.Result<ITypeElement>() != null);

            return new DeclaredTypeFromCLRName(clrTypeName, _psiModule, _currentFile.GetResolveContext())
                .GetTypeElement();
        }
Exemplo n.º 13
0
        private bool MethodSupportsRequires(out string parameterName, out IClrTypeName parameterType,
                                            out ReadOnlyCollection <ICSharpFunctionDeclaration> functionsToInsertPrecondition)
        {
            functionsToInsertPrecondition = null;

            return(ParameterSupportRequires(out parameterName, out parameterType) &&
                   FunctionSupportRequiers(parameterName, out functionsToInsertPrecondition));
        }
Exemplo n.º 14
0
        private static string GetDisplayName(IClrTypeName typeName, string?subject)
        {
            var display = typeName.ShortName.ToFormat();

            return(string.IsNullOrEmpty(subject)
                ? display
                : $"{subject}, {display}");
        }
 private static ITypeElement GetTypeElement(IClrTypeName typeName, IPsiModule module)
 {
     using (CompilationContextCookie.GetExplicitUniversalContextIfNotSet())
     {
         var type = TypeFactory.CreateTypeByCLRName(typeName, module);
         return(type.GetTypeElement());
     }
 }
 private static ITypeElement GetTypeElement(IClrTypeName typeName, KnownTypesCache knownTypesCache,
                                            IPsiModule module)
 {
     using (CompilationContextCookie.GetExplicitUniversalContextIfNotSet())
     {
         var type = knownTypesCache.GetByClrTypeName(typeName, module);
         return(type.GetTypeElement());
     }
 }
Exemplo n.º 17
0
 public UnityTestElement([NotNull] IProject project, [NotNull] IClrTypeName clrTypeName, UnitTestElementId id, UnityNUnitServiceProvider unityNUnitServiceProvider, string methodName)
 {
     myUnitTestingCachingService = unityNUnitServiceProvider.CachingService;
     myProject     = project;
     myClrTypeName = clrTypeName;
     myId          = id;
     myUnityNUnitServiceProvider = unityNUnitServiceProvider;
     myMethodName = methodName;
 }
 public UnityEventFunctionParameter([NotNull] string name, [NotNull] IClrTypeName clrTypeName, [CanBeNull] string description, bool isArray, bool isOptional, string justification)
 {
     Name          = name;
     ClrTypeName   = clrTypeName;
     Description   = description;
     IsArray       = isArray;
     IsOptional    = isOptional;
     Justification = justification;
 }
 internal MethodRunnerElement(IProject project, IClrTypeName className, string methodName, bool isClassStatic, bool isMethodStatic, MethodRunnerProvider provider)
 {
     myProjectEnvoy = ProjectModelElementEnvoy.Create(project);
       myClassName = className;
       myMethodName = methodName;
       myIsClassStatic = isClassStatic;
       myIsMethodStatic = isMethodStatic;
       myProvider = provider;
 }
        private IfThrowPrecondition(IIfStatement ifStatement, 
            PredicateExpression predicateExpression, Message message, IClrTypeName exceptionTypeName)
            : base(ifStatement, predicateExpression, message)
        {
            Contract.Requires(ifStatement != null);
            Contract.Requires(exceptionTypeName != null);

            _ifStatement = ifStatement;
            _exceptionTypeName = exceptionTypeName;
        }
        public static bool DerivesFrom(this IDeclaredElement candidate, IClrTypeName baseTypeName)
        {
            if (!(candidate is ITypeElement element))
            {
                return(false);
            }
            var baseType = GetTypeElement(baseTypeName, element.Module);

            return(element.IsDescendantOf(baseType));
        }
 public ContextElement(
     UnitTestElementId id,
     IClrTypeName typeName,
     MspecServiceProvider serviceProvider,
     string subject,
     bool isIgnored)
     : base(id, null, typeName, serviceProvider, isIgnored)
 {
     _subject = subject;
 }
Exemplo n.º 23
0
        public static bool IsDescendantOf([NotNull] IClrTypeName unityTypeClrName, [CanBeNull] ITypeElement type)
        {
            if (type == null)
            {
                return(false);
            }
            var mb = TypeFactory.CreateTypeByCLRName(unityTypeClrName, type.Module);

            return(type.IsDescendantOf(mb.GetTypeElement()));
        }
 public XunitInheritedTestMethodContainerElement(IUnitTestProvider provider, ProjectModelElementEnvoy projectModelElementEnvoy,
                                                 string id, IClrTypeName typeName, string methodName)
     : base(provider, null, id, projectModelElementEnvoy, new JetHashSet <string>())
 {
     TypeName        = typeName;
     this.methodName = methodName;
     ShortName       = methodName;
     SetState(UnitTestElementState.Fake);
     ExplicitReason = null;
 }
        public IDeclaredElement GetDeclaredElement(IProject project, IClrTypeName typeName)
        {
            var modules = psiServices.Modules;
            var psiModule = modules.GetPrimaryPsiModule(project);
            if (psiModule == null)
                return null;

            var symbolScope = psiServices.Symbols.GetSymbolScope(psiModule, project.GetResolveContext(), true, true);
            return symbolScope.GetTypeElementByCLRName(typeName);
        }
Exemplo n.º 26
0
        public static void RemoveAttributeFromSingleDeclaration([CanBeNull] IFieldDeclaration fieldDeclaration,
                                                                IClrTypeName attributeTypeName)
        {
            var attribute = GetAttribute(fieldDeclaration, attributeTypeName);

            if (attribute != null)
            {
                fieldDeclaration.RemoveAttribute(attribute);
            }
        }
Exemplo n.º 27
0
 public XunitInheritedTestMethodContainerElement(IUnitTestProvider provider, ProjectModelElementEnvoy projectModelElementEnvoy,
                                                 string id, IClrTypeName typeName, string methodName)
     : base(provider, null, id, projectModelElementEnvoy, EmptyArray <UnitTestElementCategory> .Instance)
 {
     TypeName        = typeName;
     this.methodName = methodName;
     ShortName       = methodName;
     SetState(UnitTestElementState.Fake);
     ExplicitReason = null;
 }
Exemplo n.º 28
0
        public static void RemoveAttributeFromAllDeclarations([CanBeNull] IFieldDeclaration fieldDeclaration,
                                                              IClrTypeName attributeTypeName)
        {
            var attribute = GetAttribute(fieldDeclaration, attributeTypeName);

            if (attribute != null)
            {
                CSharpSharedImplUtil.RemoveAttribute(fieldDeclaration, attribute);
            }
        }
Exemplo n.º 29
0
 public BehaviorSpecificationElement(
     UnitTestElementId id,
     IUnitTestElement parent,
     IClrTypeName typeName,
     MspecServiceProvider serviceProvider,
     string fieldName,
     bool isIgnored)
     : base(id, parent, typeName, serviceProvider, fieldName, isIgnored || parent.Explicit)
 {
 }
        private IfThrowPrecondition(IIfStatement ifStatement,
                                    PredicateExpression predicateExpression, Message message, IClrTypeName exceptionTypeName)
            : base(ifStatement, predicateExpression, message)
        {
            Contract.Requires(ifStatement != null);
            Contract.Requires(exceptionTypeName != null);

            _ifStatement       = ifStatement;
            _exceptionTypeName = exceptionTypeName;
        }
        private void ProcessTestClass(IClrTypeName typeName, IEnumerable<IMethodInfo> methods, XunitTestClassElement parent)
        {
            XunitTestClassElement classElement = factory.GetOrCreateClassElement(typeName, project, envoy, parent);
            consumer(classElement);

            foreach (IMethodInfo method in methods)
            {
                ProcessTestMethod(classElement, method);
            }
        }
Exemplo n.º 32
0
        public XunitInheritedTestMethodContainerElement(XunitServiceProvider services, UnitTestElementId id,
                                                        IClrTypeName typeName, string methodName)
            : base(services, id, typeName)
        {
            this.methodName = methodName;
            ShortName       = methodName;

            // ReSharper disable once RedundantBaseQualifier
            base.State = UnitTestElementState.Fake;
        }
Exemplo n.º 33
0
        public static void RemoveAttributeFromSingleDeclaration([CanBeNull] IFieldDeclaration fieldDeclaration,
                                                                IClrTypeName attributeTypeName)
        {
            var attribute = GetAttribute(fieldDeclaration, attributeTypeName);

            if (attribute != null)
            {
                // This will split a multiple declaration, if necessary
                fieldDeclaration.RemoveAttribute(attribute);
            }
        }
 protected FieldElement(MSpecUnitTestProvider provider,
                        Element parent,
                        IClrTypeName declaringTypeName,
                        UnitTestingCachingService cachingService,
                        IUnitTestElementManager elementManager,
                        string fieldName,
                        bool isIgnored)
     : base(provider, parent, declaringTypeName, cachingService, elementManager, isIgnored || parent.Explicit)
 {
     this._fieldName = fieldName;
 }
        public static bool DerivesFrom([CanBeNull] this ITypeElement candidate, IClrTypeName baseTypeName)
        {
            if (candidate == null)
            {
                return(false);
            }
            var knownTypesCache = candidate.GetSolution().GetComponent <KnownTypesCache>();
            var baseType        = GetTypeElement(baseTypeName, knownTypesCache, candidate.Module);

            return(candidate.IsDescendantOf(baseType));
        }
Exemplo n.º 36
0
 public UnityMessage([NotNull] string name, [NotNull] string typeName, [NotNull] IClrTypeName returnType, bool returnTypeIsArray, bool isStatic, string description,
                     [NotNull] params UnityMessageParameter[] parameters)
 {
     Description         = description;
     myIsStatic          = isStatic;
     Name                = name;
     TypeName            = typeName;
     myReturnType        = returnType;
     myReturnTypeIsArray = returnTypeIsArray;
     myParameters        = parameters.Length > 0 ? parameters : EmptyArray <UnityMessageParameter> .Instance;
 }
 protected FieldElement(
     UnitTestElementId id,
     IUnitTestElement parent,
     IClrTypeName typeName,
     MspecServiceProvider serviceProvider,
     string fieldName,
     bool isIgnored)
     : base(id, parent, typeName, serviceProvider, isIgnored || parent.Explicit)
 {
     FieldName = fieldName;
 }
Exemplo n.º 38
0
        public XunitTestMethodElement(XunitServiceProvider services, UnitTestElementId id,
                                      IClrTypeName typeName, string methodName, string skipReason,
                                      bool isDynamic)
            : base(services, id, typeName)
        {
            MethodName     = methodName;
            ExplicitReason = skipReason;
            IsDynamic      = isDynamic;

            ShortName = MethodName;
        }
        private static string GetTestMethodId(XunitTestClassElement classElement, IClrTypeName typeName, string methodName)
        {
            var baseTypeName = string.Empty;

            if (!classElement.TypeName.Equals(typeName))
            {
                baseTypeName = typeName.ShortName + ".";
            }

            return(string.Format("{0}.{1}{2}", classElement.Id, baseTypeName, methodName));
        }
 protected XunitTestElementBase([NotNull] XunitServiceProvider provider, ProjectModelElementEnvoy project, string id, IClrTypeName typeName)
 {
     if (provider == null) 
         throw new ArgumentNullException("provider");
     if (project == null)
         throw new ArgumentNullException("project");
     this.provider = provider;
     this.project = project;
     TypeName = typeName;
     Id = id;
 }
Exemplo n.º 41
0
        protected XunitBaseElement(XunitServiceProvider services, UnitTestElementId id, IClrTypeName typeName)
        {
            Services = services;
            TypeName = typeName;

            Id       = id;
            Children = new BindableCollection <IUnitTestElement>(EternalLifetime.Instance, UT.Locks.ReadLock);

            ExplicitReason = string.Empty;
            Categories     = EmptyArray <UnitTestElementCategory> .Instance;
        }
Exemplo n.º 42
0
        public XunitTestClassElement(IUnitTestProvider provider, ProjectModelElementEnvoy projectModelElementEnvoy,
                                     DeclaredElementProvider declaredElementProvider, string id, IClrTypeName typeName, string assemblyLocation,
                                     IEnumerable <UnitTestElementCategory> categories)
            : base(provider, null, id, projectModelElementEnvoy, categories)
        {
            this.declaredElementProvider = declaredElementProvider;
            AssemblyLocation             = assemblyLocation;
            TypeName = typeName;

            ShortName = string.Join("+", typeName.TypeNames.Select(FormatTypeName).ToArray());
        }
Exemplo n.º 43
0
        protected XunitBaseElement(XunitServiceProvider services, UnitTestElementId id, IClrTypeName typeName)
        {
            Services = services;
            TypeName = typeName;

            Id = id;
            Children = new BindableCollection<IUnitTestElement>(EternalLifetime.Instance, UT.Locks.ReadLock);

            ExplicitReason = string.Empty;
            Categories = EmptyArray<UnitTestElementCategory>.Instance;
        }
        public TestMethodElement(TestProvider provider, IUnitTestElement parent, ProjectModelElementEnvoy projectModelElementEnvoy,
            DeclaredElementProvider declaredElementProvider, string id, IClrTypeName typeName, string methodName, string assemblyLocation, bool isParameterized)
            : base(provider, typeName, assemblyLocation, parent, id, projectModelElementEnvoy)
        {
            this.declaredElementProvider = declaredElementProvider;
            this.methodName = methodName;
            IsParameterized = isParameterized;

            ShortName = methodName;
            presentation = string.Format("{0}.{1}", typeName.ShortName, methodName);
        }
Exemplo n.º 45
0
        private static bool IsPredefinedType([CanBeNull] IType type, [NotNull] IClrTypeName clrName)
        {
            var predefinedCandidate = type as IDeclaredType;

            if (predefinedCandidate == null)
            {
                return(false);
            }

            return(IsPredefinedTypeElement(predefinedCandidate.GetTypeElement(), clrName));
        }
 protected FieldElement(MSpecUnitTestProvider provider,
                        IPsi psiModuleManager,
                        ICache cacheManager,
                        Element parent,
                        ProjectModelElementEnvoy projectEnvoy,
                        IClrTypeName declaringTypeName,
                        string fieldName,
                        bool isIgnored)
     : base(provider, psiModuleManager, cacheManager, parent, projectEnvoy, declaringTypeName, isIgnored || parent.Explicit)
 {
     this._fieldName = fieldName;
 }
        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);
        }
Exemplo n.º 49
0
        public override bool HasAttributeInstance(IClrTypeName clrTypeName)
        {
            if (AttributeClassNames.Contains(clrTypeName.ShortName))
            {
                return(false);
            }

            // todo: get entity without getting declaration
            var entity = (GetDeclaration() as IFSharpTypeDeclaration)?.GetFSharpSymbol() as FSharpEntity;

            return(entity?.Attributes.HasAttributeInstance(clrTypeName.FullName) ?? false);
        }
 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);
 }
Exemplo n.º 51
0
 protected FieldElement(MSpecUnitTestProvider provider,
                        PsiModuleManager psiModuleManager,
                        CacheManager cacheManager, 
                        Element parent,
                        ProjectModelElementEnvoy projectEnvoy,
                        IClrTypeName declaringTypeName,
                        string fieldName,
                        bool isIgnored)
   : base(provider, psiModuleManager, cacheManager, parent, projectEnvoy, declaringTypeName, isIgnored || parent.Explicit)
 {
   _fieldName = fieldName;
   State = UnitTestElementState.Valid;
 }
        public XunitTestMethodElement GetOrCreateTestMethod(IProject project, XunitTestClassElement testClassElement, IClrTypeName typeName,
                                                            string methodName, string skipReason, MultiValueDictionary<string, string> traits, bool isDynamic)
        {
            var categories = GetCategories(traits);

            var element = GetTestMethod(project, testClassElement, typeName, methodName);
            if (element != null)
            {
                element.State = UnitTestElementState.Valid;
                element.SetCategories(categories);
                return element;
            }
            return CreateTestMethod(provider, project, declaredElementProvider, testClassElement, typeName, methodName, skipReason, categories, isDynamic);
        }
 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);
 }
        protected BaseElement(TestProvider provider, IClrTypeName typeName, string assemblyLocation, IUnitTestElement parent, string id, ProjectModelElementEnvoy projectModelElementEnvoy)
        {
            this.provider = provider;
            this.id = id;
            this.projectModelElementEnvoy = projectModelElementEnvoy;

            TypeName = typeName;
            AssemblyLocation = assemblyLocation;
            Parent = parent;

            Children = new List<IUnitTestElement>();

            SetState(UnitTestElementState.Valid);
        }
        public static bool IsInsideElement(this CSharpCodeCompletionContext context, IClrTypeName typeName)
        {
            ITreeNode nodeAt = context.BasicContext.File.FindNodeAt(context.BasicContext.CaretDocumentRange);
            if (nodeAt?.Parent == null)
                return false;

            var csharpArgument = (nodeAt.Parent is ICSharpArgument ? nodeAt.Parent : nodeAt.Parent.Parent) as ICSharpArgument;
            var attribute = (csharpArgument != null ? csharpArgument.Parent : nodeAt.Parent) as IAttribute;

            var typeElement = attribute?.TypeReference?.Resolve().DeclaredElement as ITypeElement;
            if (typeElement == null)
                return false;

            return typeElement.GetClrName().Equals(typeName);
        }
        public AddRequiresExecutor(ICSharpContextActionDataProvider provider, bool shouldBeGeneric, 
            IEnumerable<ICSharpFunctionDeclaration> functionsDeclaration, string parameterName, IClrTypeName propertyType)
            : base(provider)
        {
            Contract.Requires(functionsDeclaration != null);
            Contract.Requires(parameterName != null);
            Contract.Requires(propertyType != null);

            _provider = provider;

            _shouldBeGeneric = shouldBeGeneric;
            _functionsDeclaration = functionsDeclaration;
            _parameterName = parameterName;
            _propertyType = propertyType;
        }
Exemplo n.º 57
0
 public BehaviorElement(MSpecUnitTestProvider provider,
                        PsiModuleManager psiModuleManager,
                        CacheManager cacheManager,
   // ReSharper disable SuggestBaseTypeForParameter
                        ContextElement context,
   // ReSharper restore SuggestBaseTypeForParameter
                        ProjectModelElementEnvoy projectEnvoy,
                        IClrTypeName declaringTypeName,
                        string fieldName,
                        bool isIgnored,
                        string fullyQualifiedTypeName)
   : base(provider, psiModuleManager, cacheManager, context, projectEnvoy, declaringTypeName, fieldName, isIgnored || context.Explicit)
 {
   _id = CreateId(context, fieldName);
   FullyQualifiedTypeName = fullyQualifiedTypeName;
 }
Exemplo n.º 58
0
 public UnityEventFunction([NotNull] string name, [NotNull] string typeName, [NotNull] IClrTypeName returnType,
     bool returnTypeIsArray, bool isStatic, string description, bool undocumented,
     Version minimumVersion, Version maximumVersion,
     [NotNull] params UnityEventFunctionParameter[] parameters)
 {
     Description = description;
     Undocumented = undocumented;
     myIsStatic = isStatic;
     myMinimumVersion = minimumVersion;
     myMaximumVersion = maximumVersion;
     Name = name;
     TypeName = typeName;
     myReturnType = returnType;
     myReturnTypeIsArray = returnTypeIsArray;
     myParameters = parameters.Length > 0 ? parameters : EmptyArray<UnityEventFunctionParameter>.Instance;
 }
 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);
 }
Exemplo n.º 60
0
    public ContextElement(MSpecUnitTestProvider provider,
                          IPsi psiModuleManager,
                          ICache cacheManager,
                          ProjectModelElementEnvoy projectEnvoy,
                          IClrTypeName typeName,
                          string assemblyLocation,
                          string subject,
                          IEnumerable<string> tags,
                          bool isIgnored)
      : base(provider, psiModuleManager, cacheManager, null, projectEnvoy, typeName, isIgnored)
    {
      _id = CreateId(subject, TypeName.FullName, tags);
      _assemblyLocation = assemblyLocation;
      _subject = subject;

      if (tags != null)
      {
        _categories = UnitTestElementCategory.Create(new JetHashSet<string>(tags));
      }
    }