public async void PostLeft_OnSuccess_ShouldReturnResponseFromResponseCreated(string correlationId, BaseRequest <CreateLeftPayLoadRequest> request, CreatePayLoadResponse response, IActionResult actionResult) { _payLoadService.Create(correlationId, request.Data).Returns(response); _responseCreator.ResponseCreated(response).Returns(actionResult); var result = await _sut.Post(correlationId, request); result.Should().Be(actionResult); }
private async Task Should_request_and_handle_Exception() { _mediator.Setup(_mediatorSendResultRequest).Throws(new Exception("Id Not found.")); var controller = new DiffController(_mediator.Object); var result = await controller.Post(_id); _mediator.Verify(_mediatorSendResultRequest, Times.Once); Assert.True(result is BadRequestObjectResult); }
private async Task Should_request_diff() { _differResult.Setup(d => d.AreEqual).Returns(true); _differResult.Setup(d => d.Id).Returns(_id); var mediatrResult = Task.FromResult(_differResult.Object); _mediator.Setup(_mediatorSendResultRequest).Returns(mediatrResult); var controller = new DiffController(_mediator.Object); var result = await controller.Post(_id); _mediator.Verify(_mediatorSendResultRequest, Times.Once); Assert.True(result is OkObjectResult okResult && okResult.Value is IDifferResult diffResult && diffResult.AreEqual); }