Example #1
0
        public async Task SendRequestNotConnectedReceieveEndpoint()
        {
            // Arrange
            var responseModel = ResponseModelFake.GetResponseModelFake();
            var requestModel  = RequestModelFake.GetRequestModelFake();

            _busService.Request(Arg.Any <string>(), Arg.Any <ICommandMessage>(), Arg.Any <CancellationToken>())
            .Throws(new ReceiveEndpointNotConnectedException());

            // Act
            var response =
                _systemUnderTest.SendRequestAsync <RequestModelFake, ResponseModelFake>(requestModel,
                                                                                        CancellationToken.None);

            // Assert
            await Assert.ThrowsAsync <ReceiveEndpointNotConnectedException>(async() =>
                                                                            await _systemUnderTest.SendRequestAsync <RequestModelFake, ResponseModelFake>(requestModel,
                                                                                                                                                          CancellationToken.None));
        }
Example #2
0
        public async Task SendRequestSuccessful()
        {
            // Arrange
            var responseModel = ResponseModelFake.GetResponseModelFake();
            var requestModel  = RequestModelFake.GetRequestModelFake();

            _busService.Request(Arg.Any <string>(), Arg.Any <ICommandMessage>(), Arg.Any <CancellationToken>())
            .Returns(CommandMessageFake.GetCommandMessageFake(requestModel, responseModel));

            // Act
            var response =
                await _systemUnderTest.SendRequestAsync <RequestModelFake, ResponseModelFake>(requestModel,
                                                                                              CancellationToken.None);

            // Assert
            await _busService.Received()
            .Request(Arg.Any <string>(), Arg.Any <ICommandMessage>(), Arg.Any <CancellationToken>());

            Assert.Equal(10, response.Id);
            Assert.Equal("Dennis Hogström", response.Name);
        }