コード例 #1
0
        public void When_Calling_A_Server_Via_The_Command_Processor_With_No_Timeout()
        {
            var exception = Catch.Exception(() => _commandProcessor.Call <MyRequest, MyResponse>(_myRequest, 0));

            //should throw an exception as we require a timeout to be set
            exception.Should().BeOfType <InvalidOperationException>();
        }
        public void When_Calling_A_Server_Via_The_Command_Processor_With_No_Out_Mapper()
        {
            var exception = Catch.Exception(() => _commandProcessor.Call <MyRequest, MyResponse>(_myRequest, 500));

            //should throw an exception as we require a mapper for the outgoing request
            exception.Should().BeOfType <ArgumentOutOfRangeException>();
        }
        public void When_Calling_A_Server_Via_The_Command_Processor()
        {
            _commandProcessor.Call <MyRequest, MyResponse>(_myRequest, 500);

            //should send a message via the messaging gateway
            _fakeMessageProducer.MessageWasSent.Should().BeTrue();

            //should convert the command into a message
            _fakeMessageProducer.SentMessages[0].Should().Be(_message);

            //should forward response to a handler
            MyResponseHandler.ShouldReceive(new MyResponse(_myRequest.ReplyAddress)
            {
                Id = _myRequest.Id
            });
        }