Beispiel #1
0
        public void ShouldBeAbleToUnicastAMessageAndReceiveAResponse()
        {
            var sampleClusterConfiguration = BuildSampleClusterConfiguration();

            // Start a test server to listen for requests
            SampleResponse serverResponse = new SampleResponse("test response");
            var            testServer     = new TestServer(sampleClusterConfiguration.Nodes[0], serverResponse);

            testServer.Start();

            var sut = new NetMqRpcChannel(sampleClusterConfiguration, TimeSpan.FromMilliseconds(200));

            var sampleRequest = new SampleRequest("test");

            var responseReturned = sut.Unicast <SampleRequest, SampleResponse>(sampleClusterConfiguration.Nodes[0].Id, sampleRequest);

            Assert.IsNotNull(responseReturned);
            Assert.AreEqual(serverResponse, responseReturned);
            Assert.AreEqual(sampleRequest, testServer.GetLastReceivedMessageObject <SampleRequest>());
        }
        public void ShouldBeAbleToUnicastAMessageAndReceiveAResponse()
        {
            var sampleClusterConfiguration = BuildSampleClusterConfiguration();

            // Start a test server to listen for requests
            SampleResponse serverResponse = new SampleResponse("test response");
            var testServer = new TestServer(sampleClusterConfiguration.Nodes[0], serverResponse);
            testServer.Start();

            var sut = new NetMqRpcChannel(sampleClusterConfiguration, TimeSpan.FromMilliseconds(200));

            var sampleRequest = new SampleRequest("test");

            var responseReturned = sut.Unicast<SampleRequest, SampleResponse>(sampleClusterConfiguration.Nodes[0].Id, sampleRequest);

            Assert.IsNotNull(responseReturned);
            Assert.AreEqual(serverResponse, responseReturned);
            Assert.AreEqual(sampleRequest, testServer.GetLastReceivedMessageObject<SampleRequest>());
        }