public void OmitAutoPropertiesAfterAddingAutoPropertiesReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer <Version>(); // Exercise system var actual = sut.WithAutoProperties().OmitAutoProperties(); // Verify outcome var expected = new NodeComposer <Version>( new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new Postprocessor( new NoSpecimenOutputGuard( new MethodInvoker( new ModestConstructorQuery()), new InverseRequestSpecification( new SeedRequestSpecification( typeof(Version)))), new AutoPropertiesCommand(typeof(Version)), new FalseRequestSpecification()), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(Version)), new ExactTypeSpecification(typeof(Version))))); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void WithoutReturnsCorrectResult() { // Arrange var sut = SpecimenBuilderNodeFactory.CreateComposer <FieldHolder <short> >(); var fi = typeof(FieldHolder <short>).GetField("Field"); // Act var actual = sut.Without(x => x.Field); // Assert var expected = new NodeComposer <FieldHolder <short> >( new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new Postprocessor( new NoSpecimenOutputGuard( new MethodInvoker( new ModestConstructorQuery()), new InverseRequestSpecification( new SeedRequestSpecification( typeof(FieldHolder <short>)))), new AutoPropertiesCommand( typeof(FieldHolder <short>), new InverseRequestSpecification( new EqualRequestSpecification( fi, new MemberInfoEqualityComparer()))), new FalseRequestSpecification()), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(FieldHolder <short>)), new ExactTypeSpecification(typeof(FieldHolder <short>))))); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); }
public void SecondDoReturnsCorrectResult() { // Arrange var sut = SpecimenBuilderNodeFactory.CreateComposer <PropertyHolder <string> >(); Action <PropertyHolder <string> > dummy = _ => { }; Action <PropertyHolder <string> > a = ph => ph.Property = ""; // Act var actual = sut.Do(dummy).Do(a); // Assert var expected = new NodeComposer <PropertyHolder <string> >( new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new Postprocessor( new Postprocessor( new NoSpecimenOutputGuard( new MethodInvoker( new ModestConstructorQuery()), new InverseRequestSpecification( new SeedRequestSpecification( typeof(PropertyHolder <string>)))), new ActionSpecimenCommand <PropertyHolder <string> >(dummy)), new ActionSpecimenCommand <PropertyHolder <string> >(a)), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(PropertyHolder <string>)), new ExactTypeSpecification(typeof(PropertyHolder <string>))))); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); }
public void WithAnonymousValueReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer <PropertyHolder <int> >(); // Exercise system var actual = sut.With(x => x.Property); // Verify outcome var expected = new NodeComposer <PropertyHolder <int> >( new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new Postprocessor <PropertyHolder <int> >( new NoSpecimenOutputGuard( new MethodInvoker( new ModestConstructorQuery()), new InverseRequestSpecification( new SeedRequestSpecification( typeof(PropertyHolder <int>)))), new BindingCommand <PropertyHolder <int>, int>(x => x.Property), new OrRequestSpecification( new SeedRequestSpecification(typeof(PropertyHolder <int>)), new ExactTypeSpecification(typeof(PropertyHolder <int>)))), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(PropertyHolder <int>)), new ExactTypeSpecification(typeof(PropertyHolder <int>))))); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void TogglingAutoPropertiesOnAndOffReturnsCorrectResult() { // Arrange var sut = SpecimenBuilderNodeFactory.CreateComposer <Version>(); // Act var actual = sut.WithAutoProperties(true).WithAutoProperties(false); // Assert var expected = new NodeComposer <Version>( new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new Postprocessor( new NoSpecimenOutputGuard( new MethodInvoker( new ModestConstructorQuery()), new InverseRequestSpecification( new SeedRequestSpecification( typeof(Version)))), new AutoPropertiesCommand(typeof(Version)), new FalseRequestSpecification()), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(Version)), new ExactTypeSpecification(typeof(Version))))); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); }
public void DoReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer <AppDomainSetup>(); Action <AppDomainSetup> a = ads => ads.DisallowApplicationBaseProbing = false; // Exercise system var actual = sut.Do(a); // Verify outcome var expected = new NodeComposer <AppDomainSetup>( new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new Postprocessor <AppDomainSetup>( new NoSpecimenOutputGuard( new MethodInvoker( new ModestConstructorQuery()), new InverseRequestSpecification( new SeedRequestSpecification( typeof(AppDomainSetup)))), new ActionSpecimenCommand <AppDomainSetup>(a)), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(AppDomainSetup)), new ExactTypeSpecification(typeof(AppDomainSetup))))); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void WithAutoPropertiesTrueFollowedByFromFactoryReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer <PropertyHolder <string> >(); Func <PropertyHolder <string> > f = () => new PropertyHolder <string>(); // Exercise system var actual = sut.WithAutoProperties(true).FromFactory(f); // Verify outcome var expected = new NodeComposer <PropertyHolder <string> >( new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new Postprocessor <PropertyHolder <string> >( new NoSpecimenOutputGuard( new SpecimenFactory <PropertyHolder <string> >(f), new InverseRequestSpecification( new SeedRequestSpecification( typeof(PropertyHolder <string>)))), new AutoPropertiesCommand <PropertyHolder <string> >(), new OrRequestSpecification( new SeedRequestSpecification(typeof(PropertyHolder <string>)), new ExactTypeSpecification(typeof(PropertyHolder <string>)))), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(PropertyHolder <string>)), new ExactTypeSpecification(typeof(PropertyHolder <string>))))); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void WithoutReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer <FieldHolder <short> >(); var fi = typeof(FieldHolder <short>).GetField("Field"); // Exercise system var actual = sut.Without(x => x.Field); // Verify outcome var expected = new NodeComposer <FieldHolder <short> >( new CompositeSpecimenBuilder( new Omitter( new EqualRequestSpecification( fi, new MemberInfoEqualityComparer())), new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new NoSpecimenOutputGuard( new MethodInvoker( new ModestConstructorQuery()), new InverseRequestSpecification( new SeedRequestSpecification( typeof(FieldHolder <short>)))), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(FieldHolder <short>)), new ExactTypeSpecification(typeof(FieldHolder <short>)))))); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void WithAutoPropertiesTrueFollowedByDoReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer <PropertyHolder <int> >(); Action <PropertyHolder <int> > a = ph => ph.Property = 42; // Exercise system var actual = sut.WithAutoProperties(true).Do(a); // Verify outcome var expected = new NodeComposer <PropertyHolder <int> >( new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new Postprocessor <PropertyHolder <int> >( new Postprocessor <PropertyHolder <int> >( new NoSpecimenOutputGuard( new MethodInvoker( new ModestConstructorQuery()), new InverseRequestSpecification( new SeedRequestSpecification( typeof(PropertyHolder <int>)))), new ActionSpecimenCommand <PropertyHolder <int> >(a)), new AutoPropertiesCommand <PropertyHolder <int> >(), new OrRequestSpecification( new SeedRequestSpecification(typeof(PropertyHolder <int>)), new ExactTypeSpecification(typeof(PropertyHolder <int>)))), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(PropertyHolder <int>)), new ExactTypeSpecification(typeof(PropertyHolder <int>))))); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void DoReturnsCorrectResult() { // Arrange var sut = SpecimenBuilderNodeFactory.CreateComposer <ConcreteType>(); Action <ConcreteType> a = ads => ads.Property1 = 42; // Act var actual = sut.Do(a); // Assert var expected = new NodeComposer <ConcreteType>( new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new Postprocessor( new NoSpecimenOutputGuard( new MethodInvoker( new ModestConstructorQuery()), new InverseRequestSpecification( new SeedRequestSpecification( typeof(ConcreteType)))), new ActionSpecimenCommand <ConcreteType>(a)), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(ConcreteType)), new ExactTypeSpecification(typeof(ConcreteType))))); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); }
public void SuccessiveWithValueReturnsCorrectResult( string value1, int value2) { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer <DoublePropertyHolder <string, int> >(); var pi1 = typeof(DoublePropertyHolder <string, int>).GetProperty("Property1"); var pi2 = typeof(DoublePropertyHolder <string, int>).GetProperty("Property2"); // Exercise system var actual = sut .With(x => x.Property1, value1) .With(x => x.Property2, value2); // Verify outcome var expected = new NodeComposer <DoublePropertyHolder <string, int> >( new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new Postprocessor( new Postprocessor( new Postprocessor( new NoSpecimenOutputGuard( new MethodInvoker( new ModestConstructorQuery()), new InverseRequestSpecification( new SeedRequestSpecification( typeof(DoublePropertyHolder <string, int>)))), new AutoPropertiesCommand( typeof(DoublePropertyHolder <string, int>), new AndRequestSpecification( new InverseRequestSpecification( new EqualRequestSpecification( pi1, new MemberInfoEqualityComparer())), new InverseRequestSpecification( new EqualRequestSpecification( pi2, new MemberInfoEqualityComparer())))), new FalseRequestSpecification()), new BindingCommand <DoublePropertyHolder <string, int>, string>(x => x.Property1, value1), new OrRequestSpecification( new SeedRequestSpecification(typeof(DoublePropertyHolder <string, int>)), new ExactTypeSpecification(typeof(DoublePropertyHolder <string, int>)))), new BindingCommand <DoublePropertyHolder <string, int>, int>(x => x.Property2, value2), new OrRequestSpecification( new SeedRequestSpecification(typeof(DoublePropertyHolder <string, int>)), new ExactTypeSpecification(typeof(DoublePropertyHolder <string, int>)))), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(DoublePropertyHolder <string, int>)), new ExactTypeSpecification(typeof(DoublePropertyHolder <string, int>))))); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void SutIsCorrectInitialGraph() { // Arrange var sut = SpecimenBuilderNodeFactory.CreateComposer <int>(); // Act // Assert var factory = new MethodInvoker(new ModestConstructorQuery()); var expected = new NodeComposer <int>( SpecimenBuilderNodeFactory.CreateTypedNode(typeof(int), factory)); Assert.True(expected.GraphEquals(sut, new NodeComparer())); }
public void SutIsCorrectInitialGraph() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer <int>(); // Exercise system // Verify outcome var factory = new MethodInvoker(new ModestConstructorQuery()); var expected = new NodeComposer <int>( SpecimenBuilderNodeFactory.CreateTypedNode(typeof(int), factory)); Assert.True(expected.GraphEquals(sut, new NodeComparer())); // Teardown }
public void FromSpecimenBuilderFactoryReturnsCorrectResult() { // Arrange var sut = SpecimenBuilderNodeFactory.CreateComposer <Guid>(); var builder = new DelegatingSpecimenBuilder(); // Act var actual = sut.FromFactory(builder); // Assert var expected = new NodeComposer <Guid>( SpecimenBuilderNodeFactory.CreateTypedNode(typeof(Guid), builder)); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); }
public void CreateComposerReturnsCorrectResult() { // Arrange // Act NodeComposer <int> actual = SpecimenBuilderNodeFactory.CreateComposer <int>(); // Assert var expected = new NodeComposer <int>( SpecimenBuilderNodeFactory.CreateTypedNode( typeof(int), new MethodInvoker( new ModestConstructorQuery()))); Assert.True(expected.GraphEquals(actual, new NodeComparer())); }
public void CreateComposerReturnsCorrectResult() { // Fixture setup // Exercise system NodeComposer<int> actual = SpecimenBuilderNodeFactory.CreateComposer<int>(); // Verify outcome var expected = new NodeComposer<int>( SpecimenBuilderNodeFactory.CreateTypedNode( typeof(int), new MethodInvoker( new ModestConstructorQuery()))); Assert.True(expected.GraphEquals(actual, new NodeComparer())); // Teardown }
public void FromQuadrupleArgFuncReturnsCorrectResult() { // Arrange var sut = SpecimenBuilderNodeFactory.CreateComposer <Version>(); Func <int, int, int, int, Version> f = (mj, mn, b, r) => new Version(mj, mn, b, r); // Act var actual = sut.FromFactory(f); // Assert var factory = new SpecimenFactory <int, int, int, int, Version>(f); var expected = new NodeComposer <Version>( SpecimenBuilderNodeFactory.CreateTypedNode(typeof(Version), factory)); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); }
public void FromSingleArgFuncReturnsCorrectResult() { // Arrange var sut = SpecimenBuilderNodeFactory.CreateComposer <float>(); Func <int, float> f = i => i; // Act var actual = sut.FromFactory(f); // Assert var factory = new SpecimenFactory <int, float>(f); var expected = new NodeComposer <float>( SpecimenBuilderNodeFactory.CreateTypedNode(typeof(float), factory)); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); }
public void CreateComposerReturnsCorrectResult() { // Fixture setup // Exercise system NodeComposer <int> actual = SpecimenBuilderNodeFactory.CreateComposer <int>(); // Verify outcome var expected = new NodeComposer <int>( SpecimenBuilderNodeFactory.CreateTypedNode( typeof(int), new MethodInvoker( new ModestConstructorQuery()))); Assert.True(expected.GraphEquals(actual, new NodeComparer())); // Teardown }
public void FromSeedReturnsCorrectResult() { // Arrange var sut = SpecimenBuilderNodeFactory.CreateComposer <decimal>(); Func <decimal, decimal> f = d => d; // Act var actual = sut.FromSeed(f); // Assert var factory = new SeededFactory <decimal>(f); var expected = new NodeComposer <decimal>( SpecimenBuilderNodeFactory.CreateTypedNode(typeof(decimal), factory)); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); }
public void FromSpecimenBuilderFactoryReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer <Guid>(); var builder = new DelegatingSpecimenBuilder(); // Exercise system var actual = sut.FromFactory(builder); // Verify outcome var expected = new NodeComposer <Guid>( SpecimenBuilderNodeFactory.CreateTypedNode(typeof(Guid), builder)); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void FromTripleArgFuncReturnsCorrectResult() { // Arrange var sut = SpecimenBuilderNodeFactory.CreateComposer <decimal>(); Func <int, Guid, Version, decimal> f = (i, g, v) => i; // Act var actual = sut.FromFactory(f); // Assert var factory = new SpecimenFactory <int, Guid, Version, decimal>(f); var expected = new NodeComposer <decimal>( SpecimenBuilderNodeFactory.CreateTypedNode(typeof(decimal), factory)); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); }
public void FromSeedReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer <decimal>(); Func <decimal, decimal> f = d => d; // Exercise system var actual = sut.FromSeed(f); // Verify outcome var factory = new SeededFactory <decimal>(f); var expected = new NodeComposer <decimal>( SpecimenBuilderNodeFactory.CreateTypedNode(typeof(decimal), factory)); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void FromDoubleArgFuncReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer <string>(); Func <int, Version, string> f = (i, _) => i.ToString(); // Exercise system var actual = sut.FromFactory(f); // Verify outcome var factory = new SpecimenFactory <int, Version, string>(f); var expected = new NodeComposer <string>( SpecimenBuilderNodeFactory.CreateTypedNode(typeof(string), factory)); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void WithExplicitValueReturnsCorrectResult(string value) { // Arrange var sut = SpecimenBuilderNodeFactory.CreateComposer <PropertyHolder <string> >(); var pi = typeof(PropertyHolder <string>).GetProperty("Property"); // Act var actual = sut.With(x => x.Property, value); // Assert var expected = new NodeComposer <PropertyHolder <string> >( new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new Postprocessor( new Postprocessor( new NoSpecimenOutputGuard( new MethodInvoker( new ModestConstructorQuery()), new InverseRequestSpecification( new SeedRequestSpecification( typeof(PropertyHolder <string>)))), new AutoPropertiesCommand( typeof(PropertyHolder <string>), new InverseRequestSpecification( new EqualRequestSpecification( pi, new MemberInfoEqualityComparer()))), new FalseRequestSpecification() ), new BindingCommand <PropertyHolder <string>, string>(x => x.Property, value), new OrRequestSpecification( new SeedRequestSpecification(typeof(PropertyHolder <string>)), new ExactTypeSpecification(typeof(PropertyHolder <string>)))), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(PropertyHolder <string>)), new ExactTypeSpecification(typeof(PropertyHolder <string>))))); var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); }
public void FromSpecimenBuilderFactoryReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer<Guid>(); var builder = new DelegatingSpecimenBuilder(); // Exercise system var actual = sut.FromFactory(builder); // Verify outcome var expected = new NodeComposer<Guid>( SpecimenBuilderNodeFactory.CreateTypedNode(typeof(Guid), builder)); var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void FromNoArgFuncReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer<long>(); Func<long> f = () => 0; // Exercise system var actual = sut.FromFactory(f); // Verify outcome var factory = new SpecimenFactory<long>(f); var expected = new NodeComposer<long>( SpecimenBuilderNodeFactory.CreateTypedNode(typeof(long), factory)); var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void FromTripleArgFuncReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer<decimal>(); Func<int, Guid, Version, decimal> f = (i, g, v) => i; // Exercise system var actual = sut.FromFactory(f); // Verify outcome var factory = new SpecimenFactory<int, Guid, Version, decimal>(f); var expected = new NodeComposer<decimal>( SpecimenBuilderNodeFactory.CreateTypedNode(typeof(decimal), factory)); var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void FromQuadrupleArgFuncReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer<Version>(); Func<int, int, int, int, Version> f = (mj, mn, b, r) => new Version(mj, mn, b, r); // Exercise system var actual = sut.FromFactory(f); // Verify outcome var factory = new SpecimenFactory<int, int, int, int, Version>(f); var expected = new NodeComposer<Version>( SpecimenBuilderNodeFactory.CreateTypedNode(typeof(Version), factory)); var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void DoReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer<AppDomainSetup>(); Action<AppDomainSetup> a = ads => ads.DisallowApplicationBaseProbing = false; // Exercise system var actual = sut.Do(a); // Verify outcome var expected = new NodeComposer<AppDomainSetup>( new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new Postprocessor<AppDomainSetup>( new NoSpecimenOutputGuard( new MethodInvoker( new ModestConstructorQuery()), new InverseRequestSpecification( new SeedRequestSpecification( typeof(AppDomainSetup)))), a), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(AppDomainSetup)), new ExactTypeSpecification(typeof(AppDomainSetup))))); var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void WithAutoPropertiesTrueFollowedByDoReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer<PropertyHolder<int>>(); Action<PropertyHolder<int>> a = ph => ph.Property = 42; // Exercise system var actual = sut.WithAutoProperties(true).Do(a); // Verify outcome var expected = new NodeComposer<PropertyHolder<int>>( new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new Postprocessor<PropertyHolder<int>>( new Postprocessor<PropertyHolder<int>>( new NoSpecimenOutputGuard( new MethodInvoker( new ModestConstructorQuery()), new InverseRequestSpecification( new SeedRequestSpecification( typeof(PropertyHolder<int>)))), a), new AutoPropertiesCommand<PropertyHolder<int>>().Execute, new OrRequestSpecification( new SeedRequestSpecification(typeof(PropertyHolder<int>)), new ExactTypeSpecification(typeof(PropertyHolder<int>)))), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(PropertyHolder<int>)), new ExactTypeSpecification(typeof(PropertyHolder<int>))))); var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void FromSeedReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer<decimal>(); Func<decimal, decimal> f = d => d; // Exercise system var actual = sut.FromSeed(f); // Verify outcome var factory = new SeededFactory<decimal>(f); var expected = new NodeComposer<decimal>( SpecimenBuilderNodeFactory.CreateTypedNode(typeof(decimal), factory)); var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void WithAutoPropertiesTrueFollowedByFromFactoryReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer<PropertyHolder<string>>(); Func<PropertyHolder<string>> f = () => new PropertyHolder<string>(); // Exercise system var actual = sut.WithAutoProperties(true).FromFactory(f); // Verify outcome var expected = new NodeComposer<PropertyHolder<string>>( new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new Postprocessor<PropertyHolder<string>>( new NoSpecimenOutputGuard( new SpecimenFactory<PropertyHolder<string>>(f), new InverseRequestSpecification( new SeedRequestSpecification( typeof(PropertyHolder<string>)))), new AutoPropertiesCommand<PropertyHolder<string>>().Execute, new OrRequestSpecification( new SeedRequestSpecification(typeof(PropertyHolder<string>)), new ExactTypeSpecification(typeof(PropertyHolder<string>)))), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(PropertyHolder<string>)), new ExactTypeSpecification(typeof(PropertyHolder<string>))))); var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void WithoutReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer<FieldHolder<short>>(); var fi = typeof(FieldHolder<short>).GetField("Field"); // Exercise system var actual = sut.Without(x => x.Field); // Verify outcome var expected = new NodeComposer<FieldHolder<short>>( new CompositeSpecimenBuilder( new Omitter( new EqualRequestSpecification( fi, new MemberInfoEqualityComparer())), new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new NoSpecimenOutputGuard( new MethodInvoker( new ModestConstructorQuery()), new InverseRequestSpecification( new SeedRequestSpecification( typeof(FieldHolder<short>)))), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(FieldHolder<short>)), new ExactTypeSpecification(typeof(FieldHolder<short>)))))); var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void SuccessiveWithValueReturnsCorrectResult( string value1, int value2) { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer<DoublePropertyHolder<string, int>>(); var pi1 = typeof(DoublePropertyHolder<string, int>).GetProperty("Property1"); var pi2 = typeof(DoublePropertyHolder<string, int>).GetProperty("Property2"); // Exercise system var actual = sut .With(x => x.Property1, value1) .With(x => x.Property2, value2); // Verify outcome var expected = new NodeComposer<DoublePropertyHolder<string, int>>( new CompositeSpecimenBuilder( new Omitter( new EqualRequestSpecification( pi2, new MemberInfoEqualityComparer())), new CompositeSpecimenBuilder( new Omitter( new EqualRequestSpecification( pi1, new MemberInfoEqualityComparer())), new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new Postprocessor<DoublePropertyHolder<string, int>>( new Postprocessor<DoublePropertyHolder<string, int>>( new NoSpecimenOutputGuard( new MethodInvoker( new ModestConstructorQuery()), new InverseRequestSpecification( new SeedRequestSpecification( typeof(DoublePropertyHolder<string, int>)))), new BindingCommand<DoublePropertyHolder<string, int>, string>(x => x.Property1, value1).Execute, new OrRequestSpecification( new SeedRequestSpecification(typeof(DoublePropertyHolder<string, int>)), new ExactTypeSpecification(typeof(DoublePropertyHolder<string, int>)))), new BindingCommand<DoublePropertyHolder<string, int>, int>(x => x.Property2, value2).Execute, new OrRequestSpecification( new SeedRequestSpecification(typeof(DoublePropertyHolder<string, int>)), new ExactTypeSpecification(typeof(DoublePropertyHolder<string, int>)))), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(DoublePropertyHolder<string, int>)), new ExactTypeSpecification(typeof(DoublePropertyHolder<string, int>))))))); var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void WithAnonymousValueReturnsCorrectResult() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer<PropertyHolder<int>>(); // Exercise system var actual = sut.With(x => x.Property); // Verify outcome var expected = new NodeComposer<PropertyHolder<int>>( new FilteringSpecimenBuilder( new CompositeSpecimenBuilder( new Postprocessor<PropertyHolder<int>>( new NoSpecimenOutputGuard( new MethodInvoker( new ModestConstructorQuery()), new InverseRequestSpecification( new SeedRequestSpecification( typeof(PropertyHolder<int>)))), new BindingCommand<PropertyHolder<int>, int>(x => x.Property), new OrRequestSpecification( new SeedRequestSpecification(typeof(PropertyHolder<int>)), new ExactTypeSpecification(typeof(PropertyHolder<int>)))), new SeedIgnoringRelay()), new OrRequestSpecification( new SeedRequestSpecification(typeof(PropertyHolder<int>)), new ExactTypeSpecification(typeof(PropertyHolder<int>))))); var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual); Assert.True(expected.GraphEquals(n, new NodeComparer())); // Teardown }
public void SutIsCorrectInitialGraph() { // Fixture setup var sut = SpecimenBuilderNodeFactory.CreateComposer<int>(); // Exercise system // Verify outcome var factory = new MethodInvoker(new ModestConstructorQuery()); var expected = new NodeComposer<int>( SpecimenBuilderNodeFactory.CreateTypedNode(typeof(int), factory)); Assert.True(expected.GraphEquals(sut, new NodeComparer())); // Teardown }