private static async Task RunWaitStopJob(PollingJob pollingJob, PollingFunction polllingFunc) { pollingJob.Start(polllingFunc); await Task.Delay(TimeSpan.FromSeconds(1)); pollingJob.Stop(); }
public async Task StartedJob_WhenFuncReturnsFalse_Waits( [Frozen] Mock <IPollingTimeout> timeout, [Frozen] PollingFunction pollingFunc, PollingJob pollingJob) { await RunWaitStopJob(pollingJob, pollingFunc); timeout.Verify(self => self.WaitAsync(It.IsAny <CancellationToken>()), Times.AtLeastOnce()); }
public async Task StartedJob_WhenFuncThrows_IncreasesTimeout( [Frozen] Mock <IPollingTimeout> timeout, [Frozen] PollingFunction pollingFunc, PollingJob pollingJob) { await RunWaitStopJob(pollingJob, pollingFunc); timeout.Verify(self => self.Increase(), Times.AtLeastOnce()); }
public async Task StartedJob_WhenFuncReturnsTrue_ResetsTimeout( [Frozen] Mock <IPollingTimeout> timeout, [Frozen] PollingFunction pollingFunc, PollingJob pollingJob) { await RunWaitStopJob(pollingJob, pollingFunc); timeout.Verify(self => self.Reset(), Times.AtLeastOnce()); }