public void Test_PubSubMessenger_UpdateReceiver() { // Arrange var lorem1 = Lorem.GetSentence(5); var lorem2 = Lorem.GetSentence(5); PubSubManager manger = _fixture.Messenger.EntityManager as PubSubManager; // Act // Create topics manger.CreateTopicIfNotExists(_fixture.SecondaryTopicName).GetAwaiter().GetResult(); manger.CreateSubscription(_fixture.SecondaryTopicName, $"{_fixture.SecondaryTopicName}_default").GetAwaiter().GetResult(); // Send to topics _fixture.Messenger.Send(lorem1).GetAwaiter().GetResult(); ((PubSubMessenger)_fixture.Messenger).Send(_fixture.SecondaryTopicName, lorem2).GetAwaiter().GetResult(); ((PubSubMessenger)_fixture.Messenger).Send(_fixture.SecondaryTopicName, lorem2, new [] { new KeyValuePair <string, object>("prop1", "prop1val") }).GetAwaiter().GetResult(); // used for branch coverage ((PubSubMessenger)_fixture.Messenger).SendBatch(_fixture.SecondaryTopicName, new [] { lorem2 }, new[] { new KeyValuePair <string, object>("prop1", "prop1val") }, 10).GetAwaiter().GetResult(); // used for branch coverage ((PubSubMessenger)_fixture.Messenger).SendBatch(_fixture.SecondaryTopicName, new[] { lorem2 }, 10).GetAwaiter().GetResult(); // used for branch coverage ((PubSubMessenger)_fixture.Messenger).SendBatch(_fixture.SecondaryTopicName, new[] { lorem2 }).GetAwaiter().GetResult(); // used for branch coverage // Read from topic 1 var msg1 = _fixture.Messenger.ReceiveOne <string>(); _fixture.Messenger.Complete(msg1).GetAwaiter().GetResult(); // Update receiver to read from topic 2 _fixture.ReactiveMessenger.UpdateReceiver(_fixture.SecondaryTopicName); var msg2 = _fixture.Messenger.ReceiveOne <string>(); _fixture.Messenger.Complete(msg2).GetAwaiter().GetResult(); // Reset everything. _fixture.ReactiveMessenger.UpdateReceiver(_fixture.TestTopicName); // Assert msg1.Should().Be(lorem1); msg2.Should().Be(lorem2); }