public void CreateThrowsWhenBuilderReturnsIncompatibleTypeOnSutWithDoubleAction() { // Arrange var nonInt = "Anonymous variable"; var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => nonInt }; var dummyCommand = new DelegatingSpecimenCommand(); var sut = new Postprocessor <int>(builder, dummyCommand); // Act & assert var dummyRequest = new object(); var dummyContainer = new DelegatingSpecimenContext(); Assert.Throws <InvalidOperationException>(() => sut.Create(dummyRequest, dummyContainer)); }
public void ActionIsNotNullWhenConstructedWithFullConstructor() { // Arrange var dummyBuilder = new DelegatingSpecimenBuilder(); var dummyCommand = new DelegatingSpecimenCommand(); var dummySpecification = new DelegatingRequestSpecification(); var sut = new Postprocessor <object>( dummyBuilder, dummyCommand, dummySpecification); // Act var actual = sut.Action; // Assert Assert.NotNull(actual); }
public void SpecificationIsCorrectWhenConstructedWithFullConstructor() { // Arrange var dummyBuilder = new DelegatingSpecimenBuilder(); var dummyCommand = new DelegatingSpecimenCommand(); var expected = new DelegatingRequestSpecification(); var sut = new Postprocessor <object>( dummyBuilder, dummyCommand, expected); // Act var actual = sut.Specification; // Assert Assert.Equal(expected, actual); }
public void CreateReturnsCorrectResultWhenBuilderReturnsNoSpecimen() { // Arrange var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => new NoSpecimen() }; var dummyCommand = new DelegatingSpecimenCommand(); var sut = new Postprocessor <int>(builder, dummyCommand); // Act var dummyRequest = new object(); var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(dummyRequest, dummyContainer); // Assert Assert.IsAssignableFrom <NoSpecimen>(result); }
public void CreateReturnsCorrectResultOnSutWithDoubleAction() { // Arrange var expectedResult = 1m; var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedResult }; var dummyCommand = new DelegatingSpecimenCommand(); var sut = new Postprocessor <decimal>(builder, dummyCommand); // Act var dummyRequest = new object(); var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(dummyRequest, dummyContainer); // Assert Assert.Equal(expectedResult, result); }
public void CreateThrowsWhenBuilderReturnsIncompatibleTypeOnSutWithCommand() { // Fixture setup var nonInt = "Anonymous variable"; var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => nonInt }; var dummyCommand = new DelegatingSpecimenCommand(); var sut = new Postprocessor <int>(builder, dummyCommand); // Exercise system and verify outcome var dummyRequest = new object(); var dummyContainer = new DelegatingSpecimenContext(); Assert.Throws <InvalidOperationException>(() => sut.Create(dummyRequest, dummyContainer)); // Teardown }
public void ActionIsNotNullWhenConstructedWithFullConstructor() { // Fixture setup var dummyBuilder = new DelegatingSpecimenBuilder(); var dummyCommand = new DelegatingSpecimenCommand(); var dummySpecification = new DelegatingRequestSpecification(); var sut = new Postprocessor <object>( dummyBuilder, dummyCommand, dummySpecification); // Exercise system var actual = sut.Action; // Verify outcome Assert.NotNull(actual); // Teardown }
public void SpecificationIsCorrectWhenConstructedWithFullConstructor() { // Fixture setup var dummyBuilder = new DelegatingSpecimenBuilder(); var dummyCommand = new DelegatingSpecimenCommand(); var expected = new DelegatingRequestSpecification(); var sut = new Postprocessor <object>( dummyBuilder, dummyCommand, expected); // Exercise system var actual = sut.Specification; // Verify outcome Assert.Equal(expected, actual); // Teardown }
public void CreateReturnsCorrectResultOnSutWithDoubleAction() { // Fixture setup var expectedResult = 1m; var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedResult }; var dummyCommand = new DelegatingSpecimenCommand(); var sut = new Postprocessor <decimal>(builder, dummyCommand); // Exercise system var dummyRequest = new object(); var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(dummyRequest, dummyContainer); // Verify outcome Assert.Equal(expectedResult, result); // Teardown }
public void CreateReturnsCorrectResultWhenBuilderReturnsNoSpecimen() { // Fixture setup var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => new NoSpecimen() }; var dummyCommand = new DelegatingSpecimenCommand(); var sut = new Postprocessor <int>(builder, dummyCommand); // Exercise system var dummyRequest = new object(); var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(dummyRequest, dummyContainer); // Verify outcome Assert.IsAssignableFrom <NoSpecimen>(result); // Teardown }
public void CreateInvokesDecoratedBuilderWithCorrectParametersOnSutWithDoubleAction() { // Arrange var expectedRequest = new object(); var expectedContainer = new DelegatingSpecimenContext(); var verified = false; var builderMock = new DelegatingSpecimenBuilder { OnCreate = (r, c) => verified = r == expectedRequest && c == expectedContainer }; var dummyCommand = new DelegatingSpecimenCommand(); var sut = new Postprocessor <bool>(builderMock, dummyCommand); // Act sut.Create(expectedRequest, expectedContainer); // Assert Assert.True(verified, "Mock verified"); }
public void ComposeReturnsCorrectResult() { // Arrange var dummyBuilder = new DelegatingSpecimenBuilder(); var dummyCommand = new DelegatingSpecimenCommand(); var sut = new Postprocessor <object>(dummyBuilder, dummyCommand); // Act var expectedBuilders = new[] { new DelegatingSpecimenBuilder(), new DelegatingSpecimenBuilder(), new DelegatingSpecimenBuilder() }; var actual = sut.Compose(expectedBuilders); // Assert var pp = Assert.IsAssignableFrom <Postprocessor <object> >(actual); var composite = Assert.IsAssignableFrom <CompositeSpecimenBuilder>(pp.Builder); Assert.True(expectedBuilders.SequenceEqual(composite)); }
public void CreateInvokesDecoratedBuilderWithCorrectParametersOnSutWithCommand() { // Fixture setup var expectedRequest = new object(); var expectedContainer = new DelegatingSpecimenContext(); var verified = false; var builderMock = new DelegatingSpecimenBuilder { OnCreate = (r, c) => verified = r == expectedRequest && c == expectedContainer }; var dummyCommand = new DelegatingSpecimenCommand(); var sut = new Postprocessor <bool>(builderMock, dummyCommand); // Exercise system sut.Create(expectedRequest, expectedContainer); // Verify outcome Assert.True(verified, "Mock verified"); // Teardown }
public void ComposeReturnsCorrectResult() { // Fixture setup var dummyBuilder = new DelegatingSpecimenBuilder(); var dummyCommand = new DelegatingSpecimenCommand(); var sut = new Postprocessor <object>(dummyBuilder, dummyCommand); // Exercise system var expectedBuilders = new[] { new DelegatingSpecimenBuilder(), new DelegatingSpecimenBuilder(), new DelegatingSpecimenBuilder() }; var actual = sut.Compose(expectedBuilders); // Verify outcome var pp = Assert.IsAssignableFrom <Postprocessor <object> >(actual); var composite = Assert.IsAssignableFrom <CompositeSpecimenBuilder>(pp.Builder); Assert.True(expectedBuilders.SequenceEqual(composite)); // Teardown }
public void CreateInvokesActionWithCreatedSpecimenOnSutWithSingleAction() { // Arrange var expectedSpecimen = new DateTime(2010, 4, 26); var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedSpecimen }; var verified = false; var mock = new DelegatingSpecimenCommand { OnExecute = (s, c) => verified = expectedSpecimen.Equals(s) }; var sut = new Postprocessor <DateTime>(builder, mock); // Act var dummyRequest = new object(); var dummyContainer = new DelegatingSpecimenContext(); sut.Create(dummyRequest, dummyContainer); // Assert Assert.True(verified, "Mock verified"); }
public void CreateInvokesActionWithCreatedSpecimen() { // Fixture setup var expectedSpecimen = new object(); var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedSpecimen }; var verified = false; var mock = new DelegatingSpecimenCommand { OnExecute = (s, c) => verified = expectedSpecimen.Equals(s) }; var sut = new Postprocessor(builder, mock); // Exercise system var dummyRequest = new object(); var dummyContainer = new DelegatingSpecimenContext(); sut.Create(dummyRequest, dummyContainer); // Verify outcome Assert.True(verified, "Mock verified"); // Teardown }