本文整理汇总了C#中Scheduler.CanScheduleBeEnqueued方法的典型用法代码示例。如果您正苦于以下问题:C# Scheduler.CanScheduleBeEnqueued方法的具体用法?C# Scheduler.CanScheduleBeEnqueued怎么用?C# Scheduler.CanScheduleBeEnqueued使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scheduler
的用法示例。
在下文中一共展示了Scheduler.CanScheduleBeEnqueued方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SchedulerCanScheduleBeEnqueued
public void SchedulerCanScheduleBeEnqueued()
{
var repository = new Mock<IRepository>();
repository.Setup(r => r.GetScheduleDateExistsForSchedule(It.IsAny<long>(), It.IsAny<DateTime>(), It.IsAny<IDbTransaction>())).Returns(false);
var factory = new Mock<IRepositoryFactory>();
factory.Setup(f => f.Create()).Returns(repository.Object);
var logger = new Mock<ILogger>();
DateTime? scheduleDate;
DateTime now = DateTime.UtcNow.FloorWithSeconds();
ScheduleRecord schedule = new ScheduleRecord()
{
Id = 1,
RepeatType = ScheduleRepeatType.Days,
RepeatValue = 1,
StartOn = now
};
Scheduler scheduler = new Scheduler(
1,
BlueCollarSection.Section.ApplicationName,
QueueNameFilters.Any(),
BlueCollarSection.Section.WorkerHeartbeat,
factory.Object,
logger.Object);
DateTime begin = now.AddSeconds(-1);
DateTime end = now;
Assert.IsTrue(scheduler.CanScheduleBeEnqueued(schedule, begin, end, out scheduleDate));
Assert.IsNotNull(scheduleDate);
begin = end;
end = begin.AddSeconds(1);
Assert.IsFalse(scheduler.CanScheduleBeEnqueued(schedule, begin, end, out scheduleDate));
Assert.IsNull(scheduleDate);
begin = now.AddSeconds(-2);
end = now.AddSeconds(-1);
Assert.IsFalse(scheduler.CanScheduleBeEnqueued(schedule, begin, end, out scheduleDate));
Assert.IsNull(scheduleDate);
begin = now.AddDays(1).AddSeconds(-1);
end = now.AddDays(1);
Assert.IsTrue(scheduler.CanScheduleBeEnqueued(schedule, begin, end, out scheduleDate));
Assert.IsNotNull(scheduleDate);
schedule.RepeatType = ScheduleRepeatType.None;
Assert.IsFalse(scheduler.CanScheduleBeEnqueued(schedule, begin, end, out scheduleDate));
Assert.IsNull(scheduleDate);
}