Exemple #1
0
        public void ComposeSingleItemReturnsCorrectResult()
        {
            // Arrange
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut          = new OmitOnRecursionGuard(dummyBuilder);

            var expected = new DelegatingSpecimenBuilder();
            // Act
            var actual = sut.Compose(new[] { expected });
            // Assert
            var rg = Assert.IsAssignableFrom <OmitOnRecursionGuard>(actual);

            Assert.Equal(expected, rg.Builder);
        }
        public void ComposeSingleItemReturnsCorrectResult()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut          = new DisposableTracker(dummyBuilder);
            // Exercise system
            var expected = new DelegatingSpecimenBuilder();
            var actual   = sut.Compose(new[] { expected });
            // Verify outcome
            var dt = Assert.IsAssignableFrom <DisposableTracker>(actual);

            Assert.Equal(expected, dt.Builder);
            // Teardown
        }
Exemple #3
0
        public void ComposeSingleItemReturnsCorrectResult()
        {
            // Fixture setup
            var builder = new DelegatingSpecimenBuilder();
            var sut     = new TerminatingWithPathSpecimenBuilder(builder);
            // Exercise system
            var expected = new DelegatingSpecimenBuilder();
            var actual   = sut.Compose(new[] { expected });
            // Verify outcome
            var tw = Assert.IsAssignableFrom <TerminatingWithPathSpecimenBuilder>(actual);

            Assert.Equal(expected, tw.Builder);
            // Teardown
        }
        public void ComposeSingleItemReturnsCorrectResult()
        {
            // Arrange
            var dummyBuilder       = new DelegatingSpecimenBuilder();
            var dummySpecification = new DelegatingRequestSpecification();
            var sut = new FilteringSpecimenBuilder(dummyBuilder, dummySpecification);
            // Act
            var expected = new DelegatingSpecimenBuilder();
            var actual   = sut.Compose(new[] { expected });
            // Assert
            var f = Assert.IsAssignableFrom <FilteringSpecimenBuilder>(actual);

            Assert.Equal(expected, f.Builder);
        }
Exemple #5
0
        public void ComposeRetainsComparer()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var expected     = new DelegatingEqualityComparer();
            var sut          = new ThrowingRecursionGuard(dummyBuilder, expected);
            // Exercise system
            var actual = sut.Compose(new ISpecimenBuilder[0]);
            // Verify outcome
            var rg = Assert.IsAssignableFrom <ThrowingRecursionGuard>(actual);

            Assert.Equal(expected, rg.Comparer);
            // Teardown
        }
        public void HandleRecursiveRequestReturnsCorrectResult()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut          = new OmitOnRecursionGuard(dummyBuilder);
            // Exercise system
            var dummyRequest = new object();
            var actual       = sut.HandleRecursiveRequest(dummyRequest);
            // Verify outcome
            var expected = new OmitSpecimen();

            Assert.Equal(expected, actual);
            // Teardown
        }
        public void ActionIsCorrect()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            Action <object, ISpecimenContext> expectedAction = (s, c) => { };

            var sut = new Postprocessor <object>(dummyBuilder, expectedAction);
            // Exercise system
            Action <object, ISpecimenContext> result = sut.Action;

            // Verify outcome
            Assert.Equal(expectedAction, result);
            // Teardown
        }
Exemple #8
0
        public void SpecificationIsCorrect()
        {
            // Arrange
            var dummyBuilder = new DelegatingSpecimenBuilder();
            Action <object, ISpecimenContext> dummyAction = (s, c) => { };
            var expectedSpec = new DelegatingRequestSpecification();

            var sut = new Postprocessor <object>(dummyBuilder, dummyAction, expectedSpec);
            // Act
            IRequestSpecification result = sut.Specification;

            // Assert
            Assert.Equal(expectedSpec, result);
        }
Exemple #9
0
        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 SutYieldsCorrectSequence()
        {
            // Fixture setup
            var dummyWriter = TextWriter.Null;
            var expected    = new DelegatingSpecimenBuilder();
            var tracer      = new DelegatingTracingBuilder(expected);
            var sut         = new TraceWriter(dummyWriter, tracer);

            // Exercise system
            // Verify outcome
            Assert.Equal(expected, sut.Single());
            Assert.Equal(expected, ((System.Collections.IEnumerable)sut).Cast <object>().Single());
            // Teardown
        }
