public async Task CatchAny_catches_for_failed_consumer_only_and_does_not_notify_any_consumer_of_failure()
        {
            var behaving            = AsyncInterceptingConsumer.Behaving();
            var misbehaving         = AsyncInterceptingConsumer.Misbehaving();
            var behavingGotCatch    = false;
            var misbehavingGotCatch = false;
            var sut = NewSut();

            sut
            .CatchAny(_ => behavingGotCatch = true)
            .Subscribe(behaving);
            sut
            .CatchAny(_ => misbehavingGotCatch = true)
            .Subscribe(misbehaving);

            await sut.EmitAsync("v1");

            await sut.EmitAsync("v2");

            behavingGotCatch.Should().BeFalse();
            misbehavingGotCatch.Should().BeTrue();

            behaving.Interceptions.OnAnyFailed.Should().BeEmpty();
            misbehaving.Interceptions.OnAnyFailed.Should().BeEmpty();
            behaving.Interceptions.OnAllSucceeded.Should().HaveCount(2);
            misbehaving.Interceptions.OnAllSucceeded.Should().HaveCount(2);
        }
        public async Task Emits_events_to_all_active_consumers_even_failed_ones()
        {
            var behaving              = AsyncInterceptingConsumer.Behaving();
            var behavingDelegating    = new Interceptions();
            var misbehaving           = AsyncInterceptingConsumer.Misbehaving(ev => ev.Sequence > Sequence.First);
            var misbehavingDelegating = new Interceptions();
            var sut = NewSut();

            sut.Subscribe(behaving);
            sut.Subscribe(
                behavingDelegating.InOnNewAsync,
                behavingDelegating.InOnAllSucceededAsync,
                behavingDelegating.InOnAnyFailedAsync);
            sut.Subscribe(misbehaving);
            sut.Subscribe(
                ev =>
            {
                misbehavingDelegating.InOnNew(ev);
                if (ev.Sequence > Sequence.First)
                {
                    throw new Exception(ev.ToString());
                }

                return(ValueTask.CompletedTask);
            },
                misbehavingDelegating.InOnAllSucceededAsync,
                misbehavingDelegating.InOnAnyFailedAsync);

            var ev1 = await sut.EmitAsync(Fake.Strings.Random());

            var ev2 = await sut.EmitAsync(Fake.Strings.Random());

            behaving.Ensure().OnNewOnlyHas(ev1, ev2);
            behaving.Ensure().OnAllSucceededOnlyHasId(ev1.Id);
            behaving.Ensure().OnAnyFailedOnlyHasId(ev2.Id);

            behavingDelegating.Ensure().OnNewOnlyHas(ev1, ev2);
            behavingDelegating.Ensure().OnAllSucceededOnlyHasId(ev1.Id);
            behavingDelegating.Ensure().OnAnyFailedOnlyHasId(ev2.Id);

            misbehaving.Ensure().OnNewOnlyHas(ev1, ev2);
            misbehaving.Ensure().OnAllSucceededOnlyHasId(ev1.Id);
            misbehaving.Ensure().OnAnyFailedOnlyHasId(ev2.Id);

            misbehavingDelegating.Ensure().OnNewOnlyHas(ev1, ev2);
            misbehavingDelegating.Ensure().OnAllSucceededOnlyHasId(ev1.Id);
            misbehavingDelegating.Ensure().OnAnyFailedOnlyHasId(ev2.Id);
        }