public void InitializeWithNullBuilderWillThrows()
 {
     // Fixture setup
     var dummySpecification = new DelegatingRequestSpecification();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() => new FilteringSpecimenBuilder(null, dummySpecification));
     // Teardown
 }
 public void InitializeGreedyCtorWithNullBuilderThrows()
 {
     // Fixture setup
     var dummySpec = new DelegatingRequestSpecification();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         new NoSpecimenOutputGuard(null, dummySpec));
     // Teardown
 }
 public void InitializeDoubleActionAndSpecificationWithNullBuilderThrows()
 {
     // Fixture setup
     Action<object, ISpecimenContext> dummyAction = (s, c) => { };
     var dummySpec = new DelegatingRequestSpecification();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() => new Postprocessor<object>(null, dummyAction, dummySpec));
     // Teardown
 }
 public void SutIsRequestSpecification()
 {
     // Fixture setup
     var dummySpec = new DelegatingRequestSpecification();
     // Exercise system
     var sut = new InverseRequestSpecification(dummySpec);
     // Verify outcome
     Assert.IsAssignableFrom<IRequestSpecification>(sut);
     // Teardown
 }
 public void SpecificationIsCorrecty()
 {
     // Fixture setup
     var expectedSpec = new DelegatingRequestSpecification();
     var sut = new InverseRequestSpecification(expectedSpec);
     // Exercise system
     IRequestSpecification result = sut.Specification;
     // Verify outcome
     Assert.Equal(expectedSpec, 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
 }
Exemplo n.º 7
0
 public void SpecificationMatchesConstructorArgument()
 {
     // Fixture setup
     var expected = new DelegatingRequestSpecification();
     var sut = new Omitter(expected);
     // Exercise system
     IRequestSpecification actual = sut.Specification;
     // Verify outcome
     Assert.Equal(expected, actual);
     // Teardown
 }
        public void SpecificationIsCorrecty()
        {
            // Fixture setup
            var expectedSpec = new DelegatingRequestSpecification();
            var sut          = new InverseRequestSpecification(expectedSpec);
            // Exercise system
            IRequestSpecification result = sut.Specification;

            // Verify outcome
            Assert.Equal(expectedSpec, result);
            // Teardown
        }
 public void IsSatisfiedByReturnsCorrectResult(bool decoratedResult)
 {
     // Fixture setup
     var spec = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => decoratedResult };
     var sut = new InverseRequestSpecification(spec);
     // Exercise system
     var dummyRequest = new object();
     var result = sut.IsSatisfiedBy(dummyRequest);
     // Verify outcome
     Assert.Equal(!decoratedResult, result);
     // Teardown
 }
Exemplo n.º 10
0
        public void SutIsNode()
        {
            // Fixture setup
            var dummyBuilder       = new DelegatingSpecimenBuilder();
            var dummySpecification = new DelegatingRequestSpecification();
            // Exercise system
            var sut = new FilteringSpecimenBuilder(dummyBuilder, dummySpecification);

            // Verify outcome
            Assert.IsAssignableFrom <ISpecimenBuilderNode>(sut);
            // Teardown
        }
Exemplo n.º 11
0
        public void SpecificationMatchesConstructorArgument()
        {
            // Fixture setup
            var expected = new DelegatingRequestSpecification();
            var sut      = new Omitter(expected);
            // Exercise system
            IRequestSpecification actual = sut.Specification;

            // Verify outcome
            Assert.Equal(expected, actual);
            // 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 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
 }
Exemplo n.º 14
0
        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 IsSatisfidByInvokesDecoratedSpecWithCorrectRequest()
 {
     // Fixture setup
     var expectedRequest = new object();
     var verified = false;
     var mock = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => verified = expectedRequest == r };
     var sut = new InverseRequestSpecification(mock);
     // Exercise system
     sut.IsSatisfiedBy(expectedRequest);
     // Verify outcome
     Assert.True(verified, "Mock verified");
     // Teardown
 }
        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
        }
