public async Task WithdrawalTest() { var dto = new ChangeBalanceDto { AccountId = new Guid("bd877de3-d2c9-4237-b5ca-08bd3ba56cd8"), Amount = 200 }; var result = await _controller.Withdraw(dto); var contentResult = result as OkNegotiatedContentResult <BankAccount>; Assert.IsNotNull(contentResult); Assert.AreEqual(800, _fakeContext.BankAccounts.ElementAt(0).Balance); }
public async Task wthdraw_usd_10000_should_not_work() { DepositWithDrawViewModel model = new DepositWithDrawViewModel { AccountNumber = "3355-3346-1466-7893", Amount = 10000, Currency = "USD" }; _mockBankAccountService.Setup(x => x.GetFunds(model.AccountNumber, "USD")).Returns(Task.FromResult <double>(5434)); var response = await _bancAccountController.Withdraw(model) as HttpResponseMessage; var content = response.Content as ObjectContent; ResponseMessage responseMessage = content.Value as ResponseMessage; responseMessage.Message.Should().Be("Not Enough funds"); responseMessage.Successfull.Should().BeFalse(); }
public void BankAccount_Controller_Withdraw_ShouldBeOk() { //Arrange var wasWithdrawn = true; var value = 100; var bankAccount = ObjectMother.BankAccountWithClientWithId(_mockClient.Object); _mockBankAccountService.Setup(bas => bas.Withdraw(bankAccount.Id, value)).Returns(wasWithdrawn); //Action IHttpActionResult callback = _bankAccountController.Withdraw(bankAccount.Id, value); //Assert var httpResponse = callback.Should().BeOfType <OkNegotiatedContentResult <bool> >().Subject; _mockBankAccountService.Verify(bas => bas.Withdraw(bankAccount.Id, value), Times.Once); }