public async Task RemoveGroupFromLocalConnectionNotInGroupDoesNothing()
        {
            using (var client = new TestClient())
            {
                MassTransitHubLifetimeManager <MyHub> manager = BackplaneHarness.HubLifetimeManager;

                var connection = HubConnectionContextUtils.Create(client.Connection);

                await manager.OnConnectedAsync(connection).OrTimeout(Harness.TestTimeout);

                await manager.RemoveFromGroupAsync(connection.ConnectionId, "name").OrTimeout(Harness.TestTimeout);

                Assert.IsFalse(BackplaneHarness.GroupManagement.Consumed.Select <GroupManagement <MyHub> >()
                               .Any()); // Should not have published, because connection was local
            }
        }
        public async Task RemoveGroupAsyncForConnectionOnDifferentServerWorks()
        {
            using (var client = new TestClient())
            {
                Task <ConsumeContext <Ack <MyHub> > > ackHandler =
                    Harness.SubscribeHandler <Ack <MyHub> >(); // Lets us verify that the ack was sent back to our bus endpoint
                MassTransitHubLifetimeManager <MyHub> manager1 = Backplane1Harness.HubLifetimeManager;
                MassTransitHubLifetimeManager <MyHub> manager2 = Backplane2Harness.HubLifetimeManager;

                var connection = HubConnectionContextUtils.Create(client.Connection);

                await manager1.OnConnectedAsync(connection).OrTimeout(Harness.TestTimeout);

                await manager1.AddToGroupAsync(connection.ConnectionId, "name").OrTimeout(Harness.TestTimeout);

                await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(Harness.TestTimeout);

                IReceivedMessage <Group <MyHub> > firstMessage = Backplane1Harness.Group.Consumed.Select <Group <MyHub> >().FirstOrDefault();

                Assert.NotNull(firstMessage);

                await AssertMessageAsync(client);

                await manager2.RemoveFromGroupAsync(connection.ConnectionId, "name").OrTimeout(Harness.TestTimeout);

                Assert.IsTrue(Backplane1Harness.GroupManagement.Consumed.Select <GroupManagement <MyHub> >().Any());

                ConsumeContext <Ack <MyHub> > responseContext = await ackHandler;

                Assert.AreEqual(manager1.ServerName, responseContext.Message.ServerName);

                await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(Harness.TestTimeout);

                IReceivedMessage <Group <MyHub> > secondMessage = Backplane1Harness.Group.Consumed.Select <Group <MyHub> >().Skip(1).FirstOrDefault();

                Assert.NotNull(secondMessage);

                Assert.Null(client.TryRead());
            }
        }
        public async Task RemoveGroupFromConnectionOnDifferentServerNotInGroupDoesNothing()
        {
            using (var client = new TestClient())
            {
                Task <ConsumeContext <Ack <MyHub> > > ackHandler =
                    Harness.SubscribeHandler <Ack <MyHub> >(); // Lets us verify that the ack was sent back to our bus endpoint
                MassTransitHubLifetimeManager <MyHub> manager1 = Backplane1Harness.HubLifetimeManager;
                MassTransitHubLifetimeManager <MyHub> manager2 = Backplane2Harness.HubLifetimeManager;

                var connection = HubConnectionContextUtils.Create(client.Connection);

                await manager1.OnConnectedAsync(connection).OrTimeout(Harness.TestTimeout);

                await manager2.RemoveFromGroupAsync(connection.ConnectionId, "name").OrTimeout(Harness.TestTimeout);

                Assert.IsTrue(Backplane1Harness.GroupManagement.Consumed.Select <GroupManagement <MyHub> >().Any());

                ConsumeContext <Ack <MyHub> > responseContext = await ackHandler;

                Assert.AreEqual(manager1.ServerName, responseContext.Message.ServerName);
            }
        }