示例#1
0
        public void CallEnvironmentOverrideApplicatorAndApplicationBindingValidatorBeforeCustomVisitor()
        {
            var visitorMock = new Mock <IApplicationBindingVisitor>();

            var applicationBindingMock          = new Mock <IApplicationBinding <string> >(MockBehavior.Strict);
            var visitableApplicationBindingMock = applicationBindingMock.As <IVisitable <IApplicationBindingVisitor> >();

            var sequence = new MockSequence();

            visitableApplicationBindingMock.InSequence(sequence)
            .Setup(m => m.Accept(It.IsAny <EnvironmentOverrideApplicator>()))
            .Returns(It.IsAny <EnvironmentOverrideApplicator>());
            visitableApplicationBindingMock.InSequence(sequence)
            .Setup(m => m.Accept(It.IsAny <ApplicationBindingValidator>()))
            .Returns(It.IsAny <ApplicationBindingValidator>());
            visitableApplicationBindingMock.InSequence(sequence)
            .Setup(m => m.Accept(visitorMock.Object))
            .Returns(visitorMock.Object);

            var pipelineMock = new Mock <VisitorPipeline <string> >(applicationBindingMock.Object);
            var sut          = new PreprocessingStage <string>(pipelineMock.Object);

            sut.Accept(visitorMock.Object);

            visitableApplicationBindingMock.Verify(m => m.Accept(It.IsAny <EnvironmentOverrideApplicator>()), Times.Once);
            visitableApplicationBindingMock.Verify(m => m.Accept(It.IsAny <ApplicationBindingValidator>()), Times.Once);
            visitableApplicationBindingMock.Verify(m => m.Accept(visitorMock.Object), Times.Once);
        }
示例#2
0
        public void AdvanceVisitorPipelineStage()
        {
            var applicationBindingMock          = new Mock <IApplicationBinding <string> >(MockBehavior.Strict);
            var visitableApplicationBindingMock = applicationBindingMock.As <IVisitable <IApplicationBindingVisitor> >();
            var visitorPipeline = new VisitorPipeline <string>(applicationBindingMock.Object);

            visitableApplicationBindingMock
            .Setup(m => m.Accept(It.IsAny <IApplicationBindingVisitor>()))
            // ProcessingStage is used for each visitor called in sequence
            .Callback(() => visitorPipeline.Stage.Should().BeOfType <ProcessingStage <string> >())
            .Returns(It.IsAny <IApplicationBindingVisitor>());

            var sut = new PreprocessingStage <string>(visitorPipeline);

            sut.Accept(new Mock <IApplicationBindingVisitor>().Object);

            // PreprocessingStage is restored once all the visitors have done their processing
            visitorPipeline.Stage.Should().BeSameAs(sut);
        }