Exemple #11
0
        public void SpecificationIsCorrectWhenConstructedFullyNonGenerically()
        {
            // Arrange
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();
            var expected     = new DelegatingRequestSpecification();

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

            // Assert
            Assert.Equal(expected, actual);
        }
Exemple #12
0
        public void ComposePreservesAction()
        {
            // Fixture setup
            Action <Version, ISpecimenContext> expected = (x, y) => { };
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut          = new Postprocessor <Version>(dummyBuilder, expected);
            // Exercise system
            var actual = sut.Compose(new ISpecimenBuilder[0]);
            // Verify outcome
            var pp = Assert.IsAssignableFrom <Postprocessor <Version> >(actual);

            Assert.Equal(expected, pp.Action);
            // Teardown
        }
Exemple #13
0
        public void ComposePreservesCommand()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var expected     = new DelegatingSpecimenCommand();
            var sut          = new Postprocessor <object>(dummyBuilder, expected);
            // Exercise system
            var actual = sut.Compose(new ISpecimenBuilder[0]);
            // Verify outcome
            var pp = Assert.IsAssignableFrom <Postprocessor <object> >(actual);

            Assert.Equal(expected, pp.Command);
            // Teardown
        }
Exemple #14
0
        public void InitializeDoubleActionAndSpecificationWithNullActionThrows()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var dummySpec    = new DelegatingRequestSpecification();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  new Postprocessor <object>(
                                                      dummyBuilder,
                                                      (Action <object, ISpecimenContext>)null,
                                                      dummySpec));
            // Teardown
        }
Exemple #15
0
        public void ComposePreservesSpecification()
        {
            // Arrange
            var expected     = new DelegatingRequestSpecification();
            var dummyCommand = new DelegatingSpecimenCommand();
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut          = new Postprocessor(dummyBuilder, dummyCommand, expected);
            // Act
            var actual = sut.Compose(new ISpecimenBuilder[0]);
            // Assert
            var pp = Assert.IsAssignableFrom <Postprocessor>(actual);

            Assert.Equal(expected, pp.Specification);
        }
Exemple #16
0
        public void CreateThrowsWhenDecoratedBuilderReturnsNoSpecimen()
        {
            // Arrange
            var builder = new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => new NoSpecimen()
            };
            var sut = new NoSpecimenOutputGuard(builder);
            // Act & assert
            var dummyRequest = new object();
            var dummyContext = new DelegatingSpecimenContext();

            Assert.Throws <ObjectCreationException>(() =>
                                                    sut.Create(dummyRequest, dummyContext));
        }
        public void CommandIsCorrectWhenConstructedMinimallyNonGenerically()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var expected     = new DelegatingSpecimenCommand();

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

            // Verify outcome
            Assert.Equal(expected, actual);
            // Teardown
        }
        public void BuilderIsCorrect()
        {
            // Fixture setup
            var             expectedBuilder = new DelegatingSpecimenBuilder();
            Action <object> dummyAction     = s => { };

            var sut = new Postprocessor <object>(expectedBuilder, dummyAction);
            // Exercise system
            ISpecimenBuilder result = sut.Builder;

            // Verify outcome
            Assert.Equal(expectedBuilder, result);
            // Teardown
        }
        public void ComposeAddsReturnedObjectToDisposables()
        {
            // Arrange
            var dummy = new DelegatingSpecimenBuilder();
            var sut   = new DisposableTracker(dummy);
            // Act
            var dummies = new ISpecimenBuilder[0];
            var actual  = sut.Compose(dummies);

            // Assert
            Assert.True(
                sut.Disposables.Any(actual.Equals),
                "Returned value not added to disposables.");
        }
Exemple #20
0
        public void ActionIsNotNullWhenConstructedWithMinimalConstructor()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();

            var sut = new Postprocessor <object>(dummyBuilder, dummyCommand);
            // Exercise system
            var actual = sut.Action;

            // Verify outcome
            Assert.NotNull(actual);
            // Teardown
        }
