public void TestInitialize()
        {
            Mock <IServiceLocator> serviceLocator = new Mock <IServiceLocator>();

            serviceLocator.Setup(m => m.GetServiceUrl("TestService")).Returns("pipe://testUrl/TestService");

            this.messenger = new MessengerMock();

            Mock <IMessengerFactory> messengerFactory = new Mock <IMessengerFactory>();

            messengerFactory.Setup(m => m.GetMessenger(It.IsAny <string>())).Returns(this.messenger);
            this.serviceFactory = new ServiceInterfaceFactory(serviceLocator.Object, messengerFactory.Object);
        }
예제 #2
0
        public void ServiceDispatcher_RoutTest()
        {
            var messenger      = new MessengerMock();
            var channelFactory = new ChannelConnectNotifierMock(messenger);
            var service        = new TestService();
            var dispatcher     = new Router(new Multiplexer(channelFactory));

            dispatcher.AddRoute("Test/route", service);

            channelFactory.ConnectPipe();

            var msg           = Message.CreateRequest("Test/route");
            var packedMessage = Envelope.Pack(msg, "TestService");

            messenger.ClientSend(packedMessage);

            Assert.AreEqual(msg.ToString(), service.RequestMessage.ToString());
            Assert.AreEqual(Envelope.Pack(service.ResponseMessage, string.Empty), messenger.SendMessage);
        }