コード例 #1
0
ファイル: JobRunnerTest.cs プロジェクト: brijnandan/cafe
        public void TimerAction_ShouldProcessTasks()
        {
            var timerFactory = new FakeTimerFactory();
            var runner       = CreateJobRunner(timerFactory: timerFactory);
            var task         = new FakeJobRun();

            runner.Enqueue(task);

            timerFactory.FireTimerAction();

            task.WasRunCalled.Should().BeTrue("because the timer fired which should process tasks");
        }
コード例 #2
0
        public void TimerFired_ShouldFireJobReady()
        {
            var timerFactory = new FakeTimerFactory();

            var  recurringPolicy = new RecurringRunPolicy(Duration.FromMinutes(30), timerFactory, new FakeClock());
            bool isReady         = false;

            recurringPolicy.Due += (sender, args) => isReady = true;

            timerFactory.FireTimerAction();

            timerFactory.Every.Should().Be(recurringPolicy.Every, "timer should be on duration of the recurrence");
            isReady.Should().BeTrue("because the timer fired");
        }
コード例 #3
0
        public void ExpectedNextRun_ShouldBeLastRunDatePlusIntervalAfterItRuns()
        {
            var clock    = new FakeClock();
            var interval = FiveMinutes;
            var timer    = new FakeTimerFactory();

            var policy = new RecurringRunPolicy(interval, timer, clock);

            clock.AddToCurrentInstant(FiveMinutes);
            var timeAtTimerAction = clock.CurrentInstant;

            timer.FireTimerAction();
            clock.AddToCurrentInstant(Duration.FromMinutes(1));


            policy.ExpectedNextRun.Should().Be(timeAtTimerAction.Plus(interval));
        }