Ejemplo n.º 1
0
        public void CombineExplictPropertyWithAutoProperties()
        {
            // Fixture setup
            var expectedText = "Fnaah";

            var specifiedCommand = new BindingCommand<DoublePropertyHolder<string, int>, string>(ph => ph.Property1, expectedText);
            var reservedProperty = new InverseRequestSpecification(specifiedCommand);

            var customizedBuilder = new Postprocessor<DoublePropertyHolder<string, int>>(
                new Postprocessor<DoublePropertyHolder<string, int>>(
                    new MethodInvoker(new ModestConstructorQuery()),
                    specifiedCommand),
                new AutoPropertiesCommand<DoublePropertyHolder<string, int>>(reservedProperty),
                new AnyTypeSpecification());

            var builder = new CompositeSpecimenBuilder(
                customizedBuilder,
                Scenario.CreateAutoPropertyBuilder());
            var container = new SpecimenContext(builder);
            // Exercise system
            var result = container.Resolve(typeof(DoublePropertyHolder<string, int>));
            // Verify outcome
            var actual = Assert.IsAssignableFrom<DoublePropertyHolder<string, int>>(result);
            Assert.Equal(expectedText, actual.Property1);
            Assert.Equal(1, actual.Property2);
            // Teardown
        }
Ejemplo n.º 2
0
        /// <summary>Composes the supplied builders.</summary>
        /// <param name="builders">The builders to compose.</param>
        /// <returns>
        /// A new <see cref="ISpecimenBuilderNode" /> instance containing
        /// <paramref name="builders" /> as child nodes.
        /// </returns>
        public virtual ISpecimenBuilderNode Compose(IEnumerable <ISpecimenBuilder> builders)
        {
            var composedBuilder = CompositeSpecimenBuilder.ComposeIfMultiple(builders);
            var d = new DisposableTracker(composedBuilder);

            this.disposables.Add(d);
            return(d);
        }
Ejemplo n.º 3
0
        /// <summary>Composes the supplied builders.</summary>
        /// <param name="builders">The builders to compose.</param>
        /// <returns>
        /// A new <see cref="ISpecimenBuilderNode" /> instance containing
        /// <paramref name="builders" /> as child nodes.
        /// </returns>
        public override ISpecimenBuilderNode Compose(IEnumerable <ISpecimenBuilder> builders)
        {
            var composedBuilder = CompositeSpecimenBuilder.ComposeIfMultiple(builders);
            var pp = new Postprocessor(composedBuilder, this.Command, this.Specification);

            pp.action = this.action;
            return(pp);
        }
Ejemplo n.º 4
0
        /// <summary>Composes the supplied builders.</summary>
        /// <param name="builders">The builders to compose.</param>
        /// <returns>
        /// A new <see cref="ISpecimenBuilderNode" /> instance containing
        /// <paramref name="builders" /> as child nodes.
        /// </returns>
        public override ISpecimenBuilderNode Compose(
            IEnumerable <ISpecimenBuilder> builders)
        {
            var composedBuilder =
                CompositeSpecimenBuilder.ComposeIfMultiple(builders);

            return(new OmitOnRecursionGuard(composedBuilder, this.Comparer));
        }
