コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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
        }
コード例 #7
0
        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
        }
コード例 #8
0
        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
        }
コード例 #9
0
        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
        }
コード例 #10
0
        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
        }
コード例 #11
0
        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");
        }
コード例 #12
0
        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));
        }
コード例 #13
0
        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
        }
コード例 #14
0
        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
        }
コード例 #15
0
        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");
        }
コード例 #16
0
        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
        }