Exemple #21
0
        public void ComposePreservesSpecification()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var expected     = new DelegatingRequestSpecification();
            var sut          = new FilteringSpecimenBuilder(dummyBuilder, expected);
            // Exercise system
            var actual = sut.Compose(new ISpecimenBuilder[0]);
            // Verify outcome
            var f = Assert.IsAssignableFrom <FilteringSpecimenBuilder>(actual);

            Assert.Equal(expected, f.Specification);
            // Teardown
        }
Exemple #22
0
        public void ComposeSingleItemReturnsCorrectResult()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut          = new ThrowingRecursionGuard(dummyBuilder);
            // Exercise system
            var expected = new DelegatingSpecimenBuilder();
            var actual   = sut.Compose(new[] { expected });
            // Verify outcome
            var rg = Assert.IsAssignableFrom <ThrowingRecursionGuard>(actual);

            Assert.Equal(expected, rg.Builder);
            // Teardown
        }
Exemple #23
0
        public void ThrowsAtRecursionPoint()
        {
            // Fixture setup
            var builder = new DelegatingSpecimenBuilder();

            builder.OnCreate = (r, c) => c.Resolve(r);
            var sut       = new ThrowingRecursionGuard(builder);
            var container = new DelegatingSpecimenContext();

            container.OnResolve = r => sut.Create(r, container); // Provoke recursion

            // Exercise system
            Assert.ThrowsAny <ObjectCreationException>(() => sut.Create(Guid.NewGuid(), container));
        }
Exemple #24
0
        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
        }
Exemple #25
0
        public void ComposeSingleItemReturnsCorrectResult()
        {
            // Arrange
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var dummyCommand = new DelegatingSpecimenCommand();
            var sut          = new Postprocessor(dummyBuilder, dummyCommand);
            // Act
            var expected = new DelegatingSpecimenBuilder();
            var actual   = sut.Compose(new[] { expected });
            // Assert
            var pp = Assert.IsAssignableFrom <Postprocessor>(actual);

            Assert.Equal(expected, pp.Builder);
        }
Exemple #26
0
        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
        }
        public void SpecificationIsCorrect()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            Action <object, ISpecimenContext> dummyAction = (s, c) => { };
            var expectedSpec = new DelegatingRequestSpecification();

            var sut = new Postprocessor <object>(dummyBuilder, dummyAction, expectedSpec);
            // Exercise system
            IRequestSpecification result = sut.Specification;

            // Verify outcome
            Assert.Equal(expectedSpec, result);
            // Teardown
        }
        public void BuilderIsCorrectWhenConstructedFullyNonGenerically()
        {
            // Fixture setup
            var expected           = new DelegatingSpecimenBuilder();
            var dummyCommand       = new DelegatingSpecimenCommand();
            var dummySpecification = new DelegatingRequestSpecification();

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

            // Verify outcome
            Assert.Equal(expected, actual);
            // Teardown
        }
        public void CreateThrowsWhenDecoratedBuilderReturnsNoSpecimen()
        {
            // Fixture setup
            var builder = new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => new NoSpecimen()
            };
            var sut = new NoSpecimenOutputGuard(builder);
            // Exercise system and verify outcome
            var dummyRequest = new object();
            var dummyContext = new DelegatingSpecimenContext();

            Assert.Throws <ObjectCreationException>(() =>
                                                    sut.Create(dummyRequest, dummyContext));
            // Teardown
        }
        public void ComposeSingleItemReturnsCorrectResult()
        {
            // Fixture setup
            var writer = TextWriter.Null;
            var tracer = new DelegatingTracingBuilder();
            var sut    = new TraceWriter(writer, tracer);
            // Exercise system
            var expected = new DelegatingSpecimenBuilder();
            var actual   = sut.Compose(new[] { expected });
            // Verify outcome
            var tw = Assert.IsAssignableFrom <TraceWriter>(actual);

            Assert.Equal(expected, tw.Tracer.Builder);
            // Teardown
        }