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; }
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(); }
static Func<Task> CreateTestAction(IThreadLoop loop, Func<bool> callback) { return async () => { if (callback()) { loop.Stop(); } await Task.Delay(1); }; }
static Func <Task> CreateTestAction(IThreadLoop loop, Func <bool> callback) { return(async() => { if (callback()) { loop.Stop(); } await Task.Delay(1); }); }
public RetryingThreadLoop( IThreadLoop threadLoop) { this.threadLoop = threadLoop; }