Exemple #1
0
        public void Should_publish_request_with_address()
        {
            // Arrange
            var routeFinder = Substitute.For <IRpcRouteFinder>();

            routeFinder.RequestQueue.Returns("RequestQueue");
            InternalDependencies.RpcQueueHelper = Substitute.For <IRpcQueueHelper>();
            var client = new BurrowRpcClientCoordinator <ISomeService>(null, routeFinder);

            var res = new RpcRequest
            {
                MethodName    = "TryParse",
                Id            = Guid.NewGuid(),
                UtcExpiryTime = DateTime.UtcNow.AddSeconds(20),
            };

            tunnel.When(x => x.Publish(Arg.Any <RpcRequest>(), Arg.Any <string>()))
            .Do(callInfo =>
            {
                var waithHandler = client.GetCachedWaitHandlers()[res.Id];
                waithHandler.WaitHandle.Set();
                waithHandler.Response = new RpcResponse {
                    ChangedParams = new Dictionary <string, object> {
                        { "result", "1000" }
                    }
                };
            });
            // Action
            client.Send(res);

            // Assert
            tunnel.Received(1).Publish(Arg.Any <RpcRequest>(), "RequestQueue");
        }