public void Currency_ReturnsSingleCurrency() { //Arrange NBPController controller = new NBPController(GetFakeBankContextWithCurrencies()); //Act Currency result = controller.Currency(1); //Assert Assert.AreEqual(result.ID, 1); }
public void CurrencyByCode_ReturnsSingleCurrencyByCurrencyCode() { //Arrange NBPController controller = new NBPController(GetFakeBankContextWithCurrencies()); string lookForCurrency = "USD"; //Act Currency result = controller.CurrencyByCode(lookForCurrency); //Assert Assert.AreEqual(lookForCurrency, result.Code); }
public void Currencies_ReturnsAllCurrencies() { //Arrange FakeBankContext mockContext = GetFakeBankContextWithCurrencies(); NBPController controller = new NBPController(mockContext); //Act IEnumerable<Currency> result = controller.Currencies(); //Assert Assert.AreEqual(result.Count<Currency>(), mockContext.Currencies.Count<Currency>()); }
public void RateForDateAndCurrency_ReturnsCurrencyRateForGivenCurrencyAndDate() { //Arrange DateTime date = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); FakeBankContext context = GetFakeBankContextWithCurrenciesAndRates(); NBPController controller = new NBPController(context); //Act CurrencyRate result1 = controller.RateForDateAndCurrency(1, date); //Assert Assert.AreEqual(result1.Rate, context.CurrencyRates.FirstOrDefault( c => c.ID == 1).Rate); Assert.AreEqual(result1.ID, context.CurrencyRates.FirstOrDefault(c => c.ID == 1).ID); }
public void RateWithTrendForDateAndCurrency_ReturnsCurrencyTrendForSpecificCurrencyAndDate() { //Arrange DateTime date = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); FakeBankContext context = GetFakeBankContextWithCurrenciesAndRates(); FakeNBPReader NBPReader = new FakeNBPReader(); NBPController controller = new NBPController(context,NBPReader); //Act CurrencyTrend result1 = controller.RateWithTrendForDateAndCurrency(1, date); CurrencyTrend result2 = controller.RateWithTrendForDateAndCurrency(1, date.AddDays(-1)); CurrencyTrend result3 = controller.RateWithTrendForDateAndCurrency(1, date.AddDays(-2)); CurrencyTrend result4 = controller.RateWithTrendForDateAndCurrency(1, date.AddDays(-10)); //Assert Assert.AreEqual(result1.Trend, CurrencyTrendResult.UP); Assert.AreEqual(result2.Trend, CurrencyTrendResult.DOWN); Assert.AreEqual(result3.Trend, CurrencyTrendResult.CONST); Assert.IsTrue(context.Currencies.Any(c => c.Code == "CUR1")); Assert.IsTrue(context.CurrencyRates.Any(c => c.Rate == 99.512)); }
public HomeController() { NBPWebController = new NBPController(); }