public void HostRouter_HostNotAvailable()
        {
            HostRouter hostRouter = new HostRouter();

            var    message     = Message.CreateRequest("someRequest");
            string jsonMessage = Envelope.Pack(message, "host1");

            hostRouter.Send(jsonMessage);
        }
        public void HostRouter_DispatchMessageTest()
        {
            HostRouter        hostRouter = new HostRouter();
            Mock <IMessenger> messenger1 = new Mock <IMessenger>();
            Mock <IMessenger> messenger2 = new Mock <IMessenger>();

            hostRouter.AddConnection("host1", () => messenger1.Object);
            hostRouter.AddConnection("host2", () => messenger2.Object);

            var    message     = Message.CreateRequest("someRequest");
            string jsonMessage = Envelope.Pack(message, "host1");

            hostRouter.Send(jsonMessage);
            messenger1.Verify(m => m.Send(jsonMessage), Times.Exactly(1));
            messenger2.Verify(m => m.Send(jsonMessage), Times.Exactly(0));
        }
        public void HostRouter_MessengerDisposedTest()
        {
            HostRouter        hostRouter      = new HostRouter();
            Mock <IMessenger> messenger       = new Mock <IMessenger>();
            string            responseMessage = null;

            hostRouter.MessageReceived += (sender, @event) => responseMessage = @event.Message;
            messenger.Setup(m => m.Send(It.IsAny <string>())).Callback(() => { throw new ObjectDisposedException(string.Empty); });
            hostRouter.AddConnection("host1", () => messenger.Object);

            var    message     = Message.CreateRequest("someRequest");
            string jsonMessage = Envelope.Pack(message, "host1");

            hostRouter.Send(jsonMessage);

            WaitHelpers.WaitUntil(() => responseMessage != null);
        }