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(); }
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); }
public void FetchComponentFromComponentList() { var component = new FailedMessageRoutingEnablerComponent(); var list = new ComponentList(new Stage(StageCategory.Decoder.Id, PolicyFile.BTSReceivePolicy.Value)) { component }; list.Component <FailedMessageRoutingEnablerComponent>().Should().BeSameAs(component); }
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)); }
public void FetchComponentFromComponentList() { var component = new FailedMessageRoutingEnablerComponent(); var list = new ComponentList(new Stage(StageCategory.Decoder.Id)) { component }; Assert.That(list.Component <FailedMessageRoutingEnablerComponent>(), Is.SameAs(component)); }
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."); }
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(); }
public void ReflectCategoryFromPipelineComponent() { var component = new FailedMessageRoutingEnablerComponent(); Assert.That(component.GetStageCategories(), Contains.Item(StageCategory.Any)); }
public void ReflectCategoryFromPipelineComponent() { var component = new FailedMessageRoutingEnablerComponent(); component.GetStageCategories().Should().Contain(StageCategory.Any); }