public void Ctor_Void_Error()
        {
            ScheduledTask <FailableScheduledAction> task = new ScheduledTask <FailableScheduledAction>();

            CustomAssert.ThrowsException <CodedInvalidOperationException>(() =>
            {
                task.Reschedule(null);
            });
        }
        public void Reschedule_Null_Error()
        {
            DateTimeOffset now  = new DateTimeOffset(2013, 6, 1, 12, 0, 0, 0, TimeSpan.Zero);
            DateTimeOffset now2 = new DateTimeOffset(2013, 6, 1, 12, 0, 1, 0, TimeSpan.Zero);
            ScheduledTask <FailableScheduledAction> task = new ScheduledTask <FailableScheduledAction>(Schedule.CreateOneTime(now), new FailableScheduledAction(FailableScheduledAction.DummyAction.Run), true, now, now2);

            CustomAssert.ThrowsException <CodedArgumentNullException>(() =>
            {
                task.Reschedule(null);
            });
        }
        public void Reschedule_UpdateSchedule_Success()
        {
            DateTimeOffset now  = new DateTimeOffset(2013, 6, 1, 12, 0, 0, 0, TimeSpan.Zero);
            DateTimeOffset now2 = new DateTimeOffset(2013, 6, 1, 12, 0, 1, 0, TimeSpan.Zero);
            ScheduledTask <FailableScheduledAction> task = new ScheduledTask <FailableScheduledAction>(Schedule.CreateOneTime(now), new FailableScheduledAction(FailableScheduledAction.DummyAction.Run), true, now, now2);

            Schedule NewSchedule = Schedule.CreateInterval(now, TimeSpan.FromHours(1.0), Weekdays.All);

            task.Reschedule(NewSchedule);
            Assert.AreSame(NewSchedule, task.Schedule);

            task.UpdateSchedule(DateTimeOffset.Now);
        }
        public void Reschedule_UpdateScheduleOneTime_Success()
        {
            DateTimeOffset now  = new DateTimeOffset(2013, 6, 1, 12, 0, 0, 0, TimeSpan.Zero);
            DateTimeOffset now2 = new DateTimeOffset(2013, 6, 1, 12, 0, 1, 0, TimeSpan.Zero);
            ScheduledTask <FailableScheduledAction> task = new ScheduledTask <FailableScheduledAction>(Schedule.CreateOneTime(now), new FailableScheduledAction(FailableScheduledAction.DummyAction.Run), true, now, now2);

            Schedule NewSchedule = Schedule.CreateOneTime(DateTimeOffset.Now.AddDays(1.0));

            task.Reschedule(NewSchedule);
            Assert.AreSame(NewSchedule, task.Schedule);

            task.UpdateSchedule(DateTimeOffset.Now);
            Assert.AreEqual(NewSchedule.ScheduledDateTime.Value, task.NextDueDate);
            Assert.IsNull(task.LastStartTime);
        }