public void When_subscriptionmanager_throws_exception_on_subscribe()
        {
            var expectedException       = new Exception("expected exception");
            var fakeSubscriptionManager = new FakeSubscriptionManager(expectedException);
            var terminator =
                new NativeSubscribeTerminator(fakeSubscriptionManager, new MessageMetadataRegistry(_ => true));

            var exception = Assert.ThrowsAsync <Exception>(() => terminator.Invoke(new TestableSubscribeContext(), _ => Task.CompletedTask));

            Assert.AreSame(expectedException, exception);
        }
        public void When_subscriptionmanager_throws_aggregateexception_on_subscribeAll()
        {
            var aggregateException      = new AggregateException(new Exception("expected exception"));
            var fakeSubscriptionManager = new FakeSubscriptionManager(aggregateException);
            var terminator =
                new NativeSubscribeTerminator(fakeSubscriptionManager, new MessageMetadataRegistry(_ => true));
            var testableSubscribeContext = new TestableSubscribeContext();

            testableSubscribeContext.Extensions.Set(MessageSession.SubscribeAllFlagKey, true);

            var exception = Assert.ThrowsAsync <AggregateException>(() => terminator.Invoke(testableSubscribeContext, _ => Task.CompletedTask));

            Assert.AreSame(aggregateException, exception);
        }