Exemplo n.º 1
0
        public void Transfer_IncreasesTargetBalanceByAmount_AndDecreasesSourceBalanceByAmountPlus2PErcentCommission()
        {
            //arrange
            _context.Accounts.Add(
                new Account()
            {
                Balance  = 200,
                Id       = 1,
                OwnerId  = 1,
                Iban     = "RO10",
                Currency = "RON"
            });
            _context.Accounts.Add(new Account()
            {
                Balance  = 10,
                Id       = 2,
                OwnerId  = 1,
                Iban     = "RO11",
                Currency = "RON",
                IsActive = true
            });
            _context.SaveChanges();

            //act
            _sut.Transfer(new TransferMoneyModel()
            {
                Amount   = 100,
                IbanFrom = "RO10",
                IbanTo   = "RO11"
            });

            _context.Accounts.FirstOrDefault(a => a.Iban == "RO11").Balance.Should().Be(110);
            _context.Accounts.FirstOrDefault(a => a.Iban == "RO10").Balance.Should().Be(98);
        }
Exemplo n.º 2
0
        public IActionResult TransferMoney(TransferMoneyModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _bankAccountApplicationService.Transfer(model);

            return(Ok());
        }