public RetryingThreadLoop(
     IThreadLoop threadLoop,
     ILogger logger)
 {
     this.threadLoop = threadLoop;
     this.logger     = logger;
 }
 public ConsumerThreadLoop(
     IThreadLoop internalLoop,
     ILogger logger)
 {
     this.internalLoop = internalLoop;
     this.logger = logger;
 }
 public ThreadDeferrer(
     IThreadLoop threadLoop,
     IThreadDelay threadDelay)
 {
     this.threadLoop  = threadLoop;
     this.threadDelay = threadDelay;
 }
示例#4
0
        public async Task LoopStopsWhenNothingIsLeftToProcess()
        {
            IThreadLoop fakeInnerLoop = null;
            Func <Task> innerLoopTick = null;
            var         container     = CreateContainer(
                c => {
                fakeInnerLoop = c.RegisterFake <IThreadLoop>();
                fakeInnerLoop.StartAsync(
                    Arg.Do <Func <Task> >(
                        x => {
                    innerLoopTick
                        = x;
                }),
                    CancellationToken.None);
            });

            var systemUnderTest = container.Resolve <IConsumerThreadLoop>();

            systemUnderTest.Notify(() => Task.CompletedTask, CancellationToken.None);
            systemUnderTest.Notify(() => Task.CompletedTask, CancellationToken.None);
            systemUnderTest.Notify(() => Task.CompletedTask, CancellationToken.None);

            await innerLoopTick();
            await innerLoopTick();
            await innerLoopTick();

            fakeInnerLoop.DidNotReceive()
            .Stop();

            await innerLoopTick();

            fakeInnerLoop.Received(1)
            .Stop();
        }
示例#5
0
 public ConsumerThreadLoop(
     IThreadLoop internalLoop,
     ILogger logger)
 {
     this.internalLoop = internalLoop;
     this.logger       = logger;
 }
 static Func<Task> CreateTestAction(IThreadLoop loop, Func<bool> callback)
 {
     return async () => {
         if (callback())
         {
             loop.Stop();
         }
         await Task.Delay(1);
     };
 }
示例#7
0
 static Func <Task> CreateTestAction(IThreadLoop loop, Func <bool> callback)
 {
     return(async() => {
         if (callback())
         {
             loop.Stop();
         }
         await Task.Delay(1);
     });
 }
示例#8
0
 public RetryingThreadLoop(
     IThreadLoop threadLoop)
 {
     this.threadLoop = threadLoop;
 }
 public RetryingThreadLoop(
     IThreadLoop threadLoop)
 {
     this.threadLoop = threadLoop;
 }