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"); }
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"); }
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)); }