public void CustomizeAddsNSubstitutePostprocessorCommandsToResidueCollectors()
        {
            // Fixture setup
            var residueCollectors = new List <ISpecimenBuilder>();
            var fixture           = Substitute.For <IFixture>();

            fixture.ResidueCollectors.Returns(residueCollectors);
            var sut = new AutoConfiguredNSubstituteCustomization();

            // Exercise system
            sut.Customize(fixture);
            // Verify outcome
            var customization      = Assert.Single(residueCollectors);
            var postprocessor      = Assert.IsAssignableFrom <Postprocessor>(customization);
            var nsubstituteBuilder = Assert.IsAssignableFrom <NSubstituteBuilder>(postprocessor.Builder);
            var methodInvoker      = Assert.IsAssignableFrom <MethodInvoker>(nsubstituteBuilder.Builder);

            Assert.IsAssignableFrom <AbstractTypeSpecification>(nsubstituteBuilder.SubstitutionSpecification);
            Assert.IsAssignableFrom <NSubstituteMethodQuery>(methodInvoker.Query);
            var compositeCommand = Assert.IsAssignableFrom <CompositeSpecimenCommand>(postprocessor.Command);

            Assert.True(compositeCommand.Commands.OfType <NSubstituteVirtualMethodsCommand>().Any());
            Assert.True(compositeCommand.Commands.OfType <NSubstituteSealedPropertiesCommand>().Any());
            // Teardown
        }
 public void CustomizeThrowsWhenFixtureIsNull()
 {
     // Fixture setup
     var sut = new AutoConfiguredNSubstituteCustomization();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(
         () => sut.Customize(null));
     // Teardown
 }
Esempio n. 3
0
        public void CustomizeThrowsWhenFixtureIsNull()
        {
            // Arrange
            var sut = new AutoConfiguredNSubstituteCustomization();

            // Act & Assert
            Assert.Throws <ArgumentNullException>(
                () => sut.Customize(null));
        }
        public void CustomizeAddsBuilderToResidueCollectors()
        {
            var builder = Substitute.For<ISpecimenBuilder>();
            var fixture = Substitute.For<IFixture>();
            var sut = new AutoConfiguredNSubstituteCustomization(builder);

            sut.Customize(fixture);

            fixture.ResidueCollectors.Received().Add(builder);
        }
        public void CustomizeThrowsWhenFixtureIsNull()
        {
            // Fixture setup
            var sut = new AutoConfiguredNSubstituteCustomization();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(
                () => sut.Customize(null));
            // Teardown
        }
        public void CustomizeAddsBuilderToResidueCollectors()
        {
            var builder = Substitute.For <ISpecimenBuilder>();
            var fixture = Substitute.For <IFixture>();
            var sut     = new AutoConfiguredNSubstituteCustomization(builder);

            sut.Customize(fixture);

            fixture.ResidueCollectors.Received().Add(builder);
        }
 public void CustomizeInsertsSubstituteAttributeRelayInCustomizationsToOverrideDefaultConstructionWhenAttributeIsPresent()
 {
     // Fixture setup
     var sut = new AutoConfiguredNSubstituteCustomization();
     var fixture = Substitute.For<IFixture>();
     // Exercise system
     sut.Customize(fixture);
     // Verify outcome
     fixture.Customizations.Received().Insert(0, Arg.Any<SubstituteAttributeRelay>());
     // Teardown
 }
