public async Task reset_awaiter_when_success()
        {
            var mockAwaiter         = new Mock <IHandlingManagerAwaiter>();
            var mockHandler         = new Mock <ISubscriberEventHandler>();
            var mockStreamStateRepo = new Mock <IStreamStateRepo>();
            var runner          = new HandlingManagerHandlerRunner(NullStandardLogger.Instance, mockAwaiter.Object, mockStreamStateRepo.Object, mockHandler.Object);
            var subscriberEvent = new SubscriberEvent(null, null, 0, null, null);

            mockHandler.Setup(x => x.HandleSubscriberEventAsync(It.IsAny <SubscriberEvent>(), It.IsAny <CancellationToken>())).Returns(Task.CompletedTask);
            mockStreamStateRepo.Setup(x => x.SaveStreamStateAsync(It.IsAny <string>(), It.IsAny <long>(), It.IsAny <bool>())).Returns(Task.CompletedTask);

            await runner.TryRunHandlerAsync(subscriberEvent, CancellationToken.None);

            mockAwaiter.Verify(x => x.ReleaseThrottle());
            mockAwaiter.Verify(x => x.SetHandlerCompletionSignal());
        }
        public async Task run_handler_and_save_errored_stream_state()
        {
            var cts                 = new CancellationTokenSource();
            var mockAwaiter         = new Mock <IHandlingManagerAwaiter>();
            var mockHandler         = new Mock <ISubscriberEventHandler>();
            var mockStreamStateRepo = new Mock <IStreamStateRepo>();
            var runner              = new HandlingManagerHandlerRunner(NullStandardLogger.Instance, mockAwaiter.Object, mockStreamStateRepo.Object, mockHandler.Object);
            var streamId            = "s";
            var position            = 1;
            var subscriberEvent     = new SubscriberEvent(null, streamId, position, null, null);

            mockHandler.Setup(x => x.HandleSubscriberEventAsync(It.IsAny <SubscriberEvent>(), It.IsAny <CancellationToken>())).Throws(new Exception());
            mockStreamStateRepo.Setup(x => x.SaveStreamStateAsync(It.IsAny <string>(), It.IsAny <long>(), It.IsAny <bool>())).Returns(Task.CompletedTask);

            await runner.TryRunHandlerAsync(subscriberEvent, cts.Token);

            mockHandler.Verify(x => x.HandleSubscriberEventAsync(subscriberEvent, cts.Token));
            mockStreamStateRepo.Verify(x => x.SaveStreamStateAsync(streamId, position, true));
        }