Ejemplo n.º 1
0
        public void RepeatChore_EveryMonWedFri_ShouldOccurOnMonWedFri()
        {
            int daysOfWeek = DaysOfWeekUtils.valueOf(new DayOfWeek[] { DayOfWeek.Monday, DayOfWeek.Wednesday, DayOfWeek.Friday });

            var chore = new ChoreBuilder()
                        .WithRepeating(1, Models.RepeatingUnitType.Week)
                        .WithDaysOfWeek(daysOfWeek)
                        .Build();

            // spin through a week and check we have an occurance on the right days
            DateTime checkDate = DateTime.Now.Date;

            for (int i = 0; i < 7; i++)
            {
                if ((checkDate.DayOfWeek == DayOfWeek.Monday) ||
                    (checkDate.DayOfWeek == DayOfWeek.Wednesday) ||
                    (checkDate.DayOfWeek == DayOfWeek.Friday))
                {
                    chore.RecursOnDate(checkDate).ShouldBeTrue();
                }
                else
                {
                    chore.RecursOnDate(checkDate).ShouldBeFalse();
                }

                checkDate = checkDate.AddDays(1);
            }
        }
Ejemplo n.º 2
0
        public void OnceOffChore_ForYesterday_ShouldNotBeActiveToday()
        {
            var chore = new ChoreBuilder()
                        .OnceOff(DateTime.Today.AddDays(-1))
                        .Build();

            chore.RecursOnDate(DateTime.Now).ShouldBeFalse();
        }
Ejemplo n.º 3
0
        public void OnceOffChore_ForToday_ShouldNotBeActiveTomorrow()
        {
            var chore = new ChoreBuilder()
                        .OnceOff(DateTime.Today)
                        .Build();

            chore.RecursOnDate(DateTime.Now.AddDays(1)).ShouldBeFalse();
        }
Ejemplo n.º 4
0
        public void OnceOffChore_ForToday_ShouldBeActiveForToday()
        {
            var chore = new ChoreBuilder()
                        .OnceOff(DateTime.Today)
                        .Build();

            chore.RecursOnDate(DateTime.Now).ShouldBeTrue();
        }
Ejemplo n.º 5
0
        public void DailyRepeatChore_StartingToday_ShouldStillBeActiveNextWeek()
        {
            var chore = new ChoreBuilder()
                        .WithRepeating(1, Models.RepeatingUnitType.Day)
                        .WithStartDate(DateTime.Now)
                        .Build();

            chore.RecursOnDate(DateTime.Now.AddDays(7)).ShouldBeTrue();
        }
Ejemplo n.º 6
0
        public void DailyRepeatChore_StartingTomorrow_ShouldNotBeActiveTomorrow()
        {
            var chore = new ChoreBuilder()
                        .WithRepeating(1, Models.RepeatingUnitType.Day)
                        .WithStartDate(DateTime.Now.AddDays(1))
                        .Build();

            chore.RecursOnDate(DateTime.Now.AddDays(1)).ShouldBeTrue();
        }
Ejemplo n.º 7
0
        public void DailyRepeatChore_FromYesterday_ShouldBeActiveToday()
        {
            var chore = new ChoreBuilder()
                        .WithRepeating(1, Models.RepeatingUnitType.Day)
                        .WithStartDate(DateTime.Now.AddDays(-1))
                        .Build();

            chore.RecursOnDate(DateTime.Now).ShouldBeTrue();
        }
Ejemplo n.º 8
0
        public void OnceOffChore_ForTodayButInactive_ShouldNotBeActiveToday()
        {
            var chore = new ChoreBuilder()
                        .OnceOff(DateTime.Today)
                        .WithActive(false)
                        .Build();

            chore.RecursOnDate(DateTime.Now).ShouldBeFalse();
        }
Ejemplo n.º 9
0
        public void RepeatChore_EverySecondDay_ShouldBeActiveTodayButNotTomorrow()
        {
            var chore = new ChoreBuilder()
                        .WithRepeating(2, Models.RepeatingUnitType.Day)
                        .WithStartDate(DateTime.Now)
                        .Build();

            // should be active today
            chore.RecursOnDate(DateTime.Now).ShouldBeTrue();
            // should not be active tomorrow
            chore.RecursOnDate(DateTime.Now.AddDays(1)).ShouldBeFalse();
            // should be active again the day after
            chore.RecursOnDate(DateTime.Now.AddDays(2)).ShouldBeTrue();
        }
Ejemplo n.º 10
0
        public void RepeatChore_EverySaturday_ShouldBeActiveNextOnSaturday()
        {
            var chore = new ChoreBuilder()
                        .WithRepeating(1, Models.RepeatingUnitType.Week)
                        .WithDaysOfWeek(DaysOfWeekUtils.valueOf(DayOfWeek.Saturday))
                        .Build();

            DateTime checkDate = DateTime.Now.Date;

            for (int i = 0; i < 7; i++)
            {
                if (checkDate.DayOfWeek == DayOfWeek.Saturday)
                {
                    chore.RecursOnDate(checkDate).ShouldBeTrue();
                }
                else
                {
                    chore.RecursOnDate(checkDate).ShouldBeFalse();
                }

                checkDate = checkDate.AddDays(1);
            }
        }
Ejemplo n.º 11
0
        public void DailyRepeatChore_ShouldBeActive()
        {
            var chore = new ChoreBuilder().WithRepeating(1, Models.RepeatingUnitType.Day).Build();

            chore.RecursOnDate(DateTime.Now).ShouldBeTrue();
        }