示例#1
0
 public override void OneTimeSetup()
 {
     _behaviorRootInstanceType    = typeof(BehaviorRoot);
     _behaviorRootInstanceFixture = this.Create <BehaviorRoot>(true);
     _behaviorRootInstance        = _behaviorRootInstanceFixture ?? this.Create <BehaviorRoot>(false);
     CurrentInstance = _behaviorRootInstanceFixture;
     ConfigureIgnoringTests(); // Configure ignoring tests.
 }
示例#2
0
        public void AUT_BehaviorRoot_Constructor_Instantiation_With_Parameter_Test()
        {
            // Arrange
            var          builder           = this.CreateType <ISpecimenBuilder>();
            BehaviorRoot instance          = null;
            Exception    creationException = null;

            // Act
            Action createAction = () => instance = new BehaviorRoot(builder);

            creationException = ActionAnalyzer.GetActionException(createAction);

            // Assert
            instance.ShouldNotBeNull();
            _behaviorRootInstance.ShouldNotBeNull();
            _behaviorRootInstanceFixture.ShouldNotBeNull();
            Should.NotThrow(createAction);
        }
示例#3
0
        public Fixture(ISpecimenBuilder engine, MultipleRelay multiple)
        {
            this.Engine   = engine ?? throw new ArgumentNullException(nameof(engine));
            this.multiple = multiple ?? throw new ArgumentNullException(nameof(multiple));

            ISpecimenBuilderNode newGraph =
                new BehaviorRoot(
                    new TerminatingWithPathSpecimenBuilder(new CompositeSpecimenBuilder(
                                                               new CustomizationNode(
                                                                   new CompositeSpecimenBuilder(
                                                                       new FilteringSpecimenBuilder(
                                                                           new FixedBuilder(
                                                                               this),
                                                                           new OrRequestSpecification(
                                                                               new ExactTypeSpecification(
                                                                                   typeof(Fixture)),
                                                                               new ExactTypeSpecification(
                                                                                   typeof(IFixture)),
                                                                               new ExactTypeSpecification(
                                                                                   typeof(ISpecimenBuilder)))),

                                                                       new StableFiniteSequenceRelay(),

                                                                       MakeQueryBasedBuilderForMatchingType(
                                                                           typeof(Dictionary <,>),
                                                                           new ModestConstructorQuery(),
                                                                           new DictionaryFiller()),
                                                                       MakeQueryBasedBuilderForMatchingType(
                                                                           typeof(SortedDictionary <,>),
                                                                           new ModestConstructorQuery(),
                                                                           new DictionaryFiller()),
                                                                       MakeQueryBasedBuilderForMatchingType(
                                                                           typeof(SortedList <,>),
                                                                           new ModestConstructorQuery(),
                                                                           new DictionaryFiller()),
                                                                       MakeQueryBasedBuilderForMatchingType(
                                                                           typeof(Collection <>),
                                                                           new ListFavoringConstructorQuery()),
                                                                       MakeQueryBasedBuilderForMatchingType(
                                                                           typeof(List <>),
                                                                           new EnumerableFavoringConstructorQuery()),
                                                                       MakeQueryBasedBuilderForMatchingType(
                                                                           typeof(HashSet <>),
                                                                           new EnumerableFavoringConstructorQuery()),
                                                                       MakeQueryBasedBuilderForMatchingType(
                                                                           typeof(SortedSet <>),
                                                                           new EnumerableFavoringConstructorQuery()),
                                                                       MakeQueryBasedBuilderForMatchingType(
                                                                           typeof(ObservableCollection <>),
                                                                           new EnumerableFavoringConstructorQuery()),

                                                                       new FilteringSpecimenBuilder(
                                                                           new MethodInvoker(
                                                                               new ModestConstructorQuery()),
                                                                           new NullableEnumRequestSpecification()),
                                                                       new EnumGenerator(),
                                                                       new LambdaExpressionGenerator(),

                                                                       MakeFixedBuilder(
                                                                           CultureInfo.InvariantCulture),
                                                                       MakeFixedBuilder(
                                                                           Encoding.UTF8),
                                                                       MakeFixedBuilder(
                                                                           IPAddress.Loopback),

                                                                       new DataAnnotationsSupportNode(
                                                                           new CompositeSpecimenBuilder(
                                                                               new RangeAttributeRelay(),
                                                                               new NumericRangedRequestRelay(),
                                                                               new EnumRangedRequestRelay(),
                                                                               new TimeSpanRangedRequestRelay(),
                                                                               new StringLengthAttributeRelay(),
                                                                               new MinAndMaxLengthAttributeRelay(),
                                                                               new RegularExpressionAttributeRelay())))),
                                                               new AutoPropertiesTarget(
                                                                   new Postprocessor(
                                                                       new CompositeSpecimenBuilder(
                                                                           engine,
                                                                           multiple),
                                                                       new AutoPropertiesCommand(),
                                                                       new AnyTypeSpecification())),
                                                               new ResidueCollectorNode(
                                                                   new CompositeSpecimenBuilder(
                                                                       new TypeRelay(
                                                                           typeof(IDictionary <,>),
                                                                           typeof(Dictionary <,>)),
                                                                       new TypeRelay(
                                                                           typeof(IReadOnlyDictionary <,>),
                                                                           typeof(ReadOnlyDictionary <,>)),
                                                                       new TypeRelay(
                                                                           typeof(ICollection <>),
                                                                           typeof(List <>)),
                                                                       new TypeRelay(
                                                                           typeof(IReadOnlyCollection <>),
                                                                           typeof(ReadOnlyCollection <>)),
                                                                       new TypeRelay(
                                                                           typeof(IList <>),
                                                                           typeof(List <>)),
                                                                       new TypeRelay(
                                                                           typeof(IReadOnlyList <>),
                                                                           typeof(ReadOnlyCollection <>)),
                                                                       new TypeRelay(
                                                                           typeof(ISet <>),
                                                                           typeof(HashSet <>)),
                                                                       new EnumerableRelay(),
                                                                       new EnumeratorRelay())),
                                                               new FilteringSpecimenBuilder(
                                                                   new MutableValueTypeWarningThrower(),
                                                                   new AndRequestSpecification(
                                                                       new ValueTypeSpecification(),
                                                                       new NoConstructorsSpecification())))));

            this.UpdateGraphAndSetupAdapters(newGraph, Enumerable.Empty <ISpecimenBuilderTransformation>());

            this.Behaviors.Add(new ThrowingRecursionBehavior());
        }