Exemplo n.º 17
0
        public void SutYieldsDecoratedBuilder()
        {
            // Fixture setup
            var expected           = new DelegatingSpecimenBuilder();
            var dummySpecification = new DelegatingRequestSpecification();
            // Exercise system
            var sut = new FilteringSpecimenBuilder(expected, dummySpecification);

            // Verify outcome
            Assert.True(new[] { expected }.SequenceEqual(sut));
            Assert.True(new object[] { expected }.SequenceEqual(((System.Collections.IEnumerable)sut).Cast <object>()));
            // Teardown
        }
Exemplo n.º 18
0
        public void FilterIsProperWritableProperty()
        {
            // Fixture setup
            var sut = new DelegatingTracingBuilder();
            IRequestSpecification expectedFilter = new DelegatingRequestSpecification();

            // Exercise system
            sut.Filter = expectedFilter;
            IRequestSpecification result = sut.Filter;

            // Verify outcome
            Assert.Equal(expectedFilter, result);
            // Teardown
        }
Exemplo n.º 19
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
        }
Exemplo n.º 20
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
        }
Exemplo n.º 21
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.º 22
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
        }
 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.º 24
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.º 25
0
        public void IsSatisfiedByReturnsCorrectResult(bool decoratedResult)
        {
            // Fixture setup
            var spec = new DelegatingRequestSpecification {
                OnIsSatisfiedBy = r => decoratedResult
            };
            var sut = new InverseRequestSpecification(spec);
            // Exercise system
            var dummyRequest = new object();
            var result       = sut.IsSatisfiedBy(dummyRequest);

            // Verify outcome
            Assert.Equal(!decoratedResult, result);
            // Teardown
        }
        public void IsSatisfiedByFilteredFieldInfoReturnsCorrectResult()
        {
            // Fixture setup
            var spec = new DelegatingRequestSpecification {
                OnIsSatisfiedBy = r => false
            };
            var sut     = new AutoPropertiesCommand <FieldHolder <object> >(spec);
            var request = typeof(FieldHolder <object>).GetField("Field");
            // Exercise system
            var result = sut.IsSatisfiedBy(request);

            // Verify outcome
            Assert.False(result);
            // Teardown
        }
Exemplo n.º 27
0
        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 IsSatisfiedByPassesRequestToDecoratedSpecification()
        {
            // Fixture setup
            var expectedRequest = new object();
            var verified        = false;
            var specMock        = new DelegatingRequestSpecification {
                OnIsSatisfiedBy = r => verified = expectedRequest == r
            };
            var sut = new OrRequestSpecification(specMock);

            // Exercise system
            sut.IsSatisfiedBy(expectedRequest);
            // Verify outcome
            Assert.True(verified, "Mock verified");
            // Teardown
        }
Exemplo n.º 29
0
        public void IsSatisfiedByInvokesDecoratedSpecWithCorrectRequest()
        {
            // Fixture setup
            var expectedRequest = new object();
            var verified        = false;
            var mock            = new DelegatingRequestSpecification {
                OnIsSatisfiedBy = r => verified = expectedRequest == r
            };
            var sut = new InverseRequestSpecification(mock);

            // Exercise system
            sut.IsSatisfiedBy(expectedRequest);
            // Verify outcome
            Assert.True(verified, "Mock verified");
            // Teardown
        }
        public void IsSatisfiedByWillInvokeSpecificationWithCorrectFieldInfo()
        {
            // Fixture setup
            var expectedRequest = typeof(FieldHolder <object>).GetField("Field");
            var verified        = false;
            var specMock        = new DelegatingRequestSpecification {
                OnIsSatisfiedBy = r => verified = expectedRequest == r
            };
            var sut = new AutoPropertiesCommand <FieldHolder <object> >(specMock);

            // Exercise system
            sut.IsSatisfiedBy(expectedRequest);
            // Verify outcome
            Assert.True(verified, "Mock verified");
            // Teardown
        }
