public void CreateWillInvokeBuilderWithCorrectContainer()
        {
            // Fixture setup
            var expectedContainer = new DelegatingSpecimenContext();

            var mockVerified = false;
            var builderMock = new DelegatingSpecimenBuilder();
            builderMock.OnCreate = (r, c) =>
                {
                    Assert.Equal(expectedContainer, c);
                    mockVerified = true;
                    return new object();
                };

            var sut = new CompositeSpecimenBuilder(builderMock);
            // Exercise system
            var dummyRequest = new object();
            sut.Create(dummyRequest, expectedContainer);
            // Verify outcome
            Assert.True(mockVerified, "Mock verification");
            // Teardown
        }
 public void CreateWillReturnFirstSpecimenResultFromBuilders()
 {
     // Fixture setup
     var expectedResult = new object();
     var builders = new ISpecimenBuilder[]
     {
         new DelegatingSpecimenBuilder { OnCreate = (r, c) => new NoSpecimen() },
         new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedResult },
         new DelegatingSpecimenBuilder { OnCreate = (r, c) => new object() }
     };
     var sut = new CompositeSpecimenBuilder(builders);
     // Exercise system
     var anonymousRequest = new object();
     var dummyContainer = new DelegatingSpecimenContext();
     var result = sut.Create(anonymousRequest, dummyContainer);
     // Verify outcome
     Assert.Equal(expectedResult, result);
     // Teardown
 }
        public void CreateWillReturnNoSpecimenIfAllBuildersReturnNoSpecimen()
        {
            // Fixture setup
            var builders = new ISpecimenBuilder[]
            {
                new DelegatingSpecimenBuilder { OnCreate = (r, c) => new NoSpecimen() },
                new DelegatingSpecimenBuilder { OnCreate = (r, c) => new NoSpecimen() },
                new DelegatingSpecimenBuilder { OnCreate = (r, c) => new NoSpecimen() }
            };
            var sut = new CompositeSpecimenBuilder(builders);
            // Exercise system
            var anonymousRequest = new object();
            var dummyContainer = new DelegatingSpecimenContext();
            var result = sut.Create(anonymousRequest, dummyContainer);
            // Verify outcome
#pragma warning disable 618
            var expected = new NoSpecimen(anonymousRequest);
#pragma warning restore 618
            Assert.Equal(expected, result);
            // Teardown
        }
 public void CreateWillReturnNullIfAllBuildersReturnNull()
 {
     // Fixture setup
     var builders = new ISpecimenBuilder[]
     {
         new DelegatingSpecimenBuilder { OnCreate = (r, c) => null },
         new DelegatingSpecimenBuilder { OnCreate = (r, c) => null },
         new DelegatingSpecimenBuilder { OnCreate = (r, c) => null }
     };
     var sut = new CompositeSpecimenBuilder(builders);
     // Exercise system
     var anonymousRequest = new object();
     var dummyContainer = new DelegatingSpecimenContainer();
     var result = sut.Create(anonymousRequest, dummyContainer);
     // Verify outcome
     Assert.IsNull(result, "Create");
     // Teardown
 }