public void SutIsCustomizationComposer()
 {
     // Fixture setup
     // Exercise system
     var sut = new CompositeComposer<object>();
     // Verify outcome
     Assert.IsAssignableFrom<ICustomizationComposer<object>>(sut);
     // Teardown
 }
 public void ComposersIsCorrectWhenInitializedWithEnumerable()
 {
     // Fixture setup
     var expectedComposers = Enumerable.Range(1, 3).Select(i => new DelegatingComposer<int>()).Cast<ICustomizationComposer<int>>().ToList();
     var sut = new CompositeComposer<int>(expectedComposers);
     // Exercise system
     var result = sut.Composers;
     // Verify outcome
     Assert.True(expectedComposers.SequenceEqual(result));
     // Teardown
 }
 public void DoReturnsCorrectResult()
 {
     // Fixture setup
     Action<object> expectedAction = s => { };
     var expectedComposers = Enumerable.Range(1, 3).Select(i => new DelegatingComposer<object>()).ToArray();
     var initialComposers = (from c in expectedComposers
                             select new DelegatingComposer
                             {
                                 OnDo = a => a == expectedAction ? c : new DelegatingComposer<object>()
                             }).ToArray();
     var sut = new CompositeComposer<object>(initialComposers);
     // Exercise system
     var result = sut.Do(expectedAction);
     // Verify outcome
     var composite = Assert.IsAssignableFrom<CompositePostprocessComposer<object>>(result);
     Assert.True(expectedComposers.SequenceEqual(composite.Composers));
     // Teardown
 }
 public void OmitAutoPropertiesReturnsCorrectResult()
 {
     // Fixture setup
     var expectedComposers = Enumerable.Range(1, 3).Select(i => new DelegatingComposer<object>()).ToArray();
     var initialComposers = (from c in expectedComposers
                             select new DelegatingComposer { OnOmitAutoProperties = () => c }).ToArray();
     var sut = new CompositeComposer<object>(initialComposers);
     // Exercise system
     var result = sut.OmitAutoProperties();
     // Verify outcome
     var composite = Assert.IsAssignableFrom<CompositePostprocessComposer<object>>(result);
     Assert.True(expectedComposers.SequenceEqual(composite.Composers));
     // Teardown
 }
 public void ComposeReturnsCorrectResult()
 {
     // Fixture setup
     var expectedBuilders = Enumerable.Range(1, 3).Select(i => new DelegatingSpecimenBuilder()).ToArray();
     var composers = (from b in expectedBuilders
                      select new DelegatingComposer { OnCompose = () => b }).ToArray();
     var sut = new CompositeComposer<object>(composers);
     // Exercise system
     var result = sut.Compose();
     // Verify outcome
     var composite = Assert.IsAssignableFrom<CompositeSpecimenBuilder>(result);
     Assert.True(expectedBuilders.SequenceEqual(composite));
     // Teardown
 }
 public void FromQuadrupleParameterFactoryReturnsCorrectResult()
 {
     // Fixture setup
     Func<object, object, object, object, object> expectedFactory = (x, y, z, æ) => new object();
     var expectedComposers = Enumerable.Range(1, 3).Select(i => new DelegatingComposer()).ToArray();
     var initialComposers = (from c in expectedComposers
                             select new DelegatingComposer
                             {
                                 OnFromOverloadeFactory = f => f.Equals(expectedFactory) ? c : new DelegatingComposer()
                             }).ToArray();
     var sut = new CompositeComposer<object>(initialComposers);
     // Exercise system
     var result = sut.FromFactory(expectedFactory);
     // Verify outcome
     var composite = Assert.IsAssignableFrom<CompositePostprocessComposer<object>>(result);
     Assert.True(expectedComposers.SequenceEqual(composite.Composers));
     // Teardown
 }
 public void FromBuilderFactoryReturnsCorrectResult()
 {
     // Fixture setup
     var expectedFactory = new DelegatingSpecimenBuilder();
     var expectedComposers = Enumerable.Range(1, 3).Select(i => new DelegatingComposer<Version>()).ToArray();
     var initialComposers = (from c in expectedComposers
                             select new DelegatingComposer<Version>
                             {
                                 OnFromBuilder = f => f == expectedFactory ? c : new DelegatingComposer<Version>()
                             }).ToArray();
     var sut = new CompositeComposer<Version>(initialComposers);
     // Exercise system
     var result = sut.FromFactory(expectedFactory);
     // Verify outcome
     var composite = Assert.IsAssignableFrom<CompositePostprocessComposer<Version>>(result);
     Assert.True(expectedComposers.SequenceEqual(composite.Composers));
     // Teardown
 }
 public void WithoutReturnsCorrectResult()
 {
     // Fixture setup
     Expression<Func<PropertyHolder<object>, object>> expectedExpression = x => x.Property;
     var expectedComposers = Enumerable.Range(1, 3).Select(i => new DelegatingComposer<PropertyHolder<object>>()).ToArray();
     var initialComposers = (from c in expectedComposers
                             select new DelegatingComposer<PropertyHolder<object>>
                             {
                                 OnWithout = f => f == expectedExpression ? c : new DelegatingComposer<PropertyHolder<object>>()
                             }).ToArray();
     var sut = new CompositeComposer<PropertyHolder<object>>(initialComposers);
     // Exercise system
     var result = sut.Without(expectedExpression);
     // Verify outcome
     var composite = Assert.IsAssignableFrom<CompositePostprocessComposer<PropertyHolder<object>>>(result);
     Assert.True(expectedComposers.SequenceEqual(composite.Composers));
     // Teardown
 }
Example #9
0
 public void CustomizeAndComposeComplexType()
 {
     // Fixture setup
     // Exercise system
     var result = new CompositeComposer<DoublePropertyHolder<int, decimal>>(
             new Composer<DoublePropertyHolder<int, decimal>>(),
             new NullComposer<DoublePropertyHolder<int, decimal>>(Scenario.CreateAutoPropertyBuilder)
             ).With(x => x.Property2, 8m).WithAutoProperties().CreateAnonymous();
     // Verify outcome
     Assert.Equal(1, result.Property1);
     Assert.Equal(8, result.Property2);
     // Teardown
 }