Exemple #1
0
        public void EnsureUniqueComponentSucceedsIfStageExecutionMethodIsNotAll()
        {
            var stage     = new Stage(StageCategory.DisassemblingParser.Id, PolicyFile.BTSReceivePolicy.Value);
            var component = new XmlDasmComp();

            stage.AddComponent(component);

            Action(() => stage.AddComponent(component)).Should().NotThrow();
        }
Exemple #2
0
        public void EnsureUniqueComponentThrowsIfStageExecutionMethodIsAll()
        {
            var stage     = new Stage(StageCategory.Decoder.Id, PolicyFile.BTSReceivePolicy.Value);
            var component = new FailedMessageRoutingEnablerComponent();

            stage.AddComponent(component);

            Action(() => stage.AddComponent(component))
            .Should().Throw <ArgumentException>()
            .WithMessage($"Stage 'Decoder' has multiple '{component.GetType().FullName}' components.");
        }
Exemple #3
0
        public void WalkVisitorAccordingToPrescribedPath()
        {
            var failedMessageRoutingEnablerComponent = new FailedMessageRoutingEnablerComponent();
            var microPipelineComponent = new MicroPipelineComponent();

            var sut = new Stage(StageCategory.Any.Id, PolicyFile.BTSTransmitPolicy.Value);

            sut.AddComponent(failedMessageRoutingEnablerComponent)
            .AddComponent(microPipelineComponent);

            var visitor  = new Mock <IPipelineVisitor>(MockBehavior.Strict);
            var sequence = new MockSequence();

            visitor.InSequence(sequence).Setup(v => v.VisitStage(sut));
            visitor.InSequence(sequence).Setup(
                v => v.VisitComponent(
                    It.Is <PipelineComponentDescriptor <FailedMessageRoutingEnablerComponent> >(
                        c => ReferenceEquals((FailedMessageRoutingEnablerComponent)c, failedMessageRoutingEnablerComponent)))
                );
            visitor.InSequence(sequence).Setup(
                v => v.VisitComponent(
                    It.Is <PipelineComponentDescriptor <MicroPipelineComponent> >(
                        c => ReferenceEquals((MicroPipelineComponent)c, microPipelineComponent)))
                );

            ((IVisitable <IPipelineVisitor>)sut).Accept(visitor.Object);

            visitor.Verify();
        }
Exemple #4
0
        public void FetchComponentFromStage()
        {
            var stage     = new Stage(StageCategory.Decoder.Id, PolicyFile.BTSReceivePolicy.Value);
            var component = new FailedMessageRoutingEnablerComponent();

            stage.AddComponent(component);

            stage.Component <FailedMessageRoutingEnablerComponent>().Should().BeSameAs(component);
        }
Exemple #5
0
        public void FetchComponentFromStage()
        {
            var component = new FailedMessageRoutingEnablerComponent();

            var stage = new Stage(StageCategory.Decoder.Id);

            stage.AddComponent(component);

            Assert.That(stage.Component <FailedMessageRoutingEnablerComponent>(), Is.SameAs(component));
        }
Exemple #6
0
        public void EnsureAtMostComponentThrows()
        {
            var pipelinePolicy = new PipelinePolicy {
                Stages =
                {
                    new StagePolicy {
                        StageIdGuid     = StageCategory.AssemblingSerializer.Id.ToString(),
                        ExecutionMethod = ExecMethod.FirstMatch,
                        MaxOccurs       = 1
                    }
                }
            };
            var stage     = new Stage(StageCategory.AssemblingSerializer.Id, pipelinePolicy);
            var component = new XmlAsmComp();

            stage.AddComponent(component);
            stage.AddComponent(component);

            Action(() => stage.As <IVisitable <IPipelineVisitor> >().Accept(new Mock <IPipelineVisitor>().Object))
            .Should().Throw <ArgumentException>()
            .WithMessage("Stage 'AssemblingSerializer' should contain at most 1 components.");
        }
Exemple #7
0
        public void VisitorWalkedPath()
        {
            var failedMessageRoutingEnablerComponent = new FailedMessageRoutingEnablerComponent();
            var messageConsumerComponent             = new MessageConsumerComponent();

            var sut = new Stage(StageCategory.Any.Id);

            sut.AddComponent(failedMessageRoutingEnablerComponent)
            .AddComponent(messageConsumerComponent);

            // workaround Moq's inability to verify that calls have proceeded in a prescribed order. following recursive
            // setups simply ensure the calls are made in a specific order; as first call is matched we setup the second
            // call in the first call's callback, then when second call is matched we setup the third call in the second
            // call's callback, and so on and on... until we have setup all the expected calls. notice that for this
            // workaround to work the Mock's behavior must be *MockBehavior.Strict* or else any call missed would be
            // unnoticed (and all its consecutive calls as well since they would not have been setup via its callback).
            var visitor = new Mock <IPipelineVisitor>(MockBehavior.Strict);

            // ReSharper disable ImplicitlyCapturedClosure
            visitor.Setup(v => v.VisitStage(sut))
            // ReSharper restore ImplicitlyCapturedClosure
            .Callback(
                () => visitor.Setup(
                    v => v.VisitComponent(
                        It.Is <PipelineComponentDescriptor <FailedMessageRoutingEnablerComponent> >(
                            // ReSharper disable SuspiciousTypeConversion.Global
                            c => ReferenceEquals((FailedMessageRoutingEnablerComponent)c, failedMessageRoutingEnablerComponent)
                            // ReSharper restore SuspiciousTypeConversion.Global
                            )
                        )
                    )
                .Callback(
                    () => visitor.Setup(
                        v => v.VisitComponent(
                            It.Is <PipelineComponentDescriptor <MessageConsumerComponent> >(
                                // ReSharper disable SuspiciousTypeConversion.Global
                                c => ReferenceEquals((MessageConsumerComponent)c, messageConsumerComponent)
                                // ReSharper restore SuspiciousTypeConversion.Global
                                )
                            )
                        )
                    )
                );

            ((IVisitable <IPipelineVisitor>)sut).Accept(visitor.Object);

            visitor.Verify();
        }