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

            pollingJob.Stop();
        }
예제 #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());
        }
예제 #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());
        }
예제 #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());
        }