public void Should_Not_Alter_Original_Runtime_If_Chained_Task_Exists()
 {
     var task = new Mock<ITask>();
     var schedule = new Schedule(task.Object);
     schedule.ToRunNow().AndEvery(1).Months();
     Assert.IsNull(schedule.CalculateNextRun);
 }
 public void Should_Add_Chained_Tasks_To_AdditionalSchedules_Property()
 {
     var task = new Mock<ITask>();
     var schedule = new Schedule(task.Object);
     schedule.ToRunNow().AndEvery(1).Months();
     Assert.AreEqual(schedule.AdditionalSchedules.Count, 1);
 }
        public void Should_Be_True_By_Default()
        {
            var task = new Mock<ITask>();
            var schedule = new Schedule(task.Object);
            schedule.ToRunNow();

            schedule.Reentrant.Should().Be.True();
        }
        public void Should_Set_Chained_Task_Schedule_As_Expected()
        {
            var task = new Mock<ITask>();
            var schedule = new Schedule(task.Object);
            schedule.ToRunNow().AndEvery(2).Months();

            var input = new DateTime(2000, 1, 1);
            var scheduledTime = schedule.AdditionalSchedules.ElementAt(0).CalculateNextRun(input);
            var expectedTime = new DateTime(2000, 3, 1);
            scheduledTime.Should().Equal(expectedTime);
        }
        public void Should_Remove_Named_Task()
        {
            var task = new Mock<ITask>();
            var name = "ShouldRemoveTask";
            var schedule = new Schedule(task.Object).WithName(name);
            schedule.ToRunNow().AndEvery(1).Seconds();
            TaskManager.RemoveTask(name);

            var taskFromManager = TaskManager.GetSchedule(name);
            Assert.IsNull(taskFromManager);
        }
        public void Should_Be_True_By_Default()
        {
            // Arrange
            var task = new Mock<ITask>();

            // Act
            var schedule = new Schedule(task.Object);
            schedule.ToRunNow();

            // Assert
            Assert.IsTrue(schedule.Reentrant);
        }
        public void Should_Default_Reentrent_Parameter_For_Child_Schedules()
        {
            var task = new Mock<ITask>();
            var schedule = new Schedule(task.Object);
            schedule.ToRunNow().AndEvery(1).Minutes();

            schedule.Reentrant.Should().Be.True();
            foreach (var child in schedule.AdditionalSchedules)
            {
                child.Reentrant.Should().Be.True();
            }
        }
示例#8
0
        public void Should_Remove_Named_Task()
        {
            // Arrange
            var task = new Mock<ITask>();

            // Act
            var schedule = new Schedule(task.Object).WithName("remove named task");
            schedule.ToRunNow().AndEvery(1).Seconds();
            TaskManager.RemoveTask("remove named task");

            // Assert
            Assert.IsNull(TaskManager.GetSchedule("remove named task"));
        }
        public void Should_Default_Reentrent_Parameter_For_Child_Schedules()
        {
            // Arrange
            var task = new Mock<ITask>();

            // Act
            var schedule = new Schedule(task.Object);
            schedule.ToRunNow().AndEvery(1).Minutes();

            // Assert
            Assert.IsTrue(schedule.Reentrant);
            foreach (var child in schedule.AdditionalSchedules)
                Assert.IsTrue(child.Reentrant);
        }
        public void Should_Set_Chained_Task_Schedule_As_Expected()
        {
            // Arrange
            var task = new Mock<ITask>();
            var input = new DateTime(2000, 1, 1);
            var expected = new DateTime(2000, 3, 1);

            // Act
            var schedule = new Schedule(task.Object);
            schedule.ToRunNow().AndEvery(2).Months();
            var actual = schedule.AdditionalSchedules.ElementAt(0).CalculateNextRun(input);

            // Assert
            Assert.AreEqual(expected, actual);
        }