Exemple #1
0
        public void SelectExchangeRate()
        {
            ExchangeRateManager exchangeRateManager  = (ExchangeRateManager)container["ExchangeRateManager"];
            ExchangeRate        selectedExchangeRate = exchangeRateManager.Select(new DateTime(2008, 8, 8), new Currency {
                Id = 2
            });

            Assert.AreEqual(2, selectedExchangeRate.Rate);
        }
Exemple #2
0
        public void SelectExchangeRate_Null()
        {
            ExchangeRateManager exchangeRateManager = (ExchangeRateManager)container["ExchangeRateManager"];

            ExchangeRate selectedExchangeRate = exchangeRateManager.Select(new DateTime(3333, 2, 2), new Currency {
                Id = 1
            });

            Assert.IsNull(selectedExchangeRate);
        }
        public Dictionary <DateTime, List <double> > SelectExchangeRatesForASpecifiedMonth(int pMonth, int pYear, List <Currency> pCurrencies)
        {
            Dictionary <DateTime, List <double> > rates = new Dictionary <DateTime, List <double> >();

            DateTime date    = new DateTime(pYear, pMonth, 1);
            DateTime endDate = date.AddMonths(1);

            while (date < endDate)
            {
                List <double> list = new List <double>();
                foreach (Currency currency in pCurrencies)
                {
                    ExchangeRate rate = _rateManager.Select(date, currency) ?? new ExchangeRate {
                        Date = date, Rate = 0
                    };
                    list.Add(rate.Rate);
                }
                rates.Add(date, list);
                date = date.AddDays(1);
            }
            return(rates);
        }