Ejemplo n.º 5
0
        /// <summary>Composes the supplied builders.</summary>
        /// <param name="builders">The builders to compose.</param>
        /// <returns>
        /// A new <see cref="ISpecimenBuilderNode" /> instance containing
        /// <paramref name="builders" /> as child nodes.
        /// </returns>
        public virtual ISpecimenBuilderNode Compose(IEnumerable <ISpecimenBuilder> builders)
        {
            var builder = CompositeSpecimenBuilder.ComposeIfMultiple(builders);

            return(new TraceWriter(
                       this.writer,
                       new TracingBuilder(
                           builder)));
        }
 public void SutIsNode()
 {
     // Fixture setup
     // Exercise system
     var sut = new CompositeSpecimenBuilder();
     // Verify outcome
     Assert.IsAssignableFrom<ISpecimenBuilderNode>(sut);
     // Teardown
 }
 public void SutIsSequenceOfSpecimenBuilders()
 {
     // Fixture setup
     // Exercise system
     var sut = new CompositeSpecimenBuilder();
     // Verify outcome
     Assert.IsAssignableFrom<IEnumerable<ISpecimenBuilder>>(sut);
     // Teardown
 }
 public void SutIsSpecimenBuilder()
 {
     // Fixture setup
     // Exercise system
     var sut = new CompositeSpecimenBuilder();
     // Verify outcome
     Assert.IsInstanceOfType(sut, typeof(ISpecimenBuilder));
     // Teardown
 }
 public void SutIsComposer()
 {
     // Fixture setup
     var dummyNode = new CompositeSpecimenBuilder();
     // Exercise system
     var sut = new CompositeNodeComposer<object>(dummyNode);
     // Verify outcome
     Assert.IsAssignableFrom<ICustomizationComposer<object>>(sut);
     // Teardown
 }
 public void BuildersWillNotBeNullWhenSutIsCreatedWithDefaultConstructor()
 {
     // Fixture setup
     var sut = new CompositeSpecimenBuilder();
     // Exercise system
     IEnumerable<ISpecimenBuilder> result = sut.Builders;
     // Verify outcome
     Assert.NotNull(result);
     // Teardown
 }
 public void SutIsEventArgs()
 {
     // Fixture setup
     var dummyNode = new CompositeSpecimenBuilder();
     // Exercise system
     var sut = new SpecimenBuilderNodeEventArgs(dummyNode);
     // Verify outcome
     Assert.IsAssignableFrom<EventArgs>(sut);
     // Teardown
 }
Ejemplo n.º 12
0
        /// <summary>Composes the supplied builders.</summary>
        /// <param name="builders">The builders to compose.</param>
        /// <returns>A <see cref="ISpecimenBuilderNode" /> instance.</returns>
        /// <remarks>
        /// <para>
        /// Note to implementers:
        /// </para>
        /// <para>
        /// The intent of this method is to compose the supplied
        /// <paramref name="builders" /> into a new instance of the type
        /// implementing <see cref="ISpecimenBuilderNode" />. Thus, the
        /// concrete return type is expected to the same type as the type
        /// implementing the method. However, it is not considered a failure to
        /// deviate from this idiom - it would just not be a mainstream
        /// implementation.
        /// </para>
        /// <para>
        /// The returned instance is normally expected to contain the builders
        /// supplied as an argument, but again this is not strictly required.
        /// The implementation may decide to filter the sequence or add to it
        /// during composition.
        /// </para>
        /// </remarks>
        public virtual ISpecimenBuilderNode Compose(
            IEnumerable <ISpecimenBuilder> builders)
        {
            var composedBuilder = CompositeSpecimenBuilder.ComposeIfMultiple(
                builders);

            return(new RecursionGuard(
                       composedBuilder,
                       this.recursionHandler,
                       this.comparer));
        }
 public void GraphIsCorrect()
 {
     // Fixture setup
     var expected = new CompositeSpecimenBuilder();
     var sut = new SpecimenBuilderNodeEventArgs(expected);
     // Exercise system
     ISpecimenBuilderNode actual = sut.Graph;
     // Verify outcome
     Assert.Equal(expected, actual);
     // Teardown
 }
        public void BuildersWillNotBeNullWhenSutIsCreatedWithDefaultConstructor()
        {
            // Fixture setup
            var sut = new CompositeSpecimenBuilder();
            // Exercise system
#pragma warning disable 618
            IList<ISpecimenBuilder> result = sut.Builders;
#pragma warning restore 618
            // Verify outcome
            Assert.NotNull(result);
            // Teardown
        }
 public void ComposeSingleNodeReturnsCorrectResult()
 {            
     // Fixture setup
     var dummyNode = new CompositeSpecimenBuilder();
     var sut = new CompositeNodeComposer<uint>(dummyNode);
     ISpecimenBuilderNode expected = new CompositeSpecimenBuilder();
     // Exercise system
     var actual = sut.Compose(new[] { expected });
     // Verify outcome
     var c =
         Assert.IsAssignableFrom<CompositeNodeComposer<uint>>(actual);
     Assert.Equal(expected, c.Node);
     // Teardown
 }
