public void ExecutesEveryChildCommandWithCorrectSpecimen()
        {
            // Fixture setup
            var specimen = new object();
            var dummyContext = new DelegatingSpecimenContext();

            var command1Verified = false;
            var command1 = new DelegatingSpecimenCommand
                {
                    OnExecute = (req, ctx) =>
                        {
                            command1Verified = true;
                            Assert.Same(specimen, req);
                        }
                };

            var command2Verified = false;
            var command2 = new DelegatingSpecimenCommand
                {
                    OnExecute = (req, ctx) =>
                        {
                            command2Verified = true;
                            Assert.Same(specimen, req);
                        }
                };

            var sut = new CompositeSpecimenCommand(command1, command2);
            // Exercise system
            sut.Execute(specimen, dummyContext);
            // Verify outcome
            Assert.True(command1Verified);
            Assert.True(command2Verified);
            // Teardown
        }
 public void SutIsNode()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     var dummyCommand = new DelegatingSpecimenCommand();
     // Exercise system
     var sut = new Postprocessor<Version>(dummyBuilder, dummyCommand);
     // Verify outcome
     Assert.IsAssignableFrom<ISpecimenBuilderNode>(sut);
     // Teardown
 }
Ejemplo n.º 3
0
        public void SpecificationIsCorrectWhenConstructedFullyNonGenerically()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();
            var expected     = new DelegatingRequestSpecification();

            var sut = new Postprocessor(dummyBuilder, dummyCommand, expected);
            // Exercise system
            var actual = sut.Specification;

            // Verify outcome
            Assert.Equal(expected, actual);
            // Teardown
        }
Ejemplo n.º 4
0
        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
        }
Ejemplo n.º 5
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
        }
Ejemplo n.º 6
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
        }
Ejemplo n.º 7
0
        public void CommandIsCorrectWhenConstructedWithFullConstructor()
        {
            // Fixture setup
            var dummyBuilder       = new DelegatingSpecimenBuilder();
            var expected           = new DelegatingSpecimenCommand();
            var dummySpecification = new DelegatingRequestSpecification();

            var sut = new Postprocessor <object>(
                dummyBuilder,
                expected,
                dummySpecification);
            // Exercise system
            var actual = sut.Command;

            // Verify outcome
            Assert.Equal(expected, actual);
            // Teardown
        }
Ejemplo n.º 8
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
        }
Ejemplo n.º 9
0
        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
        }
Ejemplo n.º 10
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
        }
Ejemplo n.º 11
0
        public void CreateInvokesActionWithCreatedSpecimenOnSutWithSingleAction()
        {
            // Fixture setup
            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);
            // Exercise system
            var dummyRequest   = new object();
            var dummyContainer = new DelegatingSpecimenContext();

            sut.Create(dummyRequest, dummyContainer);
            // Verify outcome
            Assert.True(verified, "Mock verified");
            // Teardown
        }
        public void CommandIsCorrect()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var expected = new DelegatingSpecimenCommand();

            var sut = new Postprocessor<object>(dummyBuilder, expected);
            // Exercise system
            ISpecimenCommand actual = sut.Command;
            // Verify outcome
            Assert.Equal(expected, actual);
            // Teardown
        }
 public void ConstructFullWithNullSpecificationThrows()
 {
     var dummyBuilder = new DelegatingSpecimenBuilder();
     var dummyCommand = new DelegatingSpecimenCommand();
     Assert.Throws<ArgumentNullException>(() =>
         new Postprocessor<object>(
             dummyBuilder,
             dummyCommand,
             null));
 }
 public void ConstructFullWithNullBuilderThrows()
 {
     var dummyCommand = new DelegatingSpecimenCommand();
     var dummySpecification = new DelegatingRequestSpecification();
     Assert.Throws<ArgumentNullException>(() =>
         new Postprocessor<object>(
             null,
             dummyCommand,
             dummySpecification));
 }
        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 ComposePreservesSpecification()
 {
     // Fixture setup
     var expected = new DelegatingRequestSpecification();
     var dummyCommand = new DelegatingSpecimenCommand();
     var dummyBuilder = new DelegatingSpecimenBuilder();
     var sut = new Postprocessor<Version>(dummyBuilder, dummyCommand, expected);
     // Exercise system
     var actual = sut.Compose(new ISpecimenBuilder[0]);
     // Verify outcome
     var pp = Assert.IsAssignableFrom<Postprocessor<Version>>(actual);
     Assert.Equal(expected, pp.Specification);
     // 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 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 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
 }
        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
        }
Ejemplo n.º 25
0
        public void CommandIsCorrectWhenConstructedFullyNonGenerically()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var expected = new DelegatingSpecimenCommand();
            var dummySpecification = new DelegatingRequestSpecification();

            var sut = new Postprocessor(dummyBuilder, expected, dummySpecification);
            // Exercise system
            var actual = sut.Command;
            // Verify outcome
            Assert.Equal(expected, actual);
            // Teardown
        }
        public void SpecificationIsCorrectWhenConstructedWithMinimalConstructor()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();

            var sut = new Postprocessor<object>(dummyBuilder, dummyCommand);
            // Exercise system
            var actual = sut.Specification;
            // Verify outcome
            Assert.IsAssignableFrom<TrueRequestSpecification>(actual);
            // Teardown
        }
 public void SutYieldsInjectedBuilder()
 {
     // Fixture setup
     var expected = new DelegatingSpecimenBuilder();
     var dummyCommand = new DelegatingSpecimenCommand();
     var sut = new Postprocessor<object>(expected, dummyCommand);
     // Exercise system
     // Verify outcome
     Assert.Equal(expected, sut.Single());
     Assert.Equal(expected, ((System.Collections.IEnumerable)sut).Cast<object>().Single());
     // Teardown
 }
 public void ConstructMinimalWithNullBuilderThrows()
 {
     var dummyCommand = new DelegatingSpecimenCommand();
     Assert.Throws<ArgumentNullException>(() =>
         new Postprocessor<object>(null, dummyCommand));
 }
        public void BuilderIsCorrectWhenConstructedWithMinimalConstructor()
        {
            // Fixture setup
            var expected = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();

            var sut = new Postprocessor<object>(expected, dummyCommand);
            // Exercise system
            var actual = sut.Builder;
            // Verify outcome
            Assert.Equal(expected, actual);
            // Teardown
        }
 public void ComposeSingleItemReturnsCorrectResult()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     var dummyCommand = new DelegatingSpecimenCommand();
     var sut = new Postprocessor<object>(dummyBuilder, dummyCommand);
     // Exercise system
     var expected = new DelegatingSpecimenBuilder();
     var actual = sut.Compose(new[] { expected });
     // Verify outcome
     var pp = Assert.IsAssignableFrom<Postprocessor<object>>(actual);
     Assert.Equal(expected, pp.Builder);
     // Teardown
 }