public void FindPreviousTest() { DateTime now = ClockProxy.Clock.Now; DateTime currentCalendarYear = Now.CalendarYear; DateTime previousCalendarYear = currentCalendarYear.AddYears(-1); DateTimeSet dateTimeSet = new DateTimeSet(); Assert.Null(dateTimeSet.FindPrevious(now)); dateTimeSet.Add(currentCalendarYear); Assert.Equal(dateTimeSet.FindPrevious(now), now == currentCalendarYear ? (DateTime?)null : currentCalendarYear); dateTimeSet.Add(previousCalendarYear); Assert.Equal(dateTimeSet.FindPrevious(now), now == currentCalendarYear ? previousCalendarYear : currentCalendarYear); Assert.Equal(dateTimeSet.FindPrevious(currentCalendarYear), previousCalendarYear); dateTimeSet.Remove(currentCalendarYear); Assert.Equal(dateTimeSet.FindPrevious(now), previousCalendarYear); dateTimeSet.Remove(previousCalendarYear); Assert.Null(dateTimeSet.FindPrevious(now)); } // FindPreviousTest
public void FindPreviousTest() { DateTime now = ClockProxy.Clock.Now; DateTime currentCalendarYear = TimeTool.CurrentCalendarYear; DateTime previousCalendarYear = currentCalendarYear.AddYears(-1); DateTimeSet dateTimeSet = new DateTimeSet(); Assert.AreEqual(dateTimeSet.FindPrevious(now), null); dateTimeSet.Add(currentCalendarYear); Assert.AreEqual(dateTimeSet.FindPrevious(now), now == currentCalendarYear ? (DateTime?)null : currentCalendarYear); dateTimeSet.Add(previousCalendarYear); Assert.AreEqual(dateTimeSet.FindPrevious(now), now == currentCalendarYear ? previousCalendarYear : currentCalendarYear); Assert.AreEqual(dateTimeSet.FindPrevious(currentCalendarYear), previousCalendarYear); dateTimeSet.Remove(currentCalendarYear); Assert.AreEqual(dateTimeSet.FindPrevious(now), previousCalendarYear); dateTimeSet.Remove(previousCalendarYear); Assert.AreEqual(dateTimeSet.FindPrevious(now), null); }