Пример #1
0
        public void WhenNewDateIsGreaterThanEndDate_GetNextTimeAfter_ReturnsNull()
        {
            // Arrange.
            var afterTime = new DateTime(2013, 1, 16, 10, 0, 0);
            var endDate = new DateTime(2013, 1, 16, 11, 0, 0);

            var dailyFrequency = Mock.Create<IScheduleDailyFrequency>(Behavior.CallOriginal);
            Mock.Arrange(() => dailyFrequency.GetNextTimeAfter(new TimeSpan(0, 10, 0, 0))).Returns(new TimeSpan(0, 12, 0, 0));

            var pattern = Mock.Create<ISchedulePattern>(Behavior.CallOriginal);

            var target = new Schedule { DailyFrequency = dailyFrequency, Pattern = pattern, EndDate = endDate };

            // Act.
            var result = target.GetNextTimeAfter(afterTime);

            // Assert.
            Assert.IsNull(result);
        }
Пример #2
0
        public void GetNextTimeAfter_ReturnsNewTime_OnTheSameDate()
        {
            // Arrange.
            var afterTime = new DateTime(2013, 1, 16, 10, 0, 0);
            var nextDate = new DateTime(2013, 1, 16, 12, 0, 0);

            var dailyFrequency = Mock.Create<IScheduleDailyFrequency>(Behavior.CallOriginal);
            Mock.Arrange(() => dailyFrequency.GetNextTimeAfter(new TimeSpan(0, 10, 0, 0))).Returns(new TimeSpan(0, 12, 0, 0));

            var pattern = Mock.Create<ISchedulePattern>(Behavior.CallOriginal);

            var target = new Schedule { DailyFrequency = dailyFrequency, Pattern = pattern };

            // Act.
            var result = target.GetNextTimeAfter(afterTime);

            // Assert.
            Assert.IsNotNull(result);
            Assert.AreEqual(nextDate, result);
        }
Пример #3
0
        public void WhenPatternReturnsNull_GetNextTimeAfter_ReturnsNull()
        {
            // Arrange.
            var afterTime = new DateTime(2013, 1, 16, 10, 0, 0);

            var dailyFrequency = Mock.Create<IScheduleDailyFrequency>(Behavior.CallOriginal);
            // There is no new schedule time after 10:00.
            Mock.Arrange(() => dailyFrequency.GetNextTimeAfter(new TimeSpan(0, 10, 0, 0))).Returns(null as TimeSpan?);
            // Set start schedule time to 05:00.
            Mock.Arrange(() => dailyFrequency.GetNextTimeAfter(null)).Returns(new TimeSpan(0, 5, 0, 0));

            var pattern = Mock.Create<ISchedulePattern>(Behavior.CallOriginal);
            // Set next schedule date.
            Mock.Arrange(() => pattern.GetNextDateAfter(Arg.IsAny<DateTime>())).Returns(null as DateTime?);

            var target = new Schedule { DailyFrequency = dailyFrequency, Pattern = pattern };

            // Act.
            var result = target.GetNextTimeAfter(afterTime);

            // Assert.
            Assert.IsNull(result);
        }
Пример #4
0
        public void WhenDailyFrequencyIsNull_GetNextTimeAfter_ThrowsException()
        {
            var pattern = Mock.Create<ISchedulePattern>(Behavior.CallOriginal);
            var target = new Schedule { Pattern = pattern, DailyFrequency = null };

            target.GetNextTimeAfter(new DateTime(2013, 1, 16));
        }