public async Task Create_WithdrawNonExistingAccount_ShouldReturnNotFound() { var request = new WithdrawCreateRequest { AccountId = 1, Ammount = 100, CustomerId = 2, Details = "Test", }; _mockMediator .Setup(m => m.Send(It.Is <WithdrawCreateRequest>(t => t.AccountId == request.AccountId && t.Ammount == request.Ammount && t.CustomerId == request.CustomerId && t.Details == request.Details), default)) .ThrowsAsync(new NotFoundException()) .Verifiable(); var controller = new WithdrawController(_mockMediator.Object); var result = await controller.Create(request); _mockMediator.Verify(); Assert.True(typeof(NotFoundObjectResult) == result.Result.GetType()); }
public async Task Create_WithdrawExistingAccount_ShouldReturnTransactions() { var request = new WithdrawCreateRequest { AccountId = 1, Ammount = 100, CustomerId = 2, Details = "Test", }; var transferTransactions = WithdrawTransactions(request); _mockMediator .Setup(m => m.Send(It.Is <WithdrawCreateRequest>(t => t.AccountId == request.AccountId && t.Ammount == request.Ammount && t.CustomerId == request.CustomerId && t.Details == request.Details), default)) .ReturnsAsync(transferTransactions) .Verifiable(); var controller = new WithdrawController(_mockMediator.Object); var result = await controller.Create(request); _mockMediator.Verify(); Assert.True(typeof(CreatedAtActionResult) == result.Result.GetType()); }
public void Whithdraw_amount_request_and_update_balance() { _controller.Create(new Account { Amount = 10 }); var transactions = _fileSystem.File.ReadAllLines(SafeDepositLocationTest).Where(x => x != "").ToArray(); var transactionsList = transactions.Select(ReadAccountBalance).OrderByDescending(x => x.Date); Assert.That(transactionsList.Select(x => x.Amount).First(), Is.EqualTo(-10)); Assert.That(transactionsList.Select(x => x.Balance).First(), Is.EqualTo(-35)); }