public async Task Subscribe_AfterUnsubscribing_CreatesNewReader(
            string topic,
            IDisposableBlockingRawMessageReader <IPollingOptions> reader,
            [Frozen] IPollingOptions options,
            [Frozen] IRawMessageHandler rawMessageHandler,
            [Frozen] IBlockingRawMessageReaderFactory <IPollingOptions> factory,
            BlockingReaderRawMessageHandlerSubscriber <IPollingOptions> sut)
        {
            // Arrange
            factory.Create(topic, options).Returns(reader);

            var disposeEvent = new ManualResetEventSlim();

            reader.When(r => r.Dispose()).Do(r => disposeEvent.Set());

            // Act
            await sut.Subscribe(topic, rawMessageHandler, None);

            await sut.Unsubscribe(topic, rawMessageHandler, None);

            Assert.True(disposeEvent.Wait(1000)); // wait task complete
            await sut.Subscribe(topic, rawMessageHandler, None);

            // Assert
            factory.Received(2).Create(topic, options);
        }
        public async Task Subscribe_MultipleCallsSameRawHandler_CreatesSingleReader(
            string topic,
            IRawMessageHandler rawMessageHandler,
            [Frozen] IPollingOptions options,
            [Frozen] IBlockingRawMessageReaderFactory <IPollingOptions> factory,
            BlockingReaderRawMessageHandlerSubscriber <IPollingOptions> sut)
        {
            var tasks = Enumerable.Range(1, 5).Select(_ => sut.Subscribe(topic, rawMessageHandler, None));
            await Task.WhenAll(tasks);

            factory.Received(1).Create(topic, options);
        }
        public async Task Subscribe_MultipleCallsDifferentRawHandlers_CreatesSingleReader(
            string topic,
            IRawMessageHandler firstRawMessageHandler,
            IRawMessageHandler secondRawMessageHandler,
            [Frozen] IPollingOptions options,
            [Frozen] IBlockingRawMessageReaderFactory <IPollingOptions> factory,
            BlockingReaderRawMessageHandlerSubscriber <IPollingOptions> sut)
        {
            await Task.WhenAll(Subscrioptions());

            factory.Received(2).Create(topic, options);

            IEnumerable <Task> Subscrioptions()
            {
                for (int i = 0; i < 5; i++)
                {
                    yield return(sut.Subscribe(topic, firstRawMessageHandler, None));

                    yield return(sut.Subscribe(topic, secondRawMessageHandler, None));
                }
            }
        }