public async Task TestAddExchangeRateIds() { var currenciesController = new CurrenciesController(); var gbp = await currenciesController.GetCurrencies("GBP"); var usd = await currenciesController.GetCurrencies("USD"); if (gbp.Value == null || usd.Value == null) { Assert.Fail(); } var exchangeRateToSend = new ExchangeRates { BaseCurrecncy = gbp.Value.Id, ConvertedCurrency = usd.Value.Id, ExchangeRate = 1 }; await exchangeRateController.AddExchangeRate(exchangeRateToSend); var exchangeRate = await exchangeRateController.GetExchangeRate(gbp.Value.Id, usd.Value.Id); if (exchangeRate.Value != null && exchangeRate.Value == exchangeRateToSend) { Assert.Pass(); } else { Assert.Fail(); } }
public async Task TestAddExchangeRateStrings() { await exchangeRateController.AddExchangeRate("GBP", "USD", 1); var currenciesController = new CurrenciesController(); var gbp = await currenciesController.GetCurrencies("GBP"); var usd = await currenciesController.GetCurrencies("USD"); if (gbp.Value == null || usd.Value == null) { Assert.Fail(); } var exchangeRate = await exchangeRateController.GetExchangeRate(gbp.Value.Id, usd.Value.Id); if (exchangeRate.Value != null && exchangeRate.Value.BaseCurrecncy == gbp.Value.Id && exchangeRate.Value.ConvertedCurrency == usd.Value.Id) { Assert.Pass(); } else { Assert.Fail(); } }
public async Task TestEditCurrency() { List <Currencies> currenciesToAdd = new List <Currencies>(); currenciesToAdd.Add(new Currencies() { Exponent = 2, Symbol = "&", Name = "Test1" }); await AddCurrency(currenciesToAdd); var currencies = await currenciesController.GetCurrencies(); var currencyToEdit = currencies.Value.First(); currencyToEdit.Name = currencyToEdit.Name + "Edited"; await currenciesController.UpdateCurrency(currencyToEdit); var returnedCurrency = await currenciesController.GetCurrencies(currencyToEdit.Name); if (currencyToEdit != returnedCurrency.Value) { Assert.Fail(); } else { Assert.Pass(); } }
public void TestGetByIdMoq() { // Arrange var repo = new Mock <IRepository <Currency> >(); repo.Setup(r => r.GetAll()).Returns( new List <Currency> { new Currency { Id = 1, Code = "GBP" }, new Currency { Id = 2, Code = "EUR" } }.AsQueryable() ); var uow = new Mock <IExpensesUow>(); uow.SetupGet(u => u.Currencies).Returns(repo.Object); var ctrlr = new CurrenciesController(uow.Object); // Act var currencies = ctrlr.GetCurrencies(); // Assert Assert.AreEqual(5, currencies.Count()); }
public void GetShouldReturnCurrencies() { //arrange CurrenciesController controller = new CurrenciesController(); //act ActionResult <IEnumerable <string> > result = controller.GetCurrencies(); //assert result.Value.Should().BeEquivalentTo("usd", "eur", "yen", "btc"); }
public async Task AddCurrency(List <Currencies> currencies) { var currenciesController = new CurrenciesController(); for (int i = 0; i < currencies.Count; i++) { await currenciesController.AddCurrency(currencies[i]); var returnedCurrency = await currenciesController.GetCurrencies(currencies[i].Name); if (currencies[i] != returnedCurrency.Value) { Assert.Fail(); } } }