public void Test_ServiceBusQueueMessenger_UpdateReceiverChangesSubscription()
        {
            // Arrange
            var topicOne = GetTopicMessenger("updatereceiverreceiverone", "subone");
            var topicTwo = GetTopicMessenger("updatereceiverreceivertwo", "subtwo");

            ((ServiceBusManager)topicOne.EntityManager).EntityFullPurge("updatereceiverreceiverone", true).GetAwaiter().GetResult();
            ((ServiceBusManager)topicTwo.EntityManager).EntityFullPurge("updatereceiverreceivertwo", true).GetAwaiter().GetResult();

            var testMessageOne = "Message One";
            var testMessageTwo = "Message Two";

            // Act/Assert
            // Send the message to initiate receive.
            topicOne.Send(testMessageOne).GetAwaiter().GetResult();
            topicTwo.Send(testMessageTwo).GetAwaiter().GetResult();

            Thread.Sleep(2000);

            var config        = new ConfigurationBuilder().AddJsonFile("appSettings.json").Build();
            var testMessenger = new ServiceBusMessenger(new ConnectionConfig()
            {
                ConnectionString = config.GetValue <string>("ConnectionString"),
                Receiver         = new ReceiverSetup()
                {
                    EntityType             = EntityType.Topic,
                    EntityName             = "updatereceiverreceiverone",
                    EntitySubscriptionName = "subone"
                }
            });

            var receivedMessageOne = testMessenger.ReceiveOne <string>();

            var count = 0;

            while (receivedMessageOne == null && count < 10)
            {
                receivedMessageOne = testMessenger.ReceiveOne <string>();
                count++;
            }

            Assert.Equal(receivedMessageOne, testMessageOne);
            testMessenger.Complete(receivedMessageOne).GetAwaiter().GetResult();

            //Update receiver to listen to the second subscription
            testMessenger.UpdateReceiver("updatereceiverreceivertwo", "subtwo").GetAwaiter().GetResult();

            var receivedMessageTwo = testMessenger.ReceiveOne <string>();

            count = 0;
            while (receivedMessageTwo == null && count < 10)
            {
                receivedMessageTwo = testMessenger.ReceiveOne <string>();
                count++;
            }

            Assert.Equal(receivedMessageTwo, testMessageTwo);
            testMessenger.Complete(receivedMessageTwo).GetAwaiter().GetResult();
        }
        public void Test_ServiceBusQueueMessenger_UpdateReceiverChangesSubscriptionWithDifferentType()
        {
            // Arrange
            var topicOne = GetTopicMessenger("updatereceiverreceiverone1", "subone1");
            var topicTwo = GetTopicMessenger("updatereceiverreceivertwo2", "subtwo2");

            ((ServiceBusManager)topicOne.EntityManager).EntityFullPurge("updatereceiverreceiverone1", true).GetAwaiter().GetResult();
            ((ServiceBusManager)topicTwo.EntityManager).EntityFullPurge("updatereceiverreceivertwo2", true).GetAwaiter().GetResult();

            var testMessageOne = "Message One";
            var testMessageTwo = new TestProps()
            {
                Test1 = 2, Test2 = true, Version = "new"
            };

            // Act/Assert
            // Send the message to initiate receive.
            topicOne.Send(testMessageOne).GetAwaiter().GetResult();
            topicTwo.Send(testMessageTwo).GetAwaiter().GetResult();

            Thread.Sleep(2000);

            var config        = new ConfigurationBuilder().AddJsonFile("appSettings.json").Build();
            var testMessenger = new ServiceBusMessenger(new ConnectionConfig()
            {
                ConnectionString = config.GetValue <string>("ConnectionString"),
                Receiver         = new ReceiverSetup()
                {
                    EntityType             = EntityType.Topic,
                    EntityName             = "updatereceiverreceiverone1",
                    EntitySubscriptionName = "subone1"
                }
            });

            var receivedMessageOne = testMessenger.ReceiveOne <string>();

            var count = 0;

            while (receivedMessageOne == null && count < 10)
            {
                receivedMessageOne = testMessenger.ReceiveOne <string>();
                Task.Delay(500);
                count++;
            }

            receivedMessageOne.Should().BeEquivalentTo(testMessageOne);
            testMessenger.Complete(receivedMessageOne).GetAwaiter().GetResult();

            //Update receiver to listen to the second subscription
            testMessenger.UpdateReceiver("updatereceiverreceivertwo2", "subtwo2").GetAwaiter().GetResult();

            var receivedMessageTwo = testMessenger.ReceiveOne <TestProps>();

            count = 0;
            while (receivedMessageTwo == null && count < 10)
            {
                receivedMessageTwo = testMessenger.ReceiveOne <TestProps>();
                Task.Delay(500);
                count++;
            }
            testMessenger.Complete(receivedMessageTwo).GetAwaiter().GetResult();

            Assert.NotNull(receivedMessageTwo);
            receivedMessageTwo.Should().BeEquivalentTo(testMessageTwo);

            topicOne.CompleteAllMessages().GetAwaiter().GetResult();
            topicTwo.CompleteAllMessages().GetAwaiter().GetResult();
        }