public void Explore(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver consumer, IMetadataTypeInfo metadataTypeInfo)
        {
            if (!metadataTypeInfo.IsContext())
            {
                return;
            }

            ContextElement contextElement = this._factories.Contexts.CreateContext(project, assembly.Location.FullPath, metadataTypeInfo);

            consumer.OnUnitTestElement(contextElement);

            metadataTypeInfo.GetSpecifications()
            .ForEach(x =>
            {
                var contextSpecificationElement = this._factories.ContextSpecifications.CreateContextSpecification(contextElement, x);
                consumer.OnUnitTestElement(contextSpecificationElement);
            });

            metadataTypeInfo.GetBehaviors().ForEach(x =>
            {
                var behaviorElement = this._factories.Behaviors.CreateBehavior(contextElement, x);
                consumer.OnUnitTestElement(behaviorElement);

                this._factories.BehaviorSpecifications
                .CreateBehaviorSpecificationsFromBehavior(behaviorElement, x)
                .ForEach(consumer.OnUnitTestElement);

                consumer.OnUnitTestElementChanged(behaviorElement);
            });

            consumer.OnUnitTestElementChanged(contextElement);
        }
        public void Explore(IProject project, IMetadataAssembly assembly, UnitTestElementConsumer consumer, IMetadataTypeInfo metadataTypeInfo)
        {
            if (!metadataTypeInfo.IsContext())
            {
                return;
            }

            var contextElement = _factories.Contexts.CreateContext(project, assembly.Location.FullPath, metadataTypeInfo);

            consumer(contextElement);

            metadataTypeInfo.GetSpecifications()
            .ForEach(x => consumer(_factories.ContextSpecifications.CreateContextSpecification(contextElement, x)));


            metadataTypeInfo.GetBehaviors().ForEach(x =>
            {
                var behaviorElement = _factories.Behaviors.CreateBehavior(contextElement, x);
                consumer(behaviorElement);


                _factories.BehaviorSpecifications
                .CreateBehaviorSpecificationsFromBehavior(behaviorElement, x)
                .ForEach(y => consumer(y));
            });
        }
    public void Explore(IProject project, IMetadataAssembly assembly, UnitTestElementConsumer consumer, IMetadataTypeInfo metadataTypeInfo)
    {
      if (!metadataTypeInfo.IsContext())
      {
        return;
      }

      var contextElement = _factories.Contexts.CreateContext(project, assembly.Location.FullPath, metadataTypeInfo);

      consumer(contextElement);

      metadataTypeInfo.GetSpecifications()
          .ForEach(x => consumer(_factories.ContextSpecifications.CreateContextSpecification(contextElement, x)));


      metadataTypeInfo.GetBehaviors().ForEach(x =>
      {
        var behaviorElement = _factories.Behaviors.CreateBehavior(contextElement, x);
        consumer(behaviorElement);


        _factories.BehaviorSpecifications
                    .CreateBehaviorSpecificationsFromBehavior(behaviorElement, x)
                    .ForEach(y => consumer(y));
      });
    }
 public static bool IsContext(this IMetadataTypeInfo type)
 {
     return(!type.IsAbstract &&
            !type.IsStruct() &&
            type.GenericParameters.Length == 0 &&
            !type.HasCustomAttribute(FullNames.BehaviorsAttribute) &&
            (type.GetSpecifications().Any() || type.GetBehaviors().Any()));
 }
Esempio n. 5
0
        public IEnumerable <BehaviorSpecificationElement> CreateBehaviorSpecificationsFromBehavior(
            BehaviorElement behavior,
            IMetadataField behaviorSpecification)
        {
            IMetadataTypeInfo typeContainingBehaviorSpecifications = behaviorSpecification.GetFirstGenericArgument();

            foreach (var specification in typeContainingBehaviorSpecifications.GetSpecifications())
            {
                yield return(CreateBehaviorSpecification(behavior, specification));
            }
        }
        public void Explore(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver consumer, IMetadataTypeInfo metadataTypeInfo)
        {
            if (!metadataTypeInfo.IsContext())
            {
                return;
            }

            var contextElement = this._factories.Contexts.CreateContext(project, assembly.Location.FullPath, metadataTypeInfo);

            consumer.OnUnitTestElement(contextElement);

            metadataTypeInfo.GetSpecifications()
                .ForEach(x =>
                {
                    var element = this._factories.ContextSpecifications.CreateContextSpecification(contextElement, x);
                    consumer.OnUnitTestElement(element);
                    consumer.OnUnitTestElementChanged(element);
                });


            metadataTypeInfo.GetBehaviors().ForEach(x =>
            {
                var behaviorElement = this._factories.Behaviors.CreateBehavior(contextElement, x);
                consumer.OnUnitTestElement(behaviorElement);
                consumer.OnUnitTestElementChanged(behaviorElement);


                this._factories.BehaviorSpecifications
                            .CreateBehaviorSpecificationsFromBehavior(behaviorElement, x)
                            .ForEach(y =>
                            {
                                consumer.OnUnitTestElement(y);
                                consumer.OnUnitTestElementChanged(y);
                            });
            });
        }