public void Start_RunsAsyncLoop() { var asyncLoopFactory = new Mock <IAsyncLoopFactory>(); var notification = new BlockNotification(this.LoggerFactory.Object, this.chain, this.consensusManager.Object, this.signals.Object, asyncLoopFactory.Object, this.lifetime); notification.Start(); asyncLoopFactory.Verify(a => a.Run("Notify", It.IsAny <Func <CancellationToken, Task> >(), It.IsAny <CancellationToken>(), null, null)); }
public void Start_RunsAsyncLoop() { var lifetime = new NodeLifetime(); var chain = new Mock <ConcurrentChain>(); var puller = new Mock <ILookaheadBlockPuller>(); var signals = new Mock <ISignals>(); var asyncLoopFactory = new Mock <IAsyncLoopFactory>(); var notification = new BlockNotification(this.LoggerFactory.Object, chain.Object, puller.Object, signals.Object, asyncLoopFactory.Object, lifetime); notification.Start(); asyncLoopFactory.Verify(a => a.Run("Notify", It.IsAny <Func <CancellationToken, Task> >(), It.IsAny <CancellationToken>(), null, null)); }
public void Stop_DisposesAsyncLoop() { var lifetime = new NodeLifetime(); var chain = new ConcurrentChain(this.Network); var puller = new Mock <ILookaheadBlockPuller>(); var signals = new Mock <ISignals>(); var asyncLoop = new Mock <IAsyncLoop>(); var asyncLoopFactory = new Mock <IAsyncLoopFactory>(); asyncLoopFactory.Setup(a => a.Run("Notify", It.IsAny <Func <CancellationToken, Task> >(), It.IsAny <CancellationToken>(), null, null)) .Returns(asyncLoop.Object); var notification = new BlockNotification(this.LoggerFactory.Object, chain, puller.Object, signals.Object, asyncLoopFactory.Object, lifetime); notification.Start(); notification.Stop(); asyncLoop.Verify(a => a.Dispose()); }