public void Given_scheduler_with_daily_item()
        {
            var context = new TestSchedulerContext();

            _scheduler = new Scheduler(context);

            var runsoon = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);

            var foo1 = JobFactory.Daily("Foo1", () => { Console.WriteLine("Foo1"); foo1_calls += 1; }, runsoon, description: "Description for Foo1");
            var foo2 = JobFactory.Daily("Foo2", () => Console.WriteLine("Foo2"), runsoon);

            _scheduler.Schedule(foo1);
            _scheduler.Schedule(foo2);

            _scheduler.Start();

            Wait.Until(() => foo1_calls > 0, 30);

            context.MoveToTommorrow();

            Wait.Until(() => foo1_calls > 1, 30);

            context.MoveForwardNDays(2);

            Wait.Until(() => foo1_calls > 2, 50);
        }
        public void Given_scheduler_with_daily_item()
        {
            var context = new TestSchedulerContext();

            _scheduler = new Scheduler(context);

            var runsoon = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);

            var foo1 = JobFactory.Daily("Foo1", () => { Console.WriteLine("Foo1"); foo1_calls += 1; }, runsoon, description: "Description for Foo1");
            var foo2 = JobFactory.Daily("Foo2", () => Console.WriteLine("Foo2"), runsoon);

            _scheduler.Schedule(foo1);
            _scheduler.Schedule(foo2);

            _scheduler.Start();

            Wait.Until(() => foo1_calls > 0, 30);

            context.MoveToTommorrow();

            Wait.Until(() => foo1_calls > 1, 30);

            context.MoveForwardNDays(2);

            Wait.Until(() => foo1_calls > 2, 50);
        }
        public void Given_work_item()
        {
            var ctx = new TestSchedulerContext();
            // Make workitem think that it was created yesterday
            ctx.MoveToYesterday();
            _item = WorkItemFactory.Create(ctx);

            // Now update date to today, this
            // will make workitem applicable for scheduling
            ctx.MoveToNow();

            // Force workitem to reschedule
            _item.UpdateState();
            //Console.WriteLine("bo ya:" + _item.Status);
        }
        public void Given_daily_schedule()
        {
            var schedule = new DailyJobSchedule(new TimeSpan(12, 0, 0));
            var context = new TestSchedulerContext();

            context.MoveToNow();

            var jobstate = new TestJobState();

            nexttoday = schedule.NextExecution(jobstate, context);

            context.MoveToTommorrow();

            nexttomorrow = schedule.NextExecution(jobstate, context);
        }
        public void Given_daily_schedule()
        {
            var schedule = new DailyJobSchedule(new TimeSpan(12, 0, 0));
            var context  = new TestSchedulerContext();


            context.MoveToNow();

            var jobstate = new TestJobState();

            nexttoday = schedule.NextExecution(jobstate, context);

            context.MoveToTommorrow();

            nexttomorrow = schedule.NextExecution(jobstate, context);
        }
        public void Given_scheduler_with_some_work()
        {
            var ctx = new TestSchedulerContext();
            _scheduler = new Scheduler(ctx);

            _scheduler.Schedule("Foo1", () => { _foo1WorkDone = true; }, TimeSpan.FromMinutes(10));
            _scheduler.Schedule("Foo2", () => { _foo2WorkDone = true; }, TimeSpan.FromMinutes(10));

            // Lest ensure that all workitems
            // are applicable for schedule
            ctx.MoveToTommorrow();

            _scheduler.Start();

            Wait.Until(() => _scheduler.GatherOveralStats().RunningJobs + _scheduler.GatherOveralStats().ScheduledJobs == 0);
        }
        public void Given_work_item()
        {
            var ctx = new TestSchedulerContext();

            // Make workitem think that it was created yesterday
            ctx.MoveToYesterday();
            _item = WorkItemFactory.Create(ctx);

            // Now update date to today, this
            // will make workitem applicable for scheduling
            ctx.MoveToNow();

            // Force workitem to reschedule
            _item.UpdateState();
            //Console.WriteLine("bo ya:" + _item.Status);
        }
        public void Given_work_item()
        {
            var state = TempFolderStateProvider.CreateInTempFolder("When_work_item_has_not_run_since_before_interval" + Guid.NewGuid().ToString());

            state.Store("Foo1", new WorkState {
                LastCompleteTime = new DateTime(11, 10, 09)
            });

            var ctx = new TestSchedulerContext();
            ctx.State = state;

            // Make workitem with LastComplete from 9-10-2011
            _item = WorkItemFactory.Create(ctx);

            // Force workitem to reschedule
            _item.UpdateState();
        }
Пример #9
0
        public void Given_()
        {
            ctx = new TestSchedulerContext();

            state = ctx.State;

            var _item = WorkItemFactory.Create(ctx);

            // Make item think that now tomorrow, so
            // it became applicable for scheduling
            ctx.MoveToTommorrow();
            _item.UpdateState();
            _item.Run();

            // and .. wait until it will complete
            Wait.Until(() => _item.Status == JobStatus.Pending);
        }
        public void Given_()
        {
            ctx = new TestSchedulerContext();

            state = ctx.State;

            var _item = WorkItemFactory.Create(ctx);

            // Make item think that now tomorrow, so
            // it became applicable for scheduling
            ctx.MoveToTommorrow();
            _item.UpdateState();
            _item.Run();

            // and .. wait until it will complete
            Wait.Until(() => _item.Status == JobStatus.Pending);
        }
        public void Given_scheduler_with_some_work()
        {
            var ctx = new TestSchedulerContext();

            _scheduler = new Scheduler(ctx);

            _scheduler.Schedule("Foo1", () => { _foo1WorkDone = true; }, TimeSpan.FromMinutes(10));
            _scheduler.Schedule("Foo2", () => { _foo2WorkDone = true; }, TimeSpan.FromMinutes(10));

            // Lest ensure that all workitems
            // are applicable for schedule
            ctx.MoveToTommorrow();

            _scheduler.Start();

            Wait.Until(() => _scheduler.GatherOveralStats().RunningJobs + _scheduler.GatherOveralStats().ScheduledJobs == 0);
        }
Пример #12
0
        public void Given_work_item()
        {
            var state = TempFolderStateProvider.CreateInTempFolder("When_work_item_has_not_run_since_before_interval" + Guid.NewGuid().ToString());

            state.Store("Foo1", new WorkState {
                LastCompleteTime = new DateTime(11, 10, 09)
            });

            var ctx = new TestSchedulerContext();

            ctx.State = state;

            // Make workitem with LastComplete from 9-10-2011
            _item = WorkItemFactory.Create(ctx);

            // Force workitem to reschedule
            _item.UpdateState();
        }
        public void Given_work_item()
        {
            var ctx = new TestSchedulerContext();
            _item = WorkItemFactory.Create(ctx);

            // Make item think that now tomorrow, so
            // it became applicable for scheduling
            ctx.MoveToTommorrow();
            _item.UpdateState();
            _item.Run();

            // and .. wait until it will complete
            while (true)
            {
                if (_item.Status == JobStatus.Pending)
                {
                    break;
                }
                Thread.Sleep(200);
            }
        }
Пример #14
0
        public void Given_work_item()
        {
            var ctx = new TestSchedulerContext();

            _item = WorkItemFactory.Create(ctx);

            // Make item think that now tomorrow, so
            // it became applicable for scheduling
            ctx.MoveToTommorrow();
            _item.UpdateState();
            _item.Run();

            // and .. wait until it will complete
            while (true)
            {
                if (_item.Status == JobStatus.Pending)
                {
                    break;
                }
                Thread.Sleep(200);
            }
        }