Beispiel #1
0
        public override IUnitTestElement Map(Test test)
        {
            using (ReadLockCookie.Create())
            {
                var assemblyPath  = _project?.GetOutputFilePath(_targetFrameworkId);
                var typeName      = GetType(test);
                var fieldName     = GetField(test);
                var subject       = GetTraits(test, "Subject").FirstOrDefault();
                var tags          = GetTraits(test, "Tag");
                var behaviorField = GetTraits(test, "BehaviorField").FirstOrDefault();
                var behaviorType  = GetTraits(test, "BehaviorType").FirstOrDefault();

                var type = new ClrTypeName(typeName);

                var context = _factory.GetOrCreateContext(_project, type, assemblyPath, subject, tags.ToArray(), false);

                if (!string.IsNullOrEmpty(behaviorField) && !string.IsNullOrEmpty(behaviorType))
                {
                    var behavior = _factory.GetOrCreateBehavior(_project, context, type, behaviorField, false);

                    return(_factory.GetOrCreateBehaviorSpecification(_project, behavior, new ClrTypeName(behaviorType), fieldName, false));
                }

                return(_factory.GetOrCreateContextSpecification(_project, context, type, fieldName, false));
            }
        }
Beispiel #2
0
        private void ExploreSpecification(IProject project, IUnitTestElement contextElement, ITypeInfo type, IFieldInfo field)
        {
            var specificationElement = _factory.GetOrCreateContextSpecification(
                project,
                contextElement,
                new ClrTypeName(type.FullyQualifiedName),
                field.ShortName,
                field.IsIgnored());

            _observer.OnUnitTestElement(specificationElement);
        }
Beispiel #3
0
        private void ProcessSpecificationField(IProject project, IFieldInfo field, IDeclaration declaration = null)
        {
            var containingType = new ClrTypeName(field.DeclaringType);

            if (_contexts.TryGetValue(containingType, out var context))
            {
                var specification = _factory.GetOrCreateContextSpecification(
                    project,
                    context,
                    containingType,
                    field.ShortName,
                    field.IsIgnored());

                OnUnitTestElement(specification, declaration);
            }
        }