public void Given_Three_Messages_Are_Available_When_I_Call_StartConsuming_Then_The_Three_Messages_Are_Processed()
        {
            //arrange
            var message1 = $"Hello, world {Guid.NewGuid()}";
            var message2 = $"Why, Hello {Guid.NewGuid()}";
            var message3 = $"Yo, Yo {Guid.NewGuid()}";

            //act
            _sut.StartConsuming(_projectId, _subscriptionId, _messageHandler);

            PublishMessage(message1);
            PublishMessage(message2);
            PublishMessage(message3);

            Thread.Sleep(5000); // allow time for processing the messages off the queue

            _sut.StopConsuming();

            //assert
            Assert.IsNotNull(_messageHandler.MessagesHandled);
            Assert.AreEqual(3, _messageHandler.MessagesHandled.Count);
            Assert.IsTrue(_messageHandler.MessagesHandled.Contains(message1));
            Assert.IsTrue(_messageHandler.MessagesHandled.Contains(message2));
            Assert.IsTrue(_messageHandler.MessagesHandled.Contains(message3));
        }
        public void Given_Two_Subscriptions_To_A_Topic_When_Messages_Are_Published_Both_Subscriptions_Should_Get_The_Messages()
        {
            //arrange
            var message1 = $"Hello, world {Guid.NewGuid()}";
            var message2 = $"Why, Hello {Guid.NewGuid()}";
            var message3 = $"Yo, Yo {Guid.NewGuid()}";

            var messageHandler1 = new TestMessageHandler();
            var messageHandler2 = new TestMessageHandler();

            var sut1 = new SubscriberService();
            var sut2 = new SubscriberService();

            //act
            sut1.StartConsuming(_projectId, _subscription1Id, messageHandler1);
            sut2.StartConsuming(_projectId, _subscription2Id, messageHandler2);

            PublishMessage(message1);
            PublishMessage(message2);
            PublishMessage(message3);

            Thread.Sleep(5000); // allow time for processing the messages off the queue

            sut1.StopConsuming();
            sut2.StopConsuming();

            //assert
            Assert.IsNotNull(messageHandler1.MessagesHandled);
            Assert.IsNotNull(messageHandler2.MessagesHandled);

            Assert.AreEqual(3, messageHandler1.MessagesHandled.Count);
            Assert.AreEqual(3, messageHandler2.MessagesHandled.Count);

            Assert.IsTrue(messageHandler1.MessagesHandled.Contains(message1));
            Assert.IsTrue(messageHandler1.MessagesHandled.Contains(message2));
            Assert.IsTrue(messageHandler1.MessagesHandled.Contains(message3));

            Assert.IsTrue(messageHandler2.MessagesHandled.Contains(message1));
            Assert.IsTrue(messageHandler2.MessagesHandled.Contains(message2));
            Assert.IsTrue(messageHandler2.MessagesHandled.Contains(message3));
        }