示例#1
0
        public void Currency_ReturnsSingleCurrency()
        {
            //Arrange
            NBPController controller = new NBPController(GetFakeBankContextWithCurrencies());

            //Act
            Currency result = controller.Currency(1);

            //Assert
            Assert.AreEqual(result.ID, 1);
        }
示例#2
0
        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);
        }
示例#3
0
        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>());
        }
示例#4
0
        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);
        }
示例#5
0
        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));
        }
示例#6
0
 public HomeController()
 {
     NBPWebController = new NBPController();
 }