Ejemplo n.º 16
0
 public void ComposeWithAutoProperties()
 {
     // Fixture setup
     var customBuilder = SpecimenBuilderNodeFactory.CreateComposer<DoublePropertyHolder<int, int>>()
         .WithAutoProperties();
     var builder = new CompositeSpecimenBuilder(
         customBuilder,
         Scenario.CreateCoreBuilder());
     // Exercise system
     var result = new SpecimenContext(builder).CreateAnonymous<DoublePropertyHolder<int, int>>();
     // Verify outcome
     Assert.Equal(1, result.Property1);
     Assert.Equal(2, result.Property2);
     // Teardown
 }
 public void BuildersWillMatchParamsArray()
 {
     // Fixture setup
     var expectedBuilders = new ISpecimenBuilder[]
     {
         new DelegatingSpecimenBuilder(),
         new DelegatingSpecimenBuilder(),
         new DelegatingSpecimenBuilder()
     };
     var sut = new CompositeSpecimenBuilder(expectedBuilders[0], expectedBuilders[1], expectedBuilders[2]);
     // Exercise system
     var result = sut.Builders;
     // Verify outcome
     Assert.True(expectedBuilders.SequenceEqual(result), "Builders");
     // Teardown
 }
 public void BuildersWillMatchListParameter()
 {
     // Fixture setup
     var expectedBuilders = new ISpecimenBuilder[]
     {
         new DelegatingSpecimenBuilder(),
         new DelegatingSpecimenBuilder(),
         new DelegatingSpecimenBuilder()
     }.AsEnumerable();
     var sut = new CompositeSpecimenBuilder(expectedBuilders);
     // Exercise system
     var result = sut.Builders;
     // Verify outcome
     Assert.True(expectedBuilders.SequenceEqual(result), "Builders");
     // Teardown
 }
 public void ComposeReturnsCorrectResult()
 {
     // Fixture setup
     var dummyNode = new CompositeSpecimenBuilder();
     var sut = new CompositeNodeComposer<uint>(dummyNode);
     // Exercise system
     var expectedBuilders = new[]
     {
         new DelegatingSpecimenBuilder(),
         new DelegatingSpecimenBuilder(),
         new DelegatingSpecimenBuilder()
     };
     var actual = sut.Compose(expectedBuilders);
     // Verify outcome
     var c =
         Assert.IsAssignableFrom<CompositeNodeComposer<uint>>(actual);
     var composite = 
         Assert.IsAssignableFrom<CompositeSpecimenBuilder>(c.Node);
     Assert.True(expectedBuilders.SequenceEqual(composite));
     // Teardown
 }
Ejemplo n.º 20
0
 public void ComposeComplexObjectWithAutoPropertiesAndSomeCustomizations()
 {
     // Fixture setup
     var builder = new CompositeSpecimenBuilder(
         SpecimenBuilderNodeFactory.CreateComposer<DoublePropertyHolder<long, long>>()
             .With(x => x.Property2, 43)
             .WithAutoProperties(),
         SpecimenBuilderNodeFactory.CreateComposer<DoublePropertyHolder<int, string>>()
             .OmitAutoProperties()
             .With(x => x.Property1),
         SpecimenBuilderNodeFactory.CreateComposer<DoublePropertyHolder<DoublePropertyHolder<long, long>, DoublePropertyHolder<int, string>>>()
             .WithAutoProperties(),
         Scenario.CreateCoreBuilder());
     // Exercise system
     var result = new SpecimenContext(builder).CreateAnonymous<DoublePropertyHolder<DoublePropertyHolder<long, long>, DoublePropertyHolder<int, string>>>();
     // Verify outcome
     Assert.Equal(1, result.Property1.Property1);
     Assert.Equal(43, result.Property1.Property2);
     Assert.Equal(1, result.Property2.Property1);
     Assert.Null(result.Property2.Property2);
     // Teardown
 }
        /// <summary>
        /// Customizes the specified fixture by adding the <see cref="Type"/> specific numeric sequence generators.
        /// </summary>
        /// <param name="fixture">The fixture to customize.</param>
        public void Customize(IFixture fixture)
        {
            if (fixture == null)
            {
                throw new ArgumentNullException("fixture");
            }

            var numericBuilders = new CompositeSpecimenBuilder(new ISpecimenBuilder[]
            {
                new ByteSequenceGenerator(),
                new DecimalSequenceGenerator(),
                new DoubleSequenceGenerator(),
                new Int16SequenceGenerator(),
                new Int32SequenceGenerator(),
                new Int64SequenceGenerator(),
                new SByteSequenceGenerator(),
                new SingleSequenceGenerator(),
                new UInt16SequenceGenerator(),
                new UInt32SequenceGenerator(),
                new UInt64SequenceGenerator()
            });

            fixture.Customizations.Add(numericBuilders);
        }
