public void GetNextDate_DayOfMonth_Exact() { YearlyRecurrency yearly = new YearlyRecurrency(new DateTime(2012, 1, 01), new DateTime(2015, 11, 30), 1, 15, 3); Assert.AreEqual(new DateTime(2012, 1, 1), yearly.StartDate); Assert.AreEqual(new DateTime(2012, 3, 15), yearly.GetFirstDate()); Assert.AreEqual(new DateTime(2013, 3, 15), yearly.GetNextDate(new DateTime(2012, 3, 15))); Assert.AreEqual(new DateTime(2014, 3, 15), yearly.GetNextDate(new DateTime(2013, 3, 15))); Assert.AreEqual(new DateTime(2015, 3, 15), yearly.GetNextDate(new DateTime(2014, 3, 15))); Assert.IsNull(yearly.GetNextDate(new DateTime(2015, 3, 15))); }
public void GetNextDate_DayOfWeek_Exact() { // 2nd Tuesday in March YearlyRecurrency yearly = new YearlyRecurrency(new DateTime(2011, 2, 01), 4, 2, DayOfWeek.Tuesday, DayIndex.Second, 3); Assert.AreEqual(new DateTime(2011, 2, 1), yearly.StartDate); Assert.AreEqual(new DateTime(2011, 3, 8), yearly.GetFirstDate()); Assert.AreEqual(new DateTime(2013, 3, 12), yearly.GetNextDate(new DateTime(2011, 3, 8))); Assert.AreEqual(new DateTime(2015, 3, 10), yearly.GetNextDate(new DateTime(2013, 3, 12))); Assert.AreEqual(new DateTime(2017, 3, 14), yearly.GetNextDate(new DateTime(2015, 3, 10))); Assert.IsNull(yearly.GetNextDate(new DateTime(2017, 3, 14))); }
public void GetFirstDate_DayOfWeek() { // April 2011 // M T W T F S S // 1 2 3 // 4 5 6 7 8 9 10 // 11 12 13 14 15 16 17 // 18 19 20 21 22 23 24 // 25 26 27 28 29 30 YearlyRecurrency yearly = new YearlyRecurrency(new DateTime(2011, 1, 01), new DateTime(2011, 11, 30), 1, DayOfWeek.Tuesday, DayIndex.Third, 4); Assert.AreEqual(new DateTime(2011, 4, 19), yearly.GetFirstDate()); }
public void GetNextDate_DayOfWeek_Inexact() { // 2nd Tuesday in March YearlyRecurrency yearly = new YearlyRecurrency(new DateTime(2011, 2, 01), 4, 2, DayOfWeek.Tuesday, DayIndex.Second, 3); Assert.AreEqual(new DateTime(2011, 3, 8), yearly.GetFirstDate()); Assert.AreEqual(new DateTime(2011, 3, 8), yearly.GetNextDate(new DateTime(2010, 1, 1))); Assert.AreEqual(new DateTime(2011, 3, 8), yearly.GetNextDate(new DateTime(2010, 12, 31))); Assert.AreEqual(new DateTime(2011, 3, 8), yearly.GetNextDate(new DateTime(2011, 1, 1))); Assert.AreEqual(new DateTime(2011, 3, 8), yearly.GetNextDate(new DateTime(2011, 3, 7))); Assert.AreEqual(new DateTime(2013, 3, 12), yearly.GetNextDate(new DateTime(2011, 3, 8))); Assert.AreEqual(new DateTime(2013, 3, 12), yearly.GetNextDate(new DateTime(2011, 3, 9))); Assert.AreEqual(new DateTime(2013, 3, 12), yearly.GetNextDate(new DateTime(2011, 12, 31))); Assert.AreEqual(new DateTime(2013, 3, 12), yearly.GetNextDate(new DateTime(2012, 1, 1))); Assert.AreEqual(new DateTime(2013, 3, 12), yearly.GetNextDate(new DateTime(2012, 3, 8))); Assert.AreEqual(new DateTime(2013, 3, 12), yearly.GetNextDate(new DateTime(2012, 12, 31))); Assert.AreEqual(new DateTime(2013, 3, 12), yearly.GetNextDate(new DateTime(2013, 1, 1))); Assert.AreEqual(new DateTime(2013, 3, 12), yearly.GetNextDate(new DateTime(2013, 3, 11))); }
public void GetFirstDate_RollsIntoNextYear() { YearlyRecurrency yearly = new YearlyRecurrency(new DateTime(2011, 4, 20), new DateTime(2011, 11, 30), 1, 14, 4); Assert.AreEqual(new DateTime(2012, 4, 14), yearly.GetFirstDate()); // (2011, 4, 14) is before start date }
public void GetFirstDate_DayOfMonth() { YearlyRecurrency yearly = new YearlyRecurrency(new DateTime(2011, 2, 01), new DateTime(2011, 11, 30), 1, 14, 3); Assert.AreEqual(new DateTime(2011, 3, 14), yearly.GetFirstDate()); }