public void Given_Subscribe_To_One_Message_When_I_Call_StopConsuming_Using_FluentApi_Then_Subsequent_Messages_Are_Not_Handled() { //arrange var message1 = $"Hello, world {Guid.NewGuid()}"; var message2 = $"Why, Hello {Guid.NewGuid()}"; //act _sut .WithProject(_projectId) .WithSubscription(_subscriptionId) .StartConsuming(_messageHandler); PublishMessage(message1); Thread.Sleep(5000); // allow time for processing the messages off the queue _sut.StopConsuming(); PublishMessage(message2); Thread.Sleep(5000); // allow time for processing the messages off the queue //assert Assert.IsNotNull(_messageHandler.MessagesHandled); Assert.AreEqual(1, _messageHandler.MessagesHandled.Count); Assert.IsTrue(_messageHandler.MessagesHandled.Contains(message1)); }
public void TearDown() { _sut.StopConsuming(); _subscriptionService.DeleteSubscription(_projectId, _subscriptionId); _topicService.DeleteTopic(_projectId, _topicId); _subscriptionService.DeleteSubscription(_projectId, _deadLetterSubscriptionId); _topicService.DeleteTopic(_projectId, _deadLetterTopicId); }