Ejemplo n.º 22
0
 public void CustomizeFromFactoryCorrectlyResolvesSpecimen()
 {
     // Fixture setup
     var instance = new PropertyHolder<float> { Property = 89 };
     var builder = new CompositeSpecimenBuilder(
         SpecimenBuilderNodeFactory.CreateComposer<PropertyHolder<float>>().FromFactory(() => instance).OmitAutoProperties(),
         Scenario.CreateCoreBuilder());
     // Exercise system
     var result = new SpecimenContext(builder).CreateAnonymous<PropertyHolder<float>>();
     // Verify outcome
     Assert.Equal(instance, result);
     Assert.Equal(89, result.Property);
     // Teardown
 }
Ejemplo n.º 23
0
 public void CustomDoSetsCorrectProperty()
 {
     // Fixture setup
     var builder = new CompositeSpecimenBuilder(
         SpecimenBuilderNodeFactory.CreateComposer<PropertyHolder<decimal>>().OmitAutoProperties().Do(x => x.SetProperty(6789)),
         Scenario.CreateCoreBuilder());
     // Exercise system
     var result = new SpecimenContext(builder).CreateAnonymous<SingleParameterType<PropertyHolder<decimal>>>();
     // Verify outcome
     Assert.Equal(6789, result.Parameter.Property);
     // Teardown
 }
Ejemplo n.º 24
0
 public void CreateDoubleMixedParameterizedTypeWithNumberBasedStringGenerator()
 {
     // Fixture setup
     var intGenerator = new Int32SequenceGenerator();
     var builder = new CompositeSpecimenBuilder(
         intGenerator,
         new StringGenerator(() => intGenerator.CreateAnonymous()),
         new Int64SequenceGenerator(),
         new DecimalSequenceGenerator(),
         new BooleanSwitch(),
         new GuidGenerator(),
         new MethodInvoker(new ModestConstructorQuery()),
         new ParameterRequestRelay(),
         new StringSeedRelay(),
         new SeedIgnoringRelay());
     var container = new SpecimenContext(builder);
     // Exercise system
     var result = (TripleParameterType<int, string, int>)container.Resolve(typeof(TripleParameterType<int, string, int>));
     // Verify outcome
     Assert.Equal(1, result.Parameter1);
     Assert.Equal("parameter22", result.Parameter2);
     Assert.Equal(3, result.Parameter3);
     // Teardown
 }
 public void DoReturnsCorrectResult()
 {
     // Fixture setup
     var node = new CompositeSpecimenBuilder(
         new DelegatingSpecimenBuilder(),
         SpecimenBuilderNodeFactory.CreateComposer<AppDomainSetup>(),
         SpecimenBuilderNodeFactory.CreateComposer<bool>(),
         SpecimenBuilderNodeFactory.CreateComposer<AppDomainSetup>(),
         new DelegatingSpecimenBuilder());
     var sut = new CompositeNodeComposer<AppDomainSetup>(node);
     Action<AppDomainSetup> a =
         ads => ads.DisallowApplicationBaseProbing = false;
     // Exercise system
     var actual = sut.Do(a);
     // Verify outcome
     var expected = new CompositeNodeComposer<AppDomainSetup>(
         new CompositeSpecimenBuilder(
             new DelegatingSpecimenBuilder(),
             (ISpecimenBuilder)SpecimenBuilderNodeFactory.CreateComposer<AppDomainSetup>().Do(a),
             SpecimenBuilderNodeFactory.CreateComposer<bool>(),
             (ISpecimenBuilder)SpecimenBuilderNodeFactory.CreateComposer<AppDomainSetup>().Do(a),
             new DelegatingSpecimenBuilder()));
     var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual);
     Assert.True(expected.GraphEquals(n, new NodeComparer()));
     // Teardown
 }
