public async Task MakeDepositTest()
        {
            var dto = new ChangeBalanceDto
            {
                AccountId = new Guid("bd877de3-d2c9-4237-b5ca-08bd3ba56cd8"),
                Amount    = 200
            };
            var result = await _controller.MakeDeposit(dto);

            var contentResult = result as OkNegotiatedContentResult <BankAccount>;

            Assert.IsNotNull(contentResult);
            Assert.AreEqual(1200, _fakeContext.BankAccounts.ElementAt(0).Balance);
        }
        public async Task WithdrawalNotAllowedTest()
        {
            var dto = new ChangeBalanceDto()
            {
                AccountId = new Guid("bd877de3-d2c9-4237-b5ca-08bd3ba56cd8"),
                Amount    = 2000
            };

            var result = await _controller.Withdraw(dto);

            var badRequestResult = result as BadRequestErrorMessageResult;

            Assert.IsNotNull(badRequestResult);
            Assert.AreEqual("Insufficient funds", badRequestResult.Message);
        }
 public async Task <IHttpActionResult> Withdraw([FromBody] ChangeBalanceDto withdrawal)
 {
     return(await ChangeBalance(withdrawal.AccountId, -withdrawal.Amount));
 }
 public async Task <IHttpActionResult> MakeDeposit([FromBody] ChangeBalanceDto deposit)
 {
     return(await ChangeBalance(deposit.AccountId, deposit.Amount));
 }