public void GivenRecurringTask_WhenDateWithinVisibleRange_ShouldShowArticle(string rawCurrentDate)
        {
            // Fixture setup
            var startDate = DateTimeHelpers.ParseDateTime("01/01/2011");
            var endDate   = DateTimeHelpers.ParseDateTime("12/31/2011");
            var startTime = DateTimeHelpers.ParseTime("12:15:17");
            var task      = new ArticleScheduleTask
            {
                Id                   = _fixture.Create <int>(),
                ArticleId            = _fixture.Create <int>(),
                FreqType             = ScheduleFreqTypes.RecurringMonthlyRelative,
                FreqInterval         = 9, // working days
                FreqRelativeInterval = 4, // 3-rd week
                FreqRecurrenceFactor = 5, // every 5-th month
                StartDate            = startDate + startTime,
                EndDate              = endDate,
                Duration             = TimeSpan.FromDays(5)
            };

            var dbDate           = DateTimeHelpers.ParseDateTime(rawCurrentDate);
            var recurringService = _fixture.Freeze <Mock <IArticleRecurringSchedulerService> >();

            recurringService.Setup(m => m.GetCurrentDBDateTime()).Returns(dbDate);

            var sut = _fixture.Create <RecurringTaskScheduler>();

            // Exercise system
            sut.Run(task);

            // Verify outcome
            recurringService.Verify(f => f.ShowArticle(task.ArticleId), Times.Once());
            recurringService.Verify(f => f.HideArticle(It.IsAny <int>()), Times.Never());
            recurringService.Verify(f => f.HideAndCloseSchedule(It.IsAny <int>()), Times.Never());
        }
Beispiel #2
0
 public static RecurringTask Create(ArticleScheduleTask task) => new RecurringTask(
     task.Id,
     task.ArticleId,
     (RecurringTaskTypes)task.FreqType,
     task.FreqInterval,
     task.FreqRelativeInterval,
     task.FreqRecurrenceFactor,
     task.StartDate,
     task.EndDate,
     task.Duration);
        public void Run(ArticleScheduleTask articleTask)
        {
            var task        = PublishingTask.Create(articleTask);
            var currentTime = _publishingService.GetCurrentDBDateTime();

            if (ShouldProcessTask(task, currentTime))
            {
                var article = _publishingService.PublishAndCloseSchedule(task.Id);
                Logger.Log.Info($"Article [{article.Id}: {article.Name}] has been published on customer code: {_customer.CustomerName}");
            }
        }
Beispiel #4
0
        public void Run(ArticleScheduleTask articleTask)
        {
            var task        = OnetimeTask.CreateOnetimeTask(articleTask);
            var currentTime = _onetimeService.GetCurrentDBDateTime();
            var comparison  = GetTaskRange(task).CompareRangeTo(currentTime);

            if (ShouldProcessTask(task, currentTime))
            {
                ProcessTask(task, comparison);
            }
        }
        public void Run(ArticleScheduleTask articleTask)
        {
            var task        = RecurringTask.Create(articleTask);
            var currentTime = _recurringService.GetCurrentDBDateTime();
            var taskRange   = GetTaskRange(task);
            var comparison  = taskRange.CompareRangeTo(currentTime);

            if (ShouldProcessTask(task, currentTime))
            {
                ProcessTask(task, currentTime, comparison);
            }
        }
Beispiel #6
0
        public void Run(ArticleScheduleTask articleTask)
        {
            var task        = PublishingTask.Create(articleTask);
            var currentTime = _publishingService.GetCurrentDBDateTime();

            if (ShouldProcessTask(task, currentTime))
            {
                var article = _publishingService.PublishAndCloseSchedule(task.Id);
                Logger.Info()
                .Message(
                    "Article [{id}: {name}] has been published on customer code: {customerCode}",
                    article.Id, article.Name, _customer.CustomerName)
                .Write();
            }
        }
        public void GivenPublishingTask_WhenBeforePublishTime_ShouldNotDoAnything(ArticleScheduleTask task, TimeSpan diffTime)
        {
            // Fixture setup
            var startDateTime     = task.StartDate;
            var publishingService = _fixture.Freeze <Mock <IArticlePublishingSchedulerService> >();

            publishingService.Setup(m => m.GetCurrentDBDateTime()).Returns(startDateTime - diffTime);

            var sut = _fixture.Create <PublishingTaskScheduler>();

            // Exercise system
            sut.Run(task);

            // Verify outcome
            publishingService.Verify(f => f.PublishAndCloseSchedule(It.IsAny <int>()), Times.Never());
        }
 public bool ShouldProcessTask(ArticleScheduleTask task, DateTime dateTimeToCheck) => ShouldProcessTask(PublishingTask.Create(task), dateTimeToCheck);
 public bool ShouldProcessTask(ArticleScheduleTask task, DateTime dateTimeToCheck, bool forMonitoring = false)
 {
     return(ShouldProcessTask(RecurringTask.Create(task), dateTimeToCheck, forMonitoring));
 }
Beispiel #10
0
 public bool ShouldProcessTask(ArticleScheduleTask task, DateTime dateTimeToCheck) => ShouldProcessTask(OnetimeTask.CreateOnetimeTask(task), dateTimeToCheck);
Beispiel #11
0
 public static PublishingTask Create(ArticleScheduleTask task) => new PublishingTask(task.Id, task.ArticleId, task.StartDate + task.StartTime);
Beispiel #12
0
 private static bool FilterPublishingTasksPredicate(ArticleScheduleTask task) => task.FreqType == ScheduleFreqTypes.Publishing;
Beispiel #13
0
 private static bool FilterRecurringTasksPredicate(ArticleScheduleTask task) => task.FreqType == ScheduleFreqTypes.RecurringDaily ||
 task.FreqType == ScheduleFreqTypes.RecurringWeekly ||
 task.FreqType == ScheduleFreqTypes.RecurringMonthly ||
 task.FreqType == ScheduleFreqTypes.RecurringMonthlyRelative;
Beispiel #14
0
 private static bool FilterOnetimeTasksPredicate(ArticleScheduleTask task) => task.FreqType == ScheduleFreqTypes.OneTime;
Beispiel #15
0
 public static OnetimeTask CreateOnetimeTask(ArticleScheduleTask task) => new OnetimeTask(task.Id, task.ArticleId, task.StartDate + task.StartTime, task.EndDate + task.EndTime);