Beispiel #1
0
        private static async Task RunWaitStopJob(PollingJob pollingJob, PollingFunction polllingFunc)
        {
            pollingJob.Start(polllingFunc);
            await Task.Delay(TimeSpan.FromSeconds(1));

            pollingJob.Stop();
        }
Beispiel #2
0
        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());
        }
Beispiel #3
0
        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());
        }
Beispiel #4
0
        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());
        }