Ejemplo n.º 26
0
        public void CreateAndAddProperyValues()
        {
            // Fixture setup
            var ctorInvoker = new MethodInvoker(new ModestConstructorQuery());
            var strCmd = new BindingCommand<DoublePropertyHolder<string, int>, string>(ph => ph.Property1);
            var intCmd = new BindingCommand<DoublePropertyHolder<string, int>, int>(ph => ph.Property2);
            var strPostprocessor = new Postprocessor<DoublePropertyHolder<string, int>>(ctorInvoker, strCmd);
            var intPostprocessor = new Postprocessor<DoublePropertyHolder<string, int>>(strPostprocessor, intCmd);

            var builder = new CompositeSpecimenBuilder(
                new FilteringSpecimenBuilder(intPostprocessor, new ExactTypeSpecification(typeof(DoublePropertyHolder<string, int>))),
                Scenario.CreateAutoPropertyBuilder());
            var container = new SpecimenContext(builder);
            // Exercise system
            var result = container.Resolve(typeof(DoublePropertyHolder<string, int>));
            // Verify outcome
            var actual = Assert.IsAssignableFrom<DoublePropertyHolder<string, int>>(result);
            Assert.False(string.IsNullOrEmpty(actual.Property1), "Property1");
            Assert.Equal(1, actual.Property2);
            // Teardown
        }
Ejemplo n.º 27
0
 public void ComposeWithValueReturnsCorrectResult()
 {
     // Fixture setup
     var expectedValue = 9;
     var customBuilder = SpecimenBuilderNodeFactory.CreateComposer<PropertyHolder<int>>()
         .With(x => x.Property, expectedValue);
     var builder = new CompositeSpecimenBuilder(
         customBuilder,
         Scenario.CreateCoreBuilder());
     // Exercise system
     var result = new SpecimenContext(builder).CreateAnonymous<PropertyHolder<int>>();
     // Verify outcome
     Assert.Equal(expectedValue, result.Property);
     // Teardown
 }
 public void LegacyComposeReturnsCorrectResult()
 {
     // Fixture setup
     var dummyNode = new CompositeSpecimenBuilder();
     var sut = new CompositeNodeComposer<UTF8Encoding>(dummyNode);
     // Exercise system
     var actual = sut.Compose();
     // Verify outcome
     Assert.Equal(sut, actual);
     // Teardown
 }
 public void OmitAutoPropertiesAfterAddingAutoPropertiesReturnsCorrectResult()
 {
     // Fixture setup
     var node = new CompositeSpecimenBuilder(
         new DelegatingSpecimenBuilder(),
         SpecimenBuilderNodeFactory.CreateComposer<Version>(),
         SpecimenBuilderNodeFactory.CreateComposer<string>(),
         SpecimenBuilderNodeFactory.CreateComposer<Version>(),
         new DelegatingSpecimenBuilder());
     var sut = new CompositeNodeComposer<Version>(node);
     // Exercise system
     var actual = sut.WithAutoProperties().OmitAutoProperties();
     // Verify outcome
     var expected = new CompositeNodeComposer<Version>(
         new CompositeSpecimenBuilder(
             new DelegatingSpecimenBuilder(),
             (ISpecimenBuilder)SpecimenBuilderNodeFactory.CreateComposer<Version>().WithAutoProperties().OmitAutoProperties(),
             SpecimenBuilderNodeFactory.CreateComposer<string>(),
             (ISpecimenBuilder)SpecimenBuilderNodeFactory.CreateComposer<Version>().WithAutoProperties().OmitAutoProperties(),
             new DelegatingSpecimenBuilder()));
     var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual);
     Assert.True(expected.GraphEquals(n, new NodeComparer()));
     // Teardown
 }
        /// <summary>
        /// Customizes the fixture by freezing the value of <see cref="TargetType"/>.
        /// </summary>
        /// <param name="fixture">The fixture to customize.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="fixture"/> is null.
        /// </exception>
        public void Customize(IFixture fixture)
        {
            if (fixture == null)
            {
                throw new ArgumentNullException(nameof(fixture));
            }

            var specimen = fixture.Create(
                    this.targetType);
            var fixedBuilder = new FixedBuilder(specimen);

            var types = new[]
                {
                    this.targetType,
                    this.registeredType 
                };

            var builder = new CompositeSpecimenBuilder(
                from t in types
                select SpecimenBuilderNodeFactory.CreateTypedNode(
                    t, fixedBuilder) as ISpecimenBuilder);

            fixture.Customizations.Insert(0, builder);
        }