Exemplo n.º 31
0
        public void CreateWhenSpecificationMatchesRequestReturnsCorrectResult()
        {
            // Fixture setup
            var request       = new object();
            var specification = new DelegatingRequestSpecification
            {
                OnIsSatisfiedBy = request.Equals
            };
            var sut = new Omitter(specification);
            // Exercise system
            var dummyContext = new DelegatingSpecimenContext();
            var actual       = sut.Create(request, dummyContext);

            // Verify outcome
            Assert.IsAssignableFrom <OmitSpecimen>(actual);
            // Teardown
        }
        public void ExecuteDoesNotAssignFieldWhenSpecificationIsNotSatisfied()
        {
            // Fixture setup
            var spec = new DelegatingRequestSpecification {
                OnIsSatisfiedBy = r => false
            };
            var sut       = new AutoPropertiesCommand <FieldHolder <object> >(spec);
            var specimen  = new FieldHolder <object>();
            var container = new DelegatingSpecimenContext {
                OnResolve = r => new object()
            };

            // Exercise system
            sut.Execute(specimen, container);
            // Verify outcome
            Assert.Null(specimen.Field);
            // Teardown
        }
Exemplo n.º 33
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
        }
        public void ExecuteWillQuerySpecificationWithCorrectFieldInfo()
        {
            // Fixture setup
            var expectedFieldInfo = typeof(FieldHolder <string>).GetField("Field");
            var verified          = false;
            var specMock          = new DelegatingRequestSpecification {
                OnIsSatisfiedBy = r => verified = expectedFieldInfo.Equals(r)
            };
            var sut = new AutoPropertiesCommand <FieldHolder <string> >(specMock);
            // Exercise system
            var specimen       = new FieldHolder <string>();
            var dummyContainer = new DelegatingSpecimenContext();

            sut.Execute(specimen, dummyContainer);
            // Verify outcome
            Assert.True(verified, "Mock verified");
            // Teardown
        }
Exemplo n.º 35
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.º 36
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.º 37
0
        public void SpecificationReceivesCorrectRequest()
        {
            // Fixture setup
            var expectedRequest = new object();
            var verified        = false;
            var specMock        = new DelegatingRequestSpecification {
                OnIsSatisfiedBy = r => verified = expectedRequest == r
            };

            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut          = new FilteringSpecimenBuilder(dummyBuilder, specMock);
            // Exercise system
            var dummyContainer = new DelegatingSpecimenContext();

            sut.Create(expectedRequest, dummyContainer);
            // Verify outcome
            Assert.True(verified, "Mock verified");
            // Teardown
        }
Exemplo n.º 38
0
        public void CreatePassesCorrectParametersToDecoratedBuilder()
        {
            // 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 spec = new DelegatingRequestSpecification {
                OnIsSatisfiedBy = r => true
            };
            var sut = new FilteringSpecimenBuilder(builderMock, spec);

            // Exercise system
            sut.Create(expectedRequest, expectedContainer);
            // Verify outcome
            Assert.True(verified, "Mock verified");
            // Teardown
        }
Exemplo n.º 39
0
        public void CreateReturnsCorrectResultWhenFilterAllowsRequestThrough()
        {
            // Fixture setup
            var expectedResult = new object();
            var spec           = new DelegatingRequestSpecification {
                OnIsSatisfiedBy = r => true
            };
            var builder = new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => expectedResult
            };
            var sut = new FilteringSpecimenBuilder(builder, spec);
            // 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.º 40
