Example #1
0
        public void CustomizeAddsAppropriateResidueCollector()
        {
            // Arrange
            var fixtureStub = new FixtureStub();

            var sut = new AutoMoqCustomization();

            // Act
            sut.Customize(fixtureStub);
            // Assert
            Assert.Contains(sut.Relay, fixtureStub.ResidueCollectors);
        }
Example #2
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);
        }
Example #3
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);
        }
Example #4
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);
        }
Example #5
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);
        }
Example #6
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);
        }