public void Initialize_ShouldInitializeChefRecurringTaskIfSettingExists() { const int interval = 1800; var runChefJob = RunChefJobTest.CreateRunChefJob(); var timerFactory = new FakeTimerFactory(); var clock = new FakeClock(); CafeServerWindowsService.Initialize(runChefJob, interval, timerFactory, clock); bool wasRunReady = false; runChefJob.RunReady += (sender, run) => wasRunReady = true; timerFactory.FireTimerAction(); wasRunReady.Should() .BeTrue( "because there was a policy created by the initialize that tied the timer to when runs were ready"); }
public void Exception_ShouldSetAutoresetEventAndFail() { var jobServer = new Mock <IJobServer>(); jobServer.Setup(s => s.GetJobRunStatus(It.IsAny <Guid>(), It.IsAny <int>())).Throws <HttpRequestException>(); var autoResetEvent = new FakeAutoResetEvent(); var fakeTimerFactory = new FakeTimerFactory(); var waiter = new SchedulerWaiter(() => jobServer.Object, autoResetEvent, fakeTimerFactory, new FakeMessagePresenter()); autoResetEvent.WhatToDoDuringWaitOne = () => { fakeTimerFactory.FireTimerAction(); }; var result = waiter.WaitForTaskToComplete(JobRunStatus.Create("sample task")); result.Result.IsSuccess.Should().BeFalse("because an exception was thrown by the scheduler"); result.Result.FailureDescription.Should() .NotBeEmpty("because it should contain a description of what happened"); }