public void GetWeekStart_calculate_for_Sunday() { var expected = new DateTime(2015, 4, 6); var current = new DateTime(2015, 4, 12); var actual = PeriodsHelper.GetWeekStart(current); Assert.AreEqual(expected, actual); }
public void GetPeriods_should_return_date_for_Weekly() { var currentDate = DateTime.Now; var weekStartDate = PeriodsHelper.GetWeekStart(currentDate); // expected periods should include the current one even if it is not finished yet var expected = new[] { weekStartDate.AddDays(-7 * 8), weekStartDate.AddDays(-7 * 7), weekStartDate.AddDays(-7 * 6), weekStartDate.AddDays(-7 * 5), weekStartDate.AddDays(-7 * 4), weekStartDate.AddDays(-7 * 3), weekStartDate.AddDays(-7 * 2), weekStartDate.AddDays(-7 * 1), weekStartDate }; var actual = PeriodsHelper.GetPeriods(DateTime.Now, TimelogsPeriod.Weekly, 9); Assert.IsTrue(expected.SequenceEqual(actual)); }