Esempio n. 8
0
        public void CustomizeInsertsSubstituteAttributeRelayInCustomizationsToOverrideDefaultConstructionWhenAttributeIsPresent()
        {
            // Arrange
            var sut     = new AutoConfiguredNSubstituteCustomization();
            var fixture = Substitute.For <IFixture>();

            // Act
            sut.Customize(fixture);
            // Assert
            fixture.Customizations.Received().Insert(0, Arg.Any <SubstituteAttributeRelay>());
        }
        public void CustomizeInsertsSubstituteAttributeRelayInCustomizationsToOverrideDefaultConstructionWhenAttributeIsPresent()
        {
            // Fixture setup
            var sut     = new AutoConfiguredNSubstituteCustomization();
            var fixture = Substitute.For <IFixture>();

            // Exercise system
            sut.Customize(fixture);
            // Verify outcome
            fixture.Customizations.Received().Insert(0, Arg.Any <SubstituteAttributeRelay>());
            // Teardown
        }
        public void CustomizeAddsBuilderToResidueCollectors()
        {
            var builder = Substitute.For<ISpecimenBuilder>();
            var residueCollectors = new List<ISpecimenBuilder>();
            var fixture = Substitute.For<IFixture>();
            fixture.ResidueCollectors.Returns(residueCollectors);
            var sut = new AutoConfiguredNSubstituteCustomization(builder);

            sut.Customize(fixture);

            var customization = Assert.Single(residueCollectors);
            var postprocessor = Assert.IsAssignableFrom<Postprocessor>(customization);
            Assert.Equal(builder, postprocessor.Builder);
        }
        public void CustomizeAddsBuilderToResidueCollectors()
        {
            var builder           = Substitute.For <ISpecimenBuilder>();
            var residueCollectors = new List <ISpecimenBuilder>();
            var fixture           = Substitute.For <IFixture>();

            fixture.ResidueCollectors.Returns(residueCollectors);
            var sut = new AutoConfiguredNSubstituteCustomization(builder);

            sut.Customize(fixture);

            var customization = Assert.Single(residueCollectors);
            var postprocessor = Assert.IsAssignableFrom <Postprocessor>(customization);

            Assert.Equal(builder, postprocessor.Builder);
        }
 public void CustomizeAddsPostprocessorWithSubstituteRequestHandlerAndCommandsToCustomizations()
 {
     // Fixture setup
     var fixture = Substitute.For<IFixture>();
     Postprocessor postprocessor = null;
     fixture.Customizations.Insert(Arg.Any<int>(), Arg.Do<Postprocessor>(p => postprocessor = p));
     var sut = new AutoConfiguredNSubstituteCustomization();
     // Exercise system
     sut.Customize(fixture);
     // Verify outcome
     var substituteRequestHandler = Assert.IsAssignableFrom<SubstituteRequestHandler>(postprocessor.Builder);
     var substituteFactory = Assert.IsType<MethodInvoker>(substituteRequestHandler.SubstituteFactory);
     Assert.IsType<NSubstituteMethodQuery>(substituteFactory.Query);
     var compositeCommand = Assert.IsAssignableFrom<CompositeSpecimenCommand>(postprocessor.Command);
     Assert.True(compositeCommand.Commands.OfType<NSubstituteVirtualMethodsCommand>().Any());
     Assert.True(compositeCommand.Commands.OfType<NSubstituteSealedPropertiesCommand>().Any());
     // Teardown
 }
 public void CustomizeAddsNSubstitutePostprocessorCommandsToResidueCollectors()
 {
     // Fixture setup
     var residueCollectors = new List<ISpecimenBuilder>();
     var fixture = Substitute.For<IFixture>();
     fixture.ResidueCollectors.Returns(residueCollectors);
     var sut = new AutoConfiguredNSubstituteCustomization();
     // Exercise system
     sut.Customize(fixture);
     // Verify outcome
     var customization = Assert.Single(residueCollectors);
     var postprocessor = Assert.IsAssignableFrom<Postprocessor>(customization);
     var nsubstituteBuilder = Assert.IsAssignableFrom<NSubstituteBuilder>(postprocessor.Builder);
     var methodInvoker = Assert.IsAssignableFrom<MethodInvoker>(nsubstituteBuilder.Builder);
     Assert.IsAssignableFrom<AbstractTypeSpecification>(nsubstituteBuilder.SubstitutionSpecification);
     Assert.IsAssignableFrom<NSubstituteMethodQuery>(methodInvoker.Query);
     var compositeCommand = Assert.IsAssignableFrom<CompositeSpecimenCommand>(postprocessor.Command);
     Assert.True(compositeCommand.Commands.OfType<NSubstituteVirtualMethodsCommand>().Any());
     Assert.True(compositeCommand.Commands.OfType<NSubstituteSealedPropertiesCommand>().Any());
     // Teardown
 }
Esempio n. 14
0
        public void CustomizeAddsPostprocessorWithSubstituteRequestHandlerAndCommandsToCustomizations()
        {
            // Arrange
            var           fixture       = Substitute.For <IFixture>();
            Postprocessor postprocessor = null;

            fixture.Customizations.Insert(Arg.Any <int>(), Arg.Do <Postprocessor>(p => postprocessor = p));
            var sut = new AutoConfiguredNSubstituteCustomization();

            // Act
            sut.Customize(fixture);
            // Assert
            var substituteRequestHandler = Assert.IsAssignableFrom <SubstituteRequestHandler>(postprocessor.Builder);
            var substituteFactory        = Assert.IsType <MethodInvoker>(substituteRequestHandler.SubstituteFactory);

            Assert.IsType <NSubstituteMethodQuery>(substituteFactory.Query);
            var compositeCommand = Assert.IsAssignableFrom <CompositeSpecimenCommand>(postprocessor.Command);

            Assert.True(compositeCommand.Commands.OfType <NSubstituteRegisterCallHandlerCommand>().Any());
            Assert.True(compositeCommand.Commands.OfType <NSubstituteSealedPropertiesCommand>().Any());
        }