コード例 #1
0
        public void GoYear_SetWeek_Goes()
        {
            var target = new TimeWindowCore(new DateTime(2012, 2, 21));

            target.GoWeek();
            target.GoYear();

            AssertDatesMatch(target,
                             new DateTime(2012, 1, 1),
                             new DateTime(2012, 12, 31),
                             "21 Feb will expand to 19 to 25 feb, will change to 2012 year");

            target = new TimeWindowCore(new DateTime(2012, 1, 1));
            target.GoWeek();
            target.GoYear();

            AssertDatesMatch(target,
                             new DateTime(2012, 1, 1),
                             new DateTime(2012, 12, 31),
                             "1st jan was sunday, hence week was 1 to 7, year will remain same");

            target = new TimeWindowCore(new DateTime(2011, 1, 1));
            target.GoWeek();
            target.GoYear();

            AssertDatesMatch(target,
                             new DateTime(2010, 1, 1),
                             new DateTime(2010, 12, 31),
                             "1st jan was saturday, hence week ended in 1st jan, year will become 2010");
        }
コード例 #2
0
        public void GoNext_SetWeek_Goes()
        {
            var target = new TimeWindowCore(new DateTime(2012, 2, 20));

            target.GoWeek();
            target.GoNext();
            AssertDatesMatch(target,
                             new DateTime(2012, 2, 26),
                             new DateTime(2012, 3, 3),
                             "19-25 feb week, shifted to 26 - 3 mar");

            target = new TimeWindowCore(new DateTime(2010, 12, 30));
            target.GoWeek();
            target.GoNext();
            AssertDatesMatch(target,
                             new DateTime(2011, 1, 2),
                             new DateTime(2011, 1, 8),
                             "1st jan 2011 was sat, next week is 2-8 jan");

            target = new TimeWindowCore(new DateTime(2012, 1, 13));
            target.GoWeek();
            target.GoNext();
            AssertDatesMatch(target,
                             new DateTime(2012, 1, 15),
                             new DateTime(2012, 1, 21),
                             "Simple happy case");
        }
コード例 #3
0
        public void GoWeek_SetMonth_Goes()
        {
            TimeWindowCore target = new TimeWindowCore(new DateTime(2012, 2, 2));

            target.GoMonth();
            target.GoWeek();
            AssertDatesMatch(target,
                             new DateTime(2012, 1, 29),
                             new DateTime(2012, 2, 4),
                             "1st week of feb");
        }
コード例 #4
0
        public void GoPrevious_SetWeek_Goes()
        {
            var target = new TimeWindowCore(new DateTime(2012, 2, 10));

            target.GoWeek();
            target.GoPrevious();
            AssertDatesMatch(target,
                             new DateTime(2012, 1, 29),
                             new DateTime(2012, 2, 4),
                             "Month boundry case");
        }
コード例 #5
0
        public void GoWeek_SetYear_Goes()
        {
            TimeWindowCore target = new TimeWindowCore(new DateTime(2011, 4, 10));

            target.GoYear();
            target.GoWeek();

            AssertDatesMatch(target,
                             new DateTime(2010, 12, 26),
                             new DateTime(2011, 1, 1),
                             "1st Jan was sat");
        }
コード例 #6
0
        public void GoWeek_SetWeek_ShouldntChange()
        {
            var target = new TimeWindowCore(new DateTime(2012, 2, 21));

            target.GoWeek();
            target.GoWeek();

            AssertDatesMatch(target,
                             new DateTime(2012, 2, 19),
                             new DateTime(2012, 2, 25),
                             "21 Feb will expand to 19 to 25 feb, will remain unchanged");

            target = new TimeWindowCore(new DateTime(2012, 3, 2));
            target.GoWeek();
            target.GoWeek();

            AssertDatesMatch(target,
                             new DateTime(2012, 2, 26),
                             new DateTime(2012, 3, 3),
                             "2nd march will expand to 26feb - 3 mar will remain unchanged");
        }
コード例 #7
0
        public void GetUberSpan_SetDates_Week()
        {
            var target = new TimeWindowCore(new DateTime(2012, 2, 2));

            target.GoWeek();
            Assert.AreEqual(target.GetUberSpan(), UberSpan.Week, "Week expected");

            target = new TimeWindowCore(new DateTime(2012, 3, 4));
            target.GoWeek();
            Assert.AreEqual(target.GetUberSpan(), UberSpan.Week, "Week expected");

            target = new TimeWindowCore(new DateTime(2012, 3, 5));
            target.GoWeek();
            Assert.AreEqual(target.GetUberSpan(), UberSpan.Week, "Week expected");
        }
コード例 #8
0
        public void StartEnd_SetDates_Week()
        {
            var target = new TimeWindowCore(new DateTime(2012, 2, 13));

            target.GoWeek();

            AssertDatesMatch(target,
                             new DateTime(2012, 2, 12),
                             new DateTime(2012, 2, 18),
                             "Setting two consecutive dates spans into week");

            target = new TimeWindowCore(new DateTime(2012, 2, 27));
            target.GoWeek();

            AssertDatesMatch(target,
                             new DateTime(2012, 2, 26),
                             new DateTime(2012, 3, 3),
                             "Around month end");
        }
コード例 #9
0
        public void GoMonth_SetWeek_Goes()
        {
            var target = new TimeWindowCore(new DateTime(2012, 2, 21));

            target.GoWeek();
            target.GoMonth();

            AssertDatesMatch(target,
                             new DateTime(2012, 2, 1),
                             new DateTime(2012, 2, 29),
                             "21 Feb will expand to 19 to 25 feb, will change to feb month");

            target = new TimeWindowCore(new DateTime(2012, 3, 2));
            target.GoWeek();
            target.GoMonth();

            AssertDatesMatch(target,
                             new DateTime(2012, 2, 1),
                             new DateTime(2012, 2, 29),
                             "2nd march will expand to 26feb - 3 mar will change to feb month");
        }
コード例 #10
0
        public void GoDay_SetWeek_Goes()
        {
            var target = new TimeWindowCore(new DateTime(2012, 2, 21));

            target.GoWeek();
            target.GoDay();

            AssertDatesMatch(target,
                             new DateTime(2012, 2, 19),
                             new DateTime(2012, 2, 19),
                             "21 Feb will expand to 19 to 25 feb, will change then to 19 feb");

            target = new TimeWindowCore(new DateTime(2012, 3, 2));
            target.GoWeek();
            target.GoDay();

            AssertDatesMatch(target,
                             new DateTime(2012, 2, 26),
                             new DateTime(2012, 2, 26),
                             "2nd march will expand to 26feb - 3 mar which will change to 26 feb");
        }
コード例 #11
0
        public void GoWeek_SetDays_Goes()
        {
            var target = new TimeWindowCore(new DateTime(2012, 2, 10));

            target.GoWeek();
            AssertDatesMatch(target,
                             new DateTime(2012, 2, 5),
                             new DateTime(2012, 2, 11),
                             "10th feb is friday and falls in week Sun 5 to Sat 11");

            target = new TimeWindowCore(new DateTime(2012, 2, 5));
            target.GoWeek();
            AssertDatesMatch(target,
                             new DateTime(2012, 2, 5),
                             new DateTime(2012, 2, 11),
                             "5th feb is Sunday and falls in week Sun 5 to Sat 11");

            target = new TimeWindowCore(new DateTime(2012, 2, 29));
            target.GoWeek();
            AssertDatesMatch(target,
                             new DateTime(2012, 2, 26),
                             new DateTime(2012, 3, 3),
                             "Leap year check. Falls between 26th Feb Sun, 3rd March");
        }