Ejemplo n.º 31
0
        /// <summary>Composes the supplied builders.</summary>
        /// <param name="builders">The builders to compose.</param>
        /// <returns>
        /// A new <see cref="ISpecimenBuilderNode" /> instance containing
        /// <paramref name="builders" /> as child nodes.
        /// </returns>
        public virtual ISpecimenBuilderNode Compose(IEnumerable <ISpecimenBuilder> builders)
        {
            var composedBuilder = CompositeSpecimenBuilder.ComposeIfMultiple(builders);

            return(new FilteringSpecimenBuilder(composedBuilder, this.specification));
        }
Ejemplo n.º 32
0
        public void CreateWillCorrectlyRaiseSpecimenRequestedInCompositeRequest()
        {
            // Fixture setup
            object requestedObject = "The request";
            object subRequest = "Some sub request";

            var spy = new List<RequestTraceEventArgs>();
            var builder2 = new DelegatingSpecimenBuilder { OnCreate = (r, c) => r == requestedObject ? c.Resolve(subRequest) : new NoSpecimen() };
            var builder3 = new DelegatingSpecimenBuilder { OnCreate = (r, c) => r == subRequest ? new object() : new NoSpecimen() };
            var compBuilder = new CompositeSpecimenBuilder(builder2, builder3);

            var sut = new DelegatingTracingBuilder(compBuilder);
            sut.SpecimenRequested += (sender, e) => spy.Add(e);

            var container = new SpecimenContext(sut);
            // Exercise system
            sut.Create(requestedObject, container);
            // Verify outcome
            Assert.Equal(2, spy.Count);
            Assert.Equal(subRequest, spy[1].Request);
            Assert.Equal(2, spy[1].Depth);
            // Teardown
        }
Ejemplo n.º 33
0
        public void CreateWillTrackCreatedSpecimensComposite()
        {
            // Fixture setup
            object requestedObject = "The request";
            object subRequest = "Some sub request";
            object createdSpecimen = Guid.NewGuid();
            var spy = new List<object>();
            var builder2 = new DelegatingSpecimenBuilder { OnCreate = (r, c) => r == requestedObject ? c.Resolve(subRequest) : new NoSpecimen() };
            var builder3 = new DelegatingSpecimenBuilder { OnCreate = (r, c) => r == subRequest ? createdSpecimen : new NoSpecimen() };
            var compBuilder = new CompositeSpecimenBuilder(builder2, builder3);

            var sut = new DelegatingTracingBuilder(compBuilder);
            sut.SpecimenCreated += (sender, e) => spy.Add(e.Specimen);
            var container = new SpecimenContext(sut);
            // Exercise system
            sut.Create(requestedObject, container);

            // Verify outcome
            Assert.Equal(2, spy.Count);
            Assert.Equal(createdSpecimen, spy[0]);
            Assert.Equal(createdSpecimen, spy[1]);

            // Teardown
        }
