Example #1
0
        Exchange_WhenTargetCurrencyAccountExists_ConvertMoney_AndIncreaseBalanceOfTargetAccountWithProperAmount()
        {
            //arrange
            _context.Accounts.Add(CreateDefaultAccount("RO11BTRL", 20));
            _context.Accounts.Add(new Account()
            {
                Balance  = 0, Id = 2,
                OwnerId  = 1,
                Iban     = "RO12BTRL",
                Currency = "USD"
            });
            _context.SaveChanges();

            _currencyRateServiceMock.Setup(c => c.GetRate(It.IsAny <string>(), It.IsAny <string>())).Returns(1.1m);

            //act
            var result = _sut.Exchange(new ExchangeModel()
            {
                Amount         = 10,
                AccountNr      = "RO11BTRL",
                UserId         = 1,
                TargetCurrency = "USD"
            });

            //assert
            result.Amount.Should().Be(11);
        }
        public IActionResult CurrencyExchange(ExchangeModel model)
        {
            var result = _bankAccountApplicationService.Exchange(model);

            return(Ok(result));
        }