public void CreateInvokesActionWithCreatedSpecimenOnSutWithCommand() { // Arrange var expectedSpecimen = new DateTime(2010, 4, 26); var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedSpecimen }; var expectedContext = new DelegatingSpecimenContext(); var verified = false; var mock = new DelegatingSpecimenCommand { OnExecute = (s, c) => verified = expectedSpecimen.Equals(s) && c == expectedContext }; var sut = new Postprocessor <DateTime>(builder, mock); // Act var dummyRequest = new object(); sut.Create(dummyRequest, expectedContext); // Assert Assert.True(verified, "Mock verified"); }
public void CreateDoesNotInvokeActionWhenSpecificationIsFalse() { // Arrange var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => new object() }; var verified = false; var mock = new DelegatingSpecimenCommand { OnExecute = (s, c) => verified = true }; var spec = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => false }; var sut = new Postprocessor <object>(builder, mock, spec); // Act var dummyRequest = new object(); var dummyContainer = new DelegatingSpecimenContext(); sut.Create(dummyRequest, dummyContainer); // Assert Assert.False(verified, "Mock invoked"); }
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 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 CreateReturnsCorrectResult() { // Fixture setup var expectedResult = new object(); var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedResult }; Action <object> dummyAction = s => { }; var sut = new Postprocessor(builder, dummyAction); // 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 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 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 CreateInvokesActionWithCreatedSpecimenOnSutWithSingleAction() { // Fixture setup var expectedSpecimen = new DateTime(2010, 4, 26); var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedSpecimen }; var verified = false; Action <DateTime> mock = s => verified = s == expectedSpecimen; var sut = new Postprocessor <DateTime>(builder, mock); // Exercise system var dummyRequest = new object(); var dummyContainer = new DelegatingSpecimenContext(); sut.Create(dummyRequest, dummyContainer); // Verify outcome Assert.True(verified, "Mock verified"); // Teardown }
public void CreateInvokesActionWithCreatedSpecimen() { // Arrange 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); // 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 }
public void CreateDoesNotInvokeActionWhenSpecificationIsFalse() { // Fixture setup var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => new object() }; var mockInvoked = false; Action <object, ISpecimenContext> mock = (s, c) => mockInvoked = true; var spec = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => false }; var sut = new Postprocessor <object>(builder, mock, spec); // Exercise system var dummyRequest = new object(); var dummyContainer = new DelegatingSpecimenContext(); sut.Create(dummyRequest, dummyContainer); // Verify outcome Assert.False(mockInvoked, "Mock invoked"); // Teardown }
public void CreateReturnsCorrectResult() { // Fixture setup var expectedResult = new object(); var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedResult }; Action<object> dummyAction = s => { }; var sut = new Postprocessor(builder, dummyAction); // 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 CreateInvokesActionWithCreatedSpecimen() { // Fixture setup var expectedSpecimen = new object(); var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedSpecimen }; var verified = false; Action<object> mock = s => verified = s == expectedSpecimen; 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 }
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() { // 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 CreateDoesNotInvokeActionWhenSpecificationIsFalse() { // Fixture setup var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => new object() }; var verified = false; var mock = new DelegatingSpecimenCommand { OnExecute = (s, c) => verified = true }; var spec = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => false }; var sut = new Postprocessor<object>(builder, mock, spec); // Exercise system var dummyRequest = new object(); var dummyContainer = new DelegatingSpecimenContext(); sut.Create(dummyRequest, dummyContainer); // Verify outcome Assert.False(verified, "Mock invoked"); // Teardown }
public void CreateInvokesActionWithCreatedSpecimenOnSutWithCommand() { // Fixture setup var expectedSpecimen = new DateTime(2010, 4, 26); var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedSpecimen }; var expectedContext = new DelegatingSpecimenContext(); var verified = false; var mock = new DelegatingSpecimenCommand { OnExecute = (s, c) => verified = expectedSpecimen.Equals(s) && c == expectedContext }; var sut = new Postprocessor<DateTime>(builder, mock); // Exercise system var dummyRequest = new object(); sut.Create(dummyRequest, expectedContext); // Verify outcome Assert.True(verified, "Mock verified"); // Teardown }
public void CreateThrowsWhenBuilderReturnsIncompatibleTypeOnSutWithDoubleAction() { // 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 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 }