Ejemplo n.º 34
0
 public void ComposeWithoutCorrectlyCreatesSpecimen()
 {
     // Fixture setup
     var builder = new CompositeSpecimenBuilder(
         SpecimenBuilderNodeFactory.CreateComposer<DoubleFieldHolder<string, int>>().WithAutoProperties().Without(x => x.Field1),
         Scenario.CreateCoreBuilder());
     // Exercise system
     var result = new SpecimenContext(builder).CreateAnonymous<DoubleFieldHolder<string, int>>();
     // Verify outcome
     Assert.Null(result.Field1);
     Assert.Equal(1, result.Field2);
     // Teardown
 }
 public void WithExplicitValueReturnsCorrectResult(string value)
 {
     // Fixture setup
     var node = new CompositeSpecimenBuilder(
         new DelegatingSpecimenBuilder(),
         SpecimenBuilderNodeFactory.CreateComposer<PropertyHolder<string>>(),
         SpecimenBuilderNodeFactory.CreateComposer<Version>(),
         SpecimenBuilderNodeFactory.CreateComposer<PropertyHolder<string>>(),
         new DelegatingSpecimenBuilder());
     var sut = new CompositeNodeComposer<PropertyHolder<string>>(node);
     // Exercise system
     var actual = sut.With(x => x.Property, value);
     // Verify outcome
     var expected = new CompositeNodeComposer<PropertyHolder<string>>(
         new CompositeSpecimenBuilder(
             new DelegatingSpecimenBuilder(),
             (ISpecimenBuilder)SpecimenBuilderNodeFactory.CreateComposer<PropertyHolder<string>>().With(x => x.Property, value),
             SpecimenBuilderNodeFactory.CreateComposer<Version>(),
             (ISpecimenBuilder)SpecimenBuilderNodeFactory.CreateComposer<PropertyHolder<string>>().With(x => x.Property, value),
             new DelegatingSpecimenBuilder()));
     var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual);
     Assert.True(expected.GraphEquals(n, new NodeComparer()));
     // Teardown
 }
        /// <summary>Composes the supplied builders.</summary>
        /// <param name="builders">The builders to compose.</param>
        /// <returns>
        /// A new <see cref="ISpecimenBuilderNode" /> instance containing
        /// <paramref name="builders" /> as child nodes.
        /// </returns>
        public virtual ISpecimenBuilderNode Compose(IEnumerable <ISpecimenBuilder> builders)
        {
            var builder = CompositeSpecimenBuilder.ComposeIfMultiple(builders);

            return(new TerminatingWithPathSpecimenBuilder(new TracingBuilder(builder)));
        }
Ejemplo n.º 37
0
        /// <summary>Composes the supplied builders.</summary>
        /// <param name="builders">The builders to compose.</param>
        /// <returns>
        /// A new <see cref="ISpecimenBuilderNode" /> instance containing
        /// <paramref name="builders" /> as child nodes.
        /// </returns>
        public ISpecimenBuilderNode Compose(IEnumerable <ISpecimenBuilder> builders)
        {
            var composedBuilder = CompositeSpecimenBuilder.ComposeIfMultiple(builders);

            return(new NoSpecimenOutputGuard(composedBuilder, this.specification));
        }
 public void WithoutReturnsCorrectResult()
 {
     // Fixture setup
     var node = new CompositeSpecimenBuilder(
         new DelegatingSpecimenBuilder(),
         SpecimenBuilderNodeFactory.CreateComposer<FieldHolder<short>>(),
         SpecimenBuilderNodeFactory.CreateComposer<PropertyHolder<int>>(),
         SpecimenBuilderNodeFactory.CreateComposer<FieldHolder<short>>(),
         new DelegatingSpecimenBuilder());
     var sut = new CompositeNodeComposer<FieldHolder<short>>(node);
     // Exercise system
     var actual = sut.Without(x => x.Field);
     // Verify outcome
     var expected = new CompositeNodeComposer<FieldHolder<short>>(
         new CompositeSpecimenBuilder(
             new DelegatingSpecimenBuilder(),
             (ISpecimenBuilder)SpecimenBuilderNodeFactory.CreateComposer<FieldHolder<short>>().Without(x => x.Field),
             SpecimenBuilderNodeFactory.CreateComposer<PropertyHolder<int>>(),
             (ISpecimenBuilder)SpecimenBuilderNodeFactory.CreateComposer<FieldHolder<short>>().Without(x => x.Field),
             new DelegatingSpecimenBuilder()));
     var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual);
     Assert.True(expected.GraphEquals(n, new NodeComparer()));
     // Teardown
 }