Ejemplo n.º 1
0
        public void CustomizeNullFixtureThrows()
        {
            // Arrange
            var sut = new AutoMoqCustomization();

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Customize(null));
        }
 public void CustomizeNullFixtureThrows()
 {
     // Fixture setup
     var sut = new AutoMoqCustomization();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         sut.Customize(null));
     // Teardown
 }
        public void CustomizeNullFixtureThrows()
        {
            // Fixture setup
            var sut = new AutoMoqCustomization();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Customize(null));
            // Teardown
        }
Ejemplo n.º 4
0
        public void CustomizeAddsAppropriateResidueCollector()
        {
            // Arrange
            var fixtureStub = new FixtureStub();

            var sut = new AutoMoqCustomization();

            // Act
            sut.Customize(fixtureStub);
            // Assert
            Assert.Contains(sut.Relay, fixtureStub.ResidueCollectors);
        }
Ejemplo n.º 5
0
        public void WithoutGenerateDelegates_DoesNotAddMockRelayForDelegate()
        {
            // Arrange
            var fixtureStub = new FixtureStub();
            var sut         = new AutoMoqCustomization {
                GenerateDelegates = false
            };

            // Act
            sut.Customize(fixtureStub);
            // Assert
            Assert.DoesNotContain(fixtureStub.Customizations, c => c is MockRelay);
        }
Ejemplo n.º 6
0
        public void WithConfigureMembers_CustomizeAddsPostprocessorToCustomizations()
        {
            // Arrange
            var fixtureStub = new FixtureStub();
            var sut         = new AutoMoqCustomization {
                ConfigureMembers = true
            };

            // Act
            sut.Customize(fixtureStub);
            // Assert
            Assert.Contains(fixtureStub.Customizations, builder => builder is Postprocessor);
        }
        public void CustomizeAddsAppropriateResidueCollector()
        {
            // Fixture setup
            var residueCollectors = new List<ISpecimenBuilder>();
            var fixtureStub = new Mock<IFixture> { DefaultValue = DefaultValue.Mock };
            fixtureStub.SetupGet(c => c.ResidueCollectors).Returns(residueCollectors);

            var sut = new AutoMoqCustomization();
            // Exercise system
            sut.Customize(fixtureStub.Object);
            // Verify outcome
            Assert.Contains(sut.Relay, residueCollectors);
            // Teardown
        }
Ejemplo n.º 8
0
        public void WithGenerateDelegates_CustomizeAddsRelay()
        {
            // Arrange
            var fixtureStub = new FixtureStub();
            var sut         = new AutoMoqCustomization {
                GenerateDelegates = true
            };

            // Act
            sut.Customize(fixtureStub);
            // Assert
            var mockRelay = (MockRelay)fixtureStub.Customizations.Single(c => c is MockRelay);

            Assert.IsType <DelegateSpecification>(mockRelay.MockableSpecification);
        }
Ejemplo n.º 9
0
        public void CustomizeAddsAppropriateCustomizations()
        {
            // Arrange
            var fixtureStub = new FixtureStub();

            var sut = new AutoMoqCustomization();

            // Act
            sut.Customize(fixtureStub);
            // Assert
            var postprocessor = fixtureStub.Customizations.OfType <MockPostprocessor>().Single();
            var ctorInvoker   = Assert.IsAssignableFrom <MethodInvoker>(postprocessor.Builder);

            Assert.IsAssignableFrom <MockConstructorQuery>(ctorInvoker.Query);
        }
Ejemplo n.º 10
0
        public void WithConfigureMembers_CustomizeAddsMockCommandsToPostprocessor(Type expectedCommandType)
        {
            // Arrange
            var fixtureStub = new FixtureStub();
            var sut         = new AutoMoqCustomization {
                ConfigureMembers = true
            };

            // Act
            sut.Customize(fixtureStub);
            // Assert
            var postprocessor    = (Postprocessor)fixtureStub.Customizations.Single(builder => builder is Postprocessor);
            var compositeCommand = (CompositeSpecimenCommand)postprocessor.Command;

            Assert.Contains(compositeCommand.Commands, command => command.GetType() == expectedCommandType);
        }
Ejemplo n.º 11
0
        public void CustomizeAddsAppropriateResidueCollector()
        {
            // Arrange
            var residueCollectors = new List <ISpecimenBuilder>();
            var fixtureStub       = new Mock <IFixture> {
                DefaultValue = DefaultValue.Mock
            };

            fixtureStub.SetupGet(c => c.ResidueCollectors).Returns(residueCollectors);

            var sut = new AutoMoqCustomization();

            // Act
            sut.Customize(fixtureStub.Object);
            // Assert
            Assert.Contains(sut.Relay, residueCollectors);
        }
Ejemplo n.º 12
0
        public void CustomizeAddsAppropriateResidueCollector()
        {
            // Fixture setup
            var residueCollectors = new List <ISpecimenBuilder>();
            var fixtureStub       = new Mock <IFixture> {
                DefaultValue = DefaultValue.Mock
            };

            fixtureStub.SetupGet(c => c.ResidueCollectors).Returns(residueCollectors);

            var sut = new AutoMoqCustomization();

            // Exercise system
            sut.Customize(fixtureStub.Object);
            // Verify outcome
            Assert.Contains(sut.Relay, residueCollectors);
            // Teardown
        }
Ejemplo n.º 13
0
        public void CustomizeAddsAppropriateCustomizations()
        {
            // Arrange
            var customizations = new List <ISpecimenBuilder>();
            var fixtureStub    = new Mock <IFixture> {
                DefaultValue = DefaultValue.Mock
            };

            fixtureStub.SetupGet(c => c.Customizations).Returns(customizations);

            var sut = new AutoMoqCustomization();

            // Act
            sut.Customize(fixtureStub.Object);
            // Assert
            var postprocessor = customizations.OfType <MockPostprocessor>().Single();
            var ctorInvoker   = Assert.IsAssignableFrom <MethodInvoker>(postprocessor.Builder);

            Assert.IsAssignableFrom <MockConstructorQuery>(ctorInvoker.Query);
        }
        public void CustomizeAddsAppropriateCustomizations()
        {
            // Fixture setup
            var customizations = new List<ISpecimenBuilder>();
            var fixtureStub = new Mock<IFixture> { DefaultValue = DefaultValue.Mock };
            fixtureStub.SetupGet(c => c.Customizations).Returns(customizations);

            var sut = new AutoMoqCustomization();
            // Exercise system
            sut.Customize(fixtureStub.Object);
            // Verify outcome
            var postprocessor = customizations.OfType<MockPostprocessor>().Single();
            var ctorInvoker = Assert.IsAssignableFrom<MethodInvoker>(postprocessor.Builder);
            Assert.IsAssignableFrom<MockConstructorQuery>(ctorInvoker.Query);
            // Teardown
        }