public void CreateWillInvokeBuilderWithCorrectContainer() { // Arrange var expectedContainer = new DelegatingSpecimenContext(); var mockVerified = false; var builderMock = new DelegatingSpecimenBuilder(); builderMock.OnCreate = (r, c) => { if (expectedContainer != c) { throw new ArgumentException("Invalid context"); } mockVerified = true; return(new object()); }; var sut = new CompositeSpecimenBuilder(builderMock); // Act var dummyRequest = new object(); sut.Create(dummyRequest, expectedContainer); // Assert Assert.True(mockVerified, "Mock verification"); }
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 var expected = new NoSpecimen(anonymousRequest); Assert.Equal(expected, result); // Teardown }
public void CreateWillReturnNoSpecimenIfAllBuildersReturnNoSpecimen() { // Arrange 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); // Act var anonymousRequest = new object(); var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(anonymousRequest, dummyContainer); // Assert var expected = new NoSpecimen(); Assert.Equal(expected, result); }
public void CreateWillReturnFirstNonNoSpecimenResultFromBuilders() { // Fixture setup var builders = new ISpecimenBuilder[] { new DelegatingSpecimenBuilder { OnCreate = (r, c) => new NoSpecimen() }, new DelegatingSpecimenBuilder { OnCreate = (r, c) => null }, new DelegatingSpecimenBuilder { OnCreate = (r, c) => new object() } }; var sut = new CompositeSpecimenBuilder(builders); // Exercise system var anonymousRequest = new object(); var dummycontext = new DelegatingSpecimenContext(); var result = sut.Create(anonymousRequest, dummycontext); // Verify outcome Assert.Null(result); // Teardown }
public void CreateWillInvokeBuilderWithCorrectRequest() { // Fixture setup var expectedRequest = new object(); var mockVerified = false; var builderMock = new DelegatingSpecimenBuilder(); builderMock.OnCreate = (r, c) => { if (expectedRequest != r) { throw new ArgumentException("Invalid context"); } mockVerified = true; return(new object()); }; var sut = new CompositeSpecimenBuilder(builderMock); // Exercise system var dummyContext = new DelegatingSpecimenContext(); sut.Create(expectedRequest, dummyContext); // Verify outcome Assert.True(mockVerified); // 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 }
public void CreateWillReturnFirstNonNullResultFromBuilders() { // Fixture setup var expectedResult = new object(); var builders = new ISpecimenBuilder[] { new DelegatingSpecimenBuilder { OnCreate = (r, c) => null }, 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 DelegatingSpecimenContainer(); var result = sut.Create(anonymousRequest, dummyContainer); // Verify outcome Assert.AreEqual(expectedResult, result, "Create"); // Teardown }
public void CreateWillInvokeBuilderWithCorrectRequest() { // Arrange var expectedRequest = new object(); var mockVerified = false; var builderMock = new DelegatingSpecimenBuilder(); builderMock.OnCreate = (r, c) => { Assert.Equal(expectedRequest, r); mockVerified = true; return(new object()); }; var sut = new CompositeSpecimenBuilder(builderMock); // Act var dummyContainer = new DelegatingSpecimenContext(); sut.Create(expectedRequest, dummyContainer); // Assert Assert.True(mockVerified, "Mock verification"); }
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 CreateWillReturnFirstNonNoSpecimenResultFromBuilders() { // Arrange var builders = new ISpecimenBuilder[] { new DelegatingSpecimenBuilder { OnCreate = (r, c) => new NoSpecimen() }, new DelegatingSpecimenBuilder { OnCreate = (r, c) => null }, new DelegatingSpecimenBuilder { OnCreate = (r, c) => new object() } }; var sut = new CompositeSpecimenBuilder(builders); // Act var anonymousRequest = new object(); var dummycontext = new DelegatingSpecimenContext(); var result = sut.Create(anonymousRequest, dummycontext); // Assert Assert.Null(result); }