0
        public void ComposeReturnsCorrectResult()
        {
            // Fixture setup
            var dummyBuilder       = new DelegatingSpecimenBuilder();
            var dummySpecification = new DelegatingRequestSpecification();
            var sut = new FilteringSpecimenBuilder(dummyBuilder, dummySpecification);
            // Exercise system
            var expectedBuilders = new[]
            {
                new DelegatingSpecimenBuilder(),
                new DelegatingSpecimenBuilder(),
                new DelegatingSpecimenBuilder()
            };
            var actual = sut.Compose(expectedBuilders);
            // Verify outcome
            var f         = Assert.IsAssignableFrom <FilteringSpecimenBuilder>(actual);
            var composite = Assert.IsAssignableFrom <CompositeSpecimenBuilder>(f.Builder);

            Assert.True(expectedBuilders.SequenceEqual(composite));
            // Teardown
        }
        public void CreateDoesNotThrowOnReturnedNoSpecimenWhenSpecificationReturnsFalse()
        {
            // Fixture setup
            var request = new object();

            var builder = new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => new NoSpecimen(r)
            };
            var spec = new DelegatingRequestSpecification {
                OnIsSatisfiedBy = r => request == r ? false : true
            };
            var sut = new NoSpecimenOutputGuard(builder, spec);
            // Exercise system
            var dummyContext = new DelegatingSpecimenContext();
            var result       = sut.Create(request, dummyContext);
            // Verify outcome
            var expectedResult = new NoSpecimen(request);

            Assert.Equal(expectedResult, result);
            // Teardown
        }
Exemplo n.º 42
0
        public void ExecuteOnNonGenericFalseSpecifiedDoesNotAssignProperty()
        {
            // Fixture setup
            var falseSpecification = new DelegatingRequestSpecification
            {
                OnIsSatisfiedBy = x => false
            };
            var sut = new AutoPropertiesCommand(falseSpecification);

            var dummyPropertyValue = new object();
            var context            = new DelegatingSpecimenContext {
                OnResolve = r => dummyPropertyValue
            };

            var specimen = new PropertyHolder <object>();

            // Exercise system
            sut.Execute(specimen, context);
            // Verify outcome
            Assert.NotEqual(dummyPropertyValue, specimen.Property);
            // Teardown
        }
Exemplo n.º 43
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
        }
        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 CreatePassesCorrectParametersToDecoratedBuilder()
 {
     // 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 spec = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => true };
     var sut = new FilteringSpecimenBuilder(builderMock, spec);
     // Exercise system
     sut.Create(expectedRequest, expectedContainer);
     // Verify outcome
     Assert.True(verified, "Mock verified");
     // 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 SutYieldsDecoratedBuilder()
 {
     // Fixture setup
     var expected = new DelegatingSpecimenBuilder();
     var dummySpecification = new DelegatingRequestSpecification();
     // Exercise system
     var sut = new FilteringSpecimenBuilder(expected, dummySpecification);
     // Verify outcome
     Assert.True(new[] { expected }.SequenceEqual(sut));
     Assert.True(new object[] { expected }.SequenceEqual(((System.Collections.IEnumerable)sut).Cast<object>()));
     // Teardown
 }
        public void ExecuteOnNonGenericFalseSpecifiedDoesNotAssignProperty()
        {
            // Fixture setup
            var falseSpecification = new DelegatingRequestSpecification
            {
                OnIsSatisfiedBy = x => false
            };
            var sut = new AutoPropertiesCommand(falseSpecification);

            var dummyPropertyValue = new object();
            var context = new DelegatingSpecimenContext { OnResolve = r => dummyPropertyValue };

            var specimen = new PropertyHolder<object>();
            // Exercise system
            sut.Execute(specimen, context);
            // Verify outcome
            Assert.NotEqual(dummyPropertyValue, specimen.Property);
            // Teardown
        }
 public void ComposeReturnsCorrectResult()
 {
     // Fixture setup
     var dummyBuilder = new DelegatingSpecimenBuilder();
     var dummySpecification = new DelegatingRequestSpecification();
     var sut = new FilteringSpecimenBuilder(dummyBuilder, dummySpecification);
     // Exercise system
     var expectedBuilders = new[]
     {
         new DelegatingSpecimenBuilder(),
         new DelegatingSpecimenBuilder(),
         new DelegatingSpecimenBuilder()
     };
     var actual = sut.Compose(expectedBuilders);
     // Verify outcome
     var f = Assert.IsAssignableFrom<FilteringSpecimenBuilder>(actual);
     var composite = Assert.IsAssignableFrom<CompositeSpecimenBuilder>(f.Builder);
     Assert.True(expectedBuilders.SequenceEqual(composite));
     // Teardown
 }
 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
 }
        public void SpecificationReceivesCorrectRequest()
        {
            // Fixture setup
            var expectedRequest = new object();
            var verified = false;
            var specMock = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => verified = expectedRequest == r };

            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut = new FilteringSpecimenBuilder(dummyBuilder, specMock);
            // Exercise system
            var dummyContainer = new DelegatingSpecimenContext();
            sut.Create(expectedRequest, dummyContainer);
            // 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 ConstructFullWithNullCommandThrows()
 {
     var dummyBuilder = new DelegatingSpecimenBuilder();
     var dummySpecification = new DelegatingRequestSpecification();
     Assert.Throws<ArgumentNullException>(() =>
         new Postprocessor<object>(
             dummyBuilder,
             (ISpecimenCommand)null,
             dummySpecification));
 }
 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
 }
        public void ExecuteOnNonGenericTrueSpecifiedAssignsProperty()
        {
            // Fixture setup
            var trueSpecification = new DelegatingRequestSpecification
            {
                OnIsSatisfiedBy = x => true 
            };
            var sut = new AutoPropertiesCommand(trueSpecification);

            var expectedPropertyValue = new object();
            var context = new DelegatingSpecimenContext { OnResolve = r => expectedPropertyValue };

            var specimen = new PropertyHolder<object>();
            // Exercise system
            sut.Execute(specimen, context);
            // Verify outcome
            Assert.Equal(expectedPropertyValue, specimen.Property);
            // 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
 }
Exemplo n.º 57
0
 public void FilterIsProperWritableProperty()
 {
     // Fixture setup
     var sut = new DelegatingTracingBuilder();
     IRequestSpecification expectedFilter = new DelegatingRequestSpecification();
     // Exercise system
     sut.Filter = expectedFilter;
     IRequestSpecification result = sut.Filter;
     // Verify outcome
     Assert.Equal(expectedFilter, result);
     // Teardown
 }
        public void CreateDoesNotThrowOnReturnedNoSpecimenWhenSpecificationReturnsFalse()
        {
            // Fixture setup            
            var request = new object();

            var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => new NoSpecimen(r) };
            var spec = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => request == r ? false : true };
            var sut = new NoSpecimenOutputGuard(builder, spec);
            // Exercise system
            var dummyContext = new DelegatingSpecimenContext();
            var result = sut.Create(request, dummyContext);
            // Verify outcome
            var expectedResult = new NoSpecimen(request);
            Assert.Equal(expectedResult, result);
            // Teardown
        }
 public void IsSatisfiedByPassesRequestToDecoratedSpecification()
 {
     // Fixture setup
     var expectedRequest = new object();
     var verified = false;
     var specMock = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => verified = expectedRequest == r };
     var sut = new AndRequestSpecification(specMock);
     // Exercise system
     sut.IsSatisfiedBy(expectedRequest);
     // Verify outcome
     Assert.True(verified, "Mock verified");
     // Teardown
 }
 public void CreateReturnsCorrectResultWhenFilterAllowsRequestThrough()
 {
     // Fixture setup
     var expectedResult = new object();
     var spec = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => true };
     var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedResult };
     var sut = new FilteringSpecimenBuilder(builder, spec);
     // Exercise system
     var dummyRequest = new object();
     var dummyContainer = new DelegatingSpecimenContext();
     var result = sut.Create(dummyRequest, dummyContainer);
     // Verify outcome
     Assert.Equal(expectedResult, result);
     // Teardown
 }