public async Task CreateExchangeRateTest()
        {
            var defaultCurrency = new Currency
            {
                Id              = Guid.NewGuid(),
                Code            = "USD",
                DefaultCurrency = true,
                Description     = "USD1",
                Symbol          = "$"
            };

            var createModel = new CreateExchangeRateModel
            {
                CurrencyId = Guid.NewGuid(),
                Rate       = decimal.Parse("0.73")
            };
            var data = new List <Currency> {
                defaultCurrency
            };

            _dbContext.MockAsyncQueryable(data.AsQueryable(), c => c.Currency);

            _dbContext.MockAsyncQueryable(new List <ExchangeRate>().AsQueryable(), c => c.ExchangeRate);

            var result = await _service.CreateExchangeRate(createModel, _user);

            result.ToCurrency.Should().Be(defaultCurrency.Id);
        }
Пример #2
0
 public IActionResult AddExchangeRate(float rate, int currencyId)
 {
     exchangeRateService.CreateExchangeRate(currencyService.ReadCurrency(currencyId), rate);
     return(RedirectToAction("Details", "Currencies", new { id = currencyId }));
 }