public async Task Deposit_WithCorrectRequest_ReturnSuccessTransactionsResult() { // Arrange var depositRequest = new DepositRequest { AccountIban = "TH123456", Amount = 1000, }; var transactionsResult = new TransactionsResult { Success = true }; transactionsService .DepositAsync(Arg.Any <DepositRequest>()) .Returns(Task.FromResult(transactionsResult)); // Act var actionResult = await transactionsController.Deposit(depositRequest); var objectResult = actionResult as OkObjectResult; // Assert Assert.NotNull(objectResult); Assert.Equal((int)System.Net.HttpStatusCode.OK, objectResult.StatusCode); Assert.True((objectResult.Value as TransactionsResult).Success); }
public async Task <IActionResult> Deposit([FromBody] DepositRequest depositRequest) { if (depositRequest == null) { return(BadRequest(ModelState)); } var transactionsResult = await transactionsService.DepositAsync(depositRequest); return(Ok(transactionsResult)); }