Beispiel #1
0
        public async Task should_track_errors()
        {
            var subscription = new LambdaSubscription(_empty);

            var ex = new Exception("message");
            await subscription.OnErrorAsync(1, ex);

            Assert.True(subscription.Failed);
            Assert.Same(ex, subscription.LastError);
            Assert.Equal(1, subscription.FailedPosition);
        }
Beispiel #2
0
        public async Task should_intercept_on_error()
        {
            Exception trackedException = null;
            long      trackedPosition  = 0;
            var       subscription     = new LambdaSubscription(_empty)
            {
                OnError = (position, exception) =>
                {
                    trackedException = exception;
                    trackedPosition  = position;
                    return(Task.CompletedTask);
                }
            };

            var ex = new Exception("message");
            await subscription.OnErrorAsync(1, ex);

            Assert.True(subscription.Failed);
            Assert.Same(ex, trackedException);
            Assert.Equal(1, trackedPosition);
        }