public void TestWeekendAfterEnd() { //DateTime startDate = new DateTime(2021, 4, 21); //DateTime startDate = new DateTime(2021, 4, 21); DateTime startDate = new DateTime(2021, 4, 28); int count = 5; //WeekEnd[] weekends = new WeekEnd[2] //{ // new WeekEnd(new DateTime(2021, 4, 23), new DateTime(2021, 4, 25)), // new WeekEnd(new DateTime(2021, 4, 29), new DateTime(2021, 4, 29)) //}; //WeekEnd[] weekends = new WeekEnd[2] //{ // new WeekEnd(new DateTime(2021, 4, 23), new DateTime(2021, 4, 25)), // new WeekEnd(new DateTime(2021, 4, 28), new DateTime(2021, 4, 28)) //}; WeekEnd[] weekends = new WeekEnd[3] { new WeekEnd(new DateTime(2021, 4, 20), new DateTime(2021, 4, 21)), new WeekEnd(new DateTime(2021, 4, 28), new DateTime(2021, 4, 28)), new WeekEnd(new DateTime(2021, 4, 29), new DateTime(2021, 4, 29)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); //Assert.IsTrue(result.Equals(new DateTime(2021, 4, 28))); //Assert.IsTrue(result.Equals(new DateTime(2021, 4, 29))); Assert.IsTrue(result.Equals(new DateTime(2021, 5, 4))); }
public void TestMiddleWeekEnd() { DateTime startDate = new DateTime(2019, 9, 15); int count = 4; WeekEnd[] weekends = new WeekEnd[1] { new WeekEnd(new DateTime(2019, 9, 12), new DateTime(2019, 9, 17)), }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2019, 9, 21))); }
public void TestEmpty() { DateTime startDate = new DateTime(2017, 4, 21); int count = 5; WeekEnd[] weekends = new WeekEnd[0] { }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 4, 25))); }
public void TestFewMonths() { DateTime startDate = new DateTime(2019, 9, 25); int count = 10; WeekEnd[] weekends = new WeekEnd[2] { new WeekEnd(new DateTime(2019, 9, 27), new DateTime(2019, 10, 28)), new WeekEnd(new DateTime(2019, 11, 1), new DateTime(2019, 11, 5)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2019, 11, 10))); }
public void TestWeekendBeforeStart()//maybe the period will start over the weekend { DateTime startDate = new DateTime(2017, 4, 21); int count = 5; WeekEnd[] weekends = new WeekEnd[1] { new WeekEnd(new DateTime(2017, 4, 20), new DateTime(2017, 4, 22)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 4, 27))); }
public void TestWeekEndStartBeforeAndEndAfterStartDate() { DateTime startDate = new DateTime(2015, 4, 21); int count = 5; WeekEnd[] weekends = new WeekEnd[1] { new WeekEnd(new DateTime(2015, 4, 19), new DateTime(2015, 4, 23)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2015, 4, 27))); }
public void TestSameStartEndDates() { DateTime startDate = new DateTime(2012, 2, 1); int count = 10; WeekEnd[] weekends = new WeekEnd[1] { new WeekEnd(new DateTime(2012, 2, 5), new DateTime(2012, 2, 5)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2012, 2, 11))); }
public void TestOutOfRange() { DateTime startDate = new DateTime(2017, 4, 21); int count = 5; WeekEnd[] weekends = new WeekEnd[] { new WeekEnd(new DateTime(2017, 5, 28), new DateTime(2017, 5, 30)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(startDate.AddDays(count - 1))); }
public void TestIntervalInsideWeekend() { DateTime startDate = new DateTime(2017, 4, 21); int count = 5; WeekEnd[] weekends = new WeekEnd[1] { new WeekEnd(new DateTime(2017, 4, 20), new DateTime(2017, 4, 29)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 5, 4))); }
public void TestTwoDaysWeekend() { DateTime startDate = new DateTime(2019, 3, 27); int count = 2; WeekEnd[] weekends = new WeekEnd[1] { new WeekEnd(new DateTime(2019, 3, 28), new DateTime(2019, 3, 29)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2019, 3, 30))); }
public void TestNormalTwoMonthsLeapYear() { DateTime startDate = new DateTime(2019, 2, 27); int count = 5; WeekEnd[] weekends = new WeekEnd[1] { new WeekEnd(new DateTime(2019, 2, 28), new DateTime(2019, 3, 1)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2019, 3, 5))); }
public void TestNormalPath() { DateTime startDate = new DateTime(2017, 4, 21); int count = 5; WeekEnd[] weekends = new WeekEnd[1] { new WeekEnd(new DateTime(2017, 4, 23), new DateTime(2017, 4, 25)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 4, 28))); }
public void TestFirstDayEqualWeekends() { DateTime startDate = new DateTime(2017, 4, 21); int count = 1; WeekEnd[] weekends = new WeekEnd[1] { new WeekEnd(new DateTime(2017, 4, 21), new DateTime(2017, 4, 21)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 4, 23))); }
public void TestStartDateInAnotherMonth() { DateTime startDate = new DateTime(2017, 4, 21); int count = 20; WeekEnd[] weekends = new WeekEnd[2] { new WeekEnd(new DateTime(2017, 5, 1), new DateTime(2017, 5, 2)), new WeekEnd(new DateTime(2017, 5, 8), new DateTime(2017, 5, 10)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 5, 12))); }
public void TestWeekendsStartFromStartDate() { DateTime startDate = new DateTime(2017, 4, 21); int count = 5; WeekEnd[] weekends = new WeekEnd[2] { new WeekEnd(new DateTime(2017, 4, 21), new DateTime(2017, 4, 25)), new WeekEnd(new DateTime(2017, 4, 29), new DateTime(2017, 4, 29)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 5, 1))); }
public void TestDoubleWeekends() { DateTime startDate = new DateTime(2017, 4, 1); int count = 10; WeekEnd[] weekends = new WeekEnd[2] { new WeekEnd(new DateTime(2017, 4, 2), new DateTime(2017, 4, 4)), new WeekEnd(new DateTime(2017, 4, 6), new DateTime(2017, 4, 7)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 4, 15))); }
public void TestConsecutiveWeekends() { DateTime startDate = new DateTime(2017, 4, 10); int count = 7; WeekEnd[] weekends = new WeekEnd[2] { new WeekEnd(new DateTime(2017, 4, 13), new DateTime(2017, 4, 15)), new WeekEnd(new DateTime(2017, 4, 16), new DateTime(2017, 4, 17)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 4, 21))); }
public void TestStartOnWeekend() { DateTime startDate = new DateTime(2017, 4, 10); int count = 7; WeekEnd[] weekends = new WeekEnd[2] { new WeekEnd(new DateTime(2017, 4, 8), new DateTime(2017, 4, 12)), new WeekEnd(new DateTime(2017, 4, 17), new DateTime(2017, 4, 18)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 4, 21))); }
public void TestWeekendBeforeStart() { DateTime startDate = new DateTime(2017, 4, 10); int count = 7; WeekEnd[] weekends = new WeekEnd[2] { new WeekEnd(new DateTime(2017, 4, 7), new DateTime(2017, 4, 9)), new WeekEnd(new DateTime(2017, 4, 13), new DateTime(2017, 4, 14)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 4, 18))); }
public void TestWeekendBeforeStart() { DateTime startDate = new DateTime(2017, 4, 21); int count = 5; WeekEnd[] weekends = new WeekEnd[2] { new WeekEnd(new DateTime(2017, 4, 15), new DateTime(2017, 4, 16)), new WeekEnd(new DateTime(2017, 4, 19), new DateTime(2017, 4, 22)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 4, 27))); }
public void TestWeekendOneAfterOther() { DateTime startDate = new DateTime(2017, 4, 21); int count = 5; WeekEnd[] weekends = new WeekEnd[2] { new WeekEnd(new DateTime(2017, 4, 23), new DateTime(2017, 4, 25)), new WeekEnd(new DateTime(2017, 4, 26), new DateTime(2017, 4, 27)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 4, 30))); }
public void TestZeroDaysCount() { DateTime startDate = new DateTime(2017, 4, 10); int count = 0; WeekEnd[] weekends = new WeekEnd[2] { new WeekEnd(new DateTime(2017, 4, 13), new DateTime(2017, 4, 15)), new WeekEnd(new DateTime(2017, 4, 16), new DateTime(2017, 4, 17)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(startDate)); }
public void TestTwoWeekendPeriods() { DateTime startDate = new DateTime(2017, 4, 21); int count = 6; WeekEnd[] weekends = new WeekEnd[2] { new WeekEnd(new DateTime(2017, 4, 23), new DateTime(2017, 4, 25)), new WeekEnd(new DateTime(2017, 4, 29), new DateTime(2017, 4, 30)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 5, 01))); }
public void TestWeekendBeforeAndInsideAndAfter()//In this case the period is extended to the third weekend { DateTime startDate = new DateTime(2017, 4, 21); int count = 5; WeekEnd[] weekends = new WeekEnd[3] { new WeekEnd(new DateTime(2017, 4, 20), new DateTime(2017, 4, 22)), new WeekEnd(new DateTime(2017, 4, 25), new DateTime(2017, 4, 25)), new WeekEnd(new DateTime(2017, 4, 28), new DateTime(2017, 4, 29)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 4, 30))); }
public void TestWithFewWeekend1() { DateTime startDate = new DateTime(2017, 4, 21); int count = 8; WeekEnd[] weekends = new WeekEnd[3] { new WeekEnd(new DateTime(2017, 4, 23), new DateTime(2017, 4, 25)), new WeekEnd(new DateTime(2017, 4, 29), new DateTime(2017, 4, 29)), new WeekEnd(new DateTime(2017, 5, 1), new DateTime(2017, 5, 2)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 5, 4))); }
public void TestWeekendAfterEnd() { DateTime startDate = new DateTime(2017, 4, 10); int count = 15; WeekEnd[] weekends = new WeekEnd[4] { new WeekEnd(new DateTime(2017, 4, 23), new DateTime(2017, 4, 25)), new WeekEnd(new DateTime(2017, 4, 15), new DateTime(2017, 4, 15)), new WeekEnd(new DateTime(2017, 4, 28), new DateTime(2017, 4, 30)), new WeekEnd(new DateTime(2017, 4, 26), new DateTime(2017, 4, 29)) }; DateTime result = new WorkDayCalculator().Calculate(startDate, count, weekends); Assert.IsTrue(result.Equals(new DateTime(2017, 5, 3))); }