public void TestGetExchangeRateOn() { var targetDate = new DateTime(2012, 10, 5, 8, 0, 0); var stockExchange = new StockExchange(); stockExchange.AddExchangeRate(StockExchange.ExchangeRate(targetDate.AddDays(-2), "CHF", "USD", 2.0M)); stockExchange.AddExchangeRate(StockExchange.ExchangeRate(new DateTime(2012, 12, 7, 7, 0, 0), "CHF", "USD", 2.1M)); stockExchange.AddExchangeRate(StockExchange.ExchangeRate(new DateTime(2013, 2, 8, 8, 0, 0), "CHF", "USD", 2.2M)); Assert.AreEqual(stockExchange.GetExchangeRateOn("CHF", "USD", targetDate), StockExchange.ExchangeRate(targetDate.AddDays(-2), "CHF", "USD", 2.0M)); Assert.AreEqual(stockExchange.GetExchangeRateOn("CHF", "CAD", targetDate), null); }