public void ComposeReturnsCorrectResult()
        {
            // Fixture setup
            var targetType = typeof(string);
            var factory = new DelegatingSpecimenBuilder();
            var sut = new TypedBuilderComposer(targetType, factory);
            // Exercise system
            var result = sut.Compose();
            // Verify outcome
            var filter = Assert.IsAssignableFrom<FilteringSpecimenBuilder>(result);

            var orSpec = Assert.IsAssignableFrom<OrRequestSpecification>(filter.Specification);
            Assert.Equal(targetType, orSpec.Specifications.OfType<SeedRequestSpecification>().Single().TargetType);
            Assert.Equal(targetType, orSpec.Specifications.OfType<ExactTypeSpecification>().Single().TargetType);

            var composite = Assert.IsAssignableFrom<CompositeSpecimenBuilder>(filter.Builder);
            var outputGuard = Assert.IsAssignableFrom<NoSpecimenOutputGuard>(composite.Builders.First());
            Assert.IsAssignableFrom<SeedIgnoringRelay>(composite.Builders.Last());

            Assert.Equal(factory, outputGuard.Builder);

            var inverseSpec = Assert.IsAssignableFrom<InverseRequestSpecification>(outputGuard.Specification);
            var seedSpec = Assert.IsAssignableFrom<SeedRequestSpecification>(inverseSpec.Specification);
            Assert.Equal(targetType, seedSpec.TargetType);
            // Teardown
        }
        public void CreateTypedNodeReturnsCorrectResult(Type targetType)
        {
            // Fixture setup
            var factory = new DelegatingSpecimenBuilder();
            // Exercise system
            FilteringSpecimenBuilder actual =
                SpecimenBuilderNodeFactory.CreateTypedNode(
                    targetType,
                    factory);
            // Verify outcome
            var expected = new FilteringSpecimenBuilder(
                new CompositeSpecimenBuilder(
                    new NoSpecimenOutputGuard(
                        factory,
                        new InverseRequestSpecification(
                            new SeedRequestSpecification(
                                targetType))),
                    new SeedIgnoringRelay()),
                new OrRequestSpecification(
                    new SeedRequestSpecification(targetType),
                    new ExactTypeSpecification(targetType)));

            Assert.True(expected.GraphEquals(actual, new NodeComparer()));
            // Teardown
        }
 public void InitializeDoubleActionWithNullActionThrows()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() => new Postprocessor<string>(dummyBuilder, (Action<string, ISpecimenContext>)null));
     // Teardown
 }
 public void InitializeWithNullSpecificationWillThrow()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() => new FilteringSpecimenBuilder(dummyBuilder, null));
     // Teardown
 }
 public void SutCanBeInitializedWithDoubleAction()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     Action<object, ISpecimenContext> dummyAction = (s, c) => { };
     // Exercise system and verify outcome
     Assert.DoesNotThrow(() => new Postprocessor(dummyBuilder, dummyAction));
     // Teardown
 }
 public void InitializeWithNullSpecificationThrows()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     Action<object, ISpecimenContext> dummyAction = (s, c) => { };
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() => new Postprocessor(dummyBuilder, dummyAction, null));
     // Teardown
 }
 public void InitializeWithNullTypeThrows()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         new TypedBuilderComposer(null, dummyBuilder));
     // Teardown
 }
 public void ConstructorThrowsOnNullComparer()
 {
     // Fixture setup
     var dummy = new DelegatingSpecimenBuilder();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         new OmitOnRecursionGuard(dummy, null));
     // Teardown
 }
 public void InitializeGreedyCtorWithNullSpecificationThrows()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         new NoSpecimenOutputGuard(dummyBuilder, null));
     // Teardown
 }
 public void SutIsRecursionGuard()
 {
     // Fixture setup
     // Exercise system
     var dummy = new DelegatingSpecimenBuilder();
     var sut = new OmitOnRecursionGuard(dummy);
     // Verify outcome
     Assert.IsAssignableFrom<RecursionGuard>(sut);
     // Teardown
 }
 public void SutIsSpecimenBuilder()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     // Exercise system
     var sut = new DisposableTracker(dummyBuilder);
     // Verify outcome
     Assert.IsAssignableFrom<ISpecimenBuilder>(sut);
     // Teardown
 }
Exemplo n.º 12
0
 public void SutYieldsInjectedBuilder()
 {
     // Fixture setup
     var expected = new DelegatingSpecimenBuilder();
     var sut = new DisposableTracker(expected);
     // Exercise system
     // Verify outcome
     Assert.Equal(expected, sut.Single());
     Assert.Equal(expected, ((System.Collections.IEnumerable)sut).Cast<object>().Single());
     // Teardown
 }
 public void SutIsSpecimenBuilderComposer()
 {
     // Fixture setup
     var dummyType = typeof(object);
     var dummyBuilder = new DelegatingSpecimenBuilder();
     // Exercise system
     var sut = new TypedBuilderComposer(dummyType, dummyBuilder);
     // Verify outcome
     Assert.IsAssignableFrom<ISpecimenBuilderComposer>(sut);
     // Teardown
 }
 public void BuilderIsCorrect()
 {
     // Fixture setup
     var expectedBuilder = new DelegatingSpecimenBuilder();
     var sut = new ThrowingRecursionGuard(expectedBuilder);
     // Exercise system
     var result = sut.Builder;
     // Verify outcome
     Assert.Equal(expectedBuilder, result);
     // Teardown
 }
Exemplo n.º 15
0
 public void SutIsSpecimenBuilder()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     Action<object> dummyAction = s => { };
     // Exercise system
     var sut = new Postprocessor(dummyBuilder, dummyAction);
     // Verify outcome
     Assert.IsAssignableFrom<ISpecimenBuilder>(sut);
     // Teardown
 }
Exemplo n.º 16
0
 public void InitializedWithFuncCorrectlyComposes()
 {
     // Fixture setup
     var expectedBuilder = new DelegatingSpecimenBuilder();
     var sut = new NullComposer<object>(() => expectedBuilder);
     // Exercise system
     var result = sut.Compose();
     // Verify outcome
     Assert.Equal(expectedBuilder, result);
     // Teardown
 }
Exemplo n.º 17
0
 public void BuilderIsCorrect()
 {
     // Fixture setup
     var expected = new DelegatingSpecimenBuilder();
     var sut = new NodeComposer<Guid>(expected);
     // Exercise system
     ISpecimenBuilder actual = sut.Builder;
     // Verify outcome
     Assert.Equal(expected, actual);
     // Teardown
 }
 public void DisposablesIsInstance()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     var sut = new DisposableTracker(dummyBuilder);
     // Exercise system
     IEnumerable<IDisposable> result = sut.Disposables;
     // Verify outcome
     Assert.NotNull(result);
     // Teardown
 }
 public void SutIsSpecimenBuilder()
 {
     // Fixture setup
     var dummySpecification = new DelegatingRequestSpecification();
     var dummyBuilder = new DelegatingSpecimenBuilder();
     // Exercise system
     var sut = new FilteringSpecimenBuilder(dummyBuilder, dummySpecification);
     // Verify outcome
     Assert.IsAssignableFrom<ISpecimenBuilder>(sut);
     // Teardown
 }
 public void SpecificationIsCorrectWhenInitializedWithModestCtor()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     var sut = new NoSpecimenOutputGuard(dummyBuilder);
     // Exercise system
     IRequestSpecification result = sut.Specification;
     // Verify outcome
     Assert.IsAssignableFrom<TrueRequestSpecification>(result);
     // 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
 }
 public void BuilderIsCorrect()
 {
     // Fixture setup
     var expectedBuilder = new DelegatingSpecimenBuilder();
     var sut = new DisposableTracker(expectedBuilder);
     // Exercise system
     ISpecimenBuilder result = sut.Builder;
     // Verify outcome
     Assert.Equal(expectedBuilder, result);
     // Teardown
 }
 public void BuilderIsCorrectWhenInitializedWithModestCtor()
 {
     // Fixture setup
     var expectedBuilder = new DelegatingSpecimenBuilder();
     var sut = new NoSpecimenOutputGuard(expectedBuilder);
     // Exercise system
     ISpecimenBuilder result = sut.Builder;
     // Verify outcome
     Assert.Equal(expectedBuilder, result);
     // Teardown
 }
 public void TransformReturnsCorrectSpecimenBuilderType()
 {
     // Fixture setup
     var sut = new DisposableTrackingBehavior();
     // Exercise system
     var dummyBuilder = new DelegatingSpecimenBuilder();
     var result = sut.Transform(dummyBuilder);
     // Verify outcome
     Assert.IsAssignableFrom<DisposableTracker>(result);
     // Teardown
 }
 public void FactoryIsCorrect()
 {
     // Fixture setup
     var dummyType = typeof(string);
     var expectedBuilder = new DelegatingSpecimenBuilder();
     var sut = new TypedBuilderComposer(dummyType, expectedBuilder);
     // Exercise system
     ISpecimenBuilder result = sut.Factory;
     // Verify outcome
     Assert.Equal(expectedBuilder, result);
     // Teardown
 }
Exemplo n.º 26
0
 public void SutYieldsDecoratedBuilder()
 {
     // Fixture setup
     var expected = new DelegatingSpecimenBuilder();
     // Exercise system
     var sut = new NodeComposer<Guid>(expected);
     // Verify outcome
     Assert.True(new[] { expected }.SequenceEqual(sut));
     Assert.True(new object[] { expected }.SequenceEqual(
         ((System.Collections.IEnumerable)sut).Cast<object>()));
     // Teardown
 }
        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.Throws(typeof(ObjectCreationException), () => sut.Create(Guid.NewGuid(), container));
        }
 public void BuilderIsCorrectWhenInitializedWithGreedyCtor()
 {
     // Fixture setup
     var expectedBuilder = new DelegatingSpecimenBuilder();
     var dummySpec = new DelegatingRequestSpecification();
     var sut = new NoSpecimenOutputGuard(expectedBuilder, dummySpec);
     // Exercise system
     var result = sut.Builder;
     // Verify outcome
     Assert.Equal(expectedBuilder, result);
     // Teardown
 }
 public void SpecificationIsCorrect()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     var expectedSpecification = new DelegatingRequestSpecification();
     var sut = new FilteringSpecimenBuilder(dummyBuilder, expectedSpecification);
     // Exercise system
     IRequestSpecification result = sut.Specification;
     // Verify outcome
     Assert.Equal(expectedSpecification, result);
     // Teardown
 }
 public void SutYieldsCorrectSequence()
 {
     // Fixture setup
     var expected = new DelegatingSpecimenBuilder();
     var tracer = new DelegatingTracingBuilder(expected);
     var sut = new TerminatingWithPathSpecimenBuilder(tracer);
     // Exercise system
     // Verify outcome
     Assert.Equal(expected, sut.Single());
     Assert.Equal(expected, sut.Cast<object>().Single());
     // Teardown
 }
Exemplo n.º 31
0
        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
        }
Exemplo n.º 32
0
        public void ComposePreservesAction()
        {
            // Fixture setup
            Action <object, ISpecimenContext> expected = (x, y) => { };
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut          = new Postprocessor(dummyBuilder, expected);
            // Exercise system
            var actual = sut.Compose(new ISpecimenBuilder[0]);
            // Verify outcome
            var pp = Assert.IsAssignableFrom <Postprocessor>(actual);

            Assert.Equal(expected, pp.Action);
            // Teardown
        }
Exemplo n.º 33
0
        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
        }
        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
        }
Exemplo n.º 35
0
        public void ComposeSingleItemReturnsCorrectResult()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut          = new NullRecursionGuard(dummyBuilder);
            // Exercise system
            var expected = new DelegatingSpecimenBuilder();
            var actual   = sut.Compose(new[] { expected });
            // Verify outcome
            var rg = Assert.IsAssignableFrom <NullRecursionGuard>(actual);

            Assert.Equal(expected, rg.Builder);
            // Teardown
        }
Exemplo n.º 36
0
        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
        }
Exemplo n.º 37
0
        public void ComposeRetainsComparer()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var expected     = new DelegatingEqualityComparer();
            var sut          = new OmitOnRecursionGuard(dummyBuilder, expected);
            // Exercise system
            var actual = sut.Compose(new ISpecimenBuilder[0]);
            // Verify outcome
            var rg = Assert.IsAssignableFrom <OmitOnRecursionGuard>(actual);

            Assert.Equal(expected, rg.Comparer);
            // Teardown
        }
Exemplo n.º 38
0
        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
        }
Exemplo n.º 39
0
        public void ComposePreservesCommand()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var expected     = new DelegatingSpecimenCommand();
            var sut          = new Postprocessor(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
        }
Exemplo n.º 40
0
        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
        }
Exemplo n.º 41
0
        public void ComposeSingleItemReturnsCorrectResult()
        {
            // Fixture setup
            var tracer = new DelegatingTracingBuilder();
            var sut    = new TerminatingWithPathSpecimenBuilder(tracer);
            // Exercise system
            var expected = new DelegatingSpecimenBuilder();
            var actual   = sut.Compose(new[] { expected });
            // Verify outcome
            var tw = Assert.IsAssignableFrom <TerminatingWithPathSpecimenBuilder>(actual);

            Assert.Equal(expected, tw.Tracer.Builder);
            // Teardown
        }
Exemplo n.º 42
0
        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
        }
Exemplo n.º 43
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.Throws(typeof(ObjectCreationException), () => sut.Create(Guid.NewGuid(), container));
        }
        public void CreateThrowsWhenDecoratedBuilderReturnsNoSpecimen()
        {
            // Fixture setup
            var builder = new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => new NoSpecimen(r)
            };
            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
        }
Exemplo n.º 45
0
        public void ComposeAddsReturnedObjectToDisposables()
        {
            // Fixture setup
            var dummy = new DelegatingSpecimenBuilder();
            var sut   = new DisposableTracker(dummy);
            // Exercise system
            var dummies = new ISpecimenBuilder[0];
            var actual  = sut.Compose(dummies);

            // Verify outcome
            Assert.True(
                sut.Disposables.Any(actual.Equals),
                "Returned value not added to disposables.");
            // Teardown
        }
Exemplo n.º 46
0
        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
        }
Exemplo n.º 47
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
        }
Exemplo n.º 48
0
        public void ComposeSingleItemReturnsCorrectResult()
        {
            // Fixture setup
            var dummyBuilder       = new DelegatingSpecimenBuilder();
            var dummySpecification = new DelegatingRequestSpecification();
            var sut = new FilteringSpecimenBuilder(dummyBuilder, dummySpecification);
            // Exercise system
            var expected = new DelegatingSpecimenBuilder();
            var actual   = sut.Compose(new[] { expected });
            // Verify outcome
            var f = Assert.IsAssignableFrom <FilteringSpecimenBuilder>(actual);

            Assert.Equal(expected, f.Builder);
            // Teardown
        }
Exemplo n.º 49
0
        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
        }
Exemplo n.º 50
0
            public IEnumerator <object[]> GetEnumerator()
            {
                var leaf = new DelegatingSpecimenBuilder();

                yield return(new object[]
                {
                    new TaggedNode(1),
                    new TaggedNode(1)
                });

                yield return(new object[]
                {
                    new TaggedNode(1,
                                   new TaggedNode(2),
                                   new TaggedNode(3)),
                    new TaggedNode(1,
                                   new TaggedNode(2),
                                   new TaggedNode(3))
                });

                yield return(new object[]
                {
                    new TaggedNode(1, leaf),
                    new TaggedNode(1, leaf)
                });

                yield return(new object[]
                {
                    new TaggedNode(1,
                                   new TaggedNode(2,
                                                  leaf,
                                                  leaf,
                                                  leaf),
                                   new TaggedNode(3,
                                                  leaf,
                                                  leaf,
                                                  leaf)),
                    new TaggedNode(1,
                                   new TaggedNode(2,
                                                  leaf,
                                                  leaf,
                                                  leaf),
                                   new TaggedNode(3,
                                                  leaf,
                                                  leaf,
                                                  leaf))
                });
            }
Exemplo n.º 51
0
        public void ReturnsNullAtRecursionPoint()
        {
            // Fixture setup
            var builder = new DelegatingSpecimenBuilder();

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

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

            // Exercise system
            object res = sut.Create(Guid.NewGuid(), container);

            Assert.Null(res);
        }
Exemplo n.º 52
0
        public void CreateWillReturnCorrectResult()
        {
            // Fixture setup
            var expectedResult = new object();
            var builder        = new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => expectedResult
            };
            var sut = new SpecimenContext(builder);
            // Exercise system
            var dummyRequest = new object();
            var result       = sut.Resolve(dummyRequest);

            // Verify outcome
            Assert.Equal(expectedResult, result);
            // Teardown
        }
Exemplo n.º 53
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
        }
Exemplo n.º 54
0
        public void DecoratedDisposableResultIsAddedToDisposables()
        {
            // Fixture setup
            var disposable = new DisposableSpy();
            var builder    = new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => disposable
            };
            var sut = new DisposableTracker(builder);
            // Exercise system
            var dummyRequest = new object();
            var dummyContext = new DelegatingSpecimenContext();

            sut.Create(dummyRequest, dummyContext);
            // Verify outcome
            Assert.Contains(disposable, sut.Disposables);
            // Teardown
        }
Exemplo n.º 55
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
        }
Exemplo n.º 56
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
        }
Exemplo n.º 57
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
        }
Exemplo n.º 58
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
        }
Exemplo n.º 59
0
        public void CreateReturnsCorrectResultWhenSpecificationIsNotSatisfied()
        {
            // Fixture setup
            var spec = new DelegatingRequestSpecification {
                OnIsSatisfiedBy = r => false
            };
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut          = new FilteringSpecimenBuilder(dummyBuilder, spec);
            var request      = new object();
            // Exercise system
            var dummyContainer = new DelegatingSpecimenContext();
            var result         = sut.Create(request, dummyContainer);
            // Verify outcome
            var expectedResult = new NoSpecimen(request);

            Assert.Equal(expectedResult, result);
            // Teardown
        }
Exemplo n.º 60
0
        public void CreateWillPassThroughToDecoratedBuilder()
        {
            // Fixture setup
            object expectedSpecimen = Guid.NewGuid();
            var    decoratedBuilder = new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => r
            };
            var sut = new DelegatingTracingBuilder(decoratedBuilder);

            // Exercise system
            var    dummyContainer = new DelegatingSpecimenContext();
            object result         = sut.Create(expectedSpecimen, dummyContainer);

            // Verify outcome
            Assert.Equal(expectedSpecimen, result);

            // Teardown
        }