public void SpecifyAtLeastOneDownstream()
        {
            var destination = Substitute.For <IUpstreamHandler>();
            var pipeline    = new Decoupled.Pipeline.Pipeline();

            Assert.Throws <InvalidOperationException>(() => pipeline.Start());
        }
        public void SpecifyAtLeastOneDownstream()
        {
            var destination = Substitute.For<IUpstreamHandler>();
            var pipeline = new Decoupled.Pipeline.Pipeline();

            Assert.Throws<InvalidOperationException>(() => pipeline.Start());
        }
        public void Destination_IsInvoked()
        {
            var handler = Substitute.For<IUpstreamHandler>();
            var downHandler = Substitute.For<IDownstreamHandler>();
            var pipeline = new Decoupled.Pipeline.Pipeline();
            var context = new DownstreamContext(downHandler);
            var msg = Substitute.For<IUpstreamMessage>();

            pipeline.Add(context);
            pipeline.Add(new UpstreamContext(handler));
            pipeline.Start();
            context.SendUpstream(msg);

            handler.Received().HandleUpstream(Arg.Any<IUpstreamContext>(), msg);
        }
        public void Destination_IsInvoked()
        {
            var handler     = Substitute.For <IUpstreamHandler>();
            var downHandler = Substitute.For <IDownstreamHandler>();
            var pipeline    = new Decoupled.Pipeline.Pipeline();
            var context     = new DownstreamContext(downHandler);
            var msg         = Substitute.For <IUpstreamMessage>();

            pipeline.Add(context);
            pipeline.Add(new UpstreamContext(handler));
            pipeline.Start();
            context.SendUpstream(msg);

            handler.Received().HandleUpstream(Arg.Any <IUpstreamContext>(), msg);
        }
        public void DestinationIsNotSet()
        {
            var upContext = new UpstreamContext(new ForwardingUpHandler());
            var destination = Substitute.For<IUpstreamHandler>();
            var downHandler = Substitute.For<IDownstreamHandler>();
            var downContext = new DownstreamContext(downHandler);
            var pipeline = new Decoupled.Pipeline.Pipeline();
            var msg = Substitute.For<IUpstreamMessage>();

            pipeline.Add(downContext);
            pipeline.Add(upContext);
            pipeline.Add(new UpstreamContext(destination));
            pipeline.Start();
            upContext.Invoke(msg);

            destination.Received().HandleUpstream(Arg.Any<IUpstreamContext>(), msg);
        }
        public void DestinationIsNotSet()
        {
            var upContext   = new UpstreamContext(new ForwardingUpHandler());
            var destination = Substitute.For <IUpstreamHandler>();
            var downHandler = Substitute.For <IDownstreamHandler>();
            var downContext = new DownstreamContext(downHandler);
            var pipeline    = new Decoupled.Pipeline.Pipeline();
            var msg         = Substitute.For <IUpstreamMessage>();

            pipeline.Add(downContext);
            pipeline.Add(upContext);
            pipeline.Add(new UpstreamContext(destination));
            pipeline.Start();
            upContext.Invoke(msg);

            destination.Received().HandleUpstream(Arg.Any <IUpstreamContext>(), msg);
        }
 public void NotStarted()
 {
     var pipeline = new Decoupled.Pipeline.Pipeline();
     Assert.Throws<InvalidOperationException>(() => pipeline.Send(new DispatchCommand(new FakeCommand())));
 }
        public void NotStarted()
        {
            var pipeline = new Decoupled.Pipeline.Pipeline();

            Assert.Throws <InvalidOperationException>(() => pipeline.Send(new DispatchCommand(new FakeCommand())));
        }