public async Task InvokeConnectionAsyncOnServerWithoutConnectionWritesOutputToConnection()
        {
            using (var client = new TestClient())
            {
                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.SendConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout(Harness.TestTimeout);

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

                await AssertMessageAsync(client);
            }
        }
        public async Task WritingToRemoteConnectionThatFailsDoesNotThrow()
        {
            using (var client = new TestClient())
            {
                MassTransitHubLifetimeManager <MyHub> manager1 = Backplane1Harness.HubLifetimeManager;
                MassTransitHubLifetimeManager <MyHub> manager2 = Backplane2Harness.HubLifetimeManager;

                // Force an exception when writing to connection
                var connectionMock = HubConnectionContextUtils.CreateMock(client.Connection);

                await manager2.OnConnectedAsync(connectionMock).OrTimeout(Harness.TestTimeout);

                // This doesn't throw because there is no connection.ConnectionId on this server so it has to publish to the backplane.
                // And once that happens there is no way to know if the invocation was successful or not.
                await manager1.SendConnectionAsync(connectionMock.ConnectionId, "Hello", new object[] { "World" }).OrTimeout(Harness.TestTimeout);

                Assert.IsTrue(Backplane2Harness.Connection.Consumed.Select <Connection <MyHub> >().Any());
            }
        }
        public async Task InvokeConnectionAsyncForLocalConnectionDoesNotPublishToBackplane()
        {
            using (var client = new TestClient())
            {
                MassTransitHubLifetimeManager <MyHub> manager1 = Backplane1Harness.HubLifetimeManager;
                MassTransitHubLifetimeManager <MyHub> manager2 = Backplane2Harness.HubLifetimeManager;

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

                // Add connection to both "servers" to see if connection receives message twice
                await manager1.OnConnectedAsync(connection).OrTimeout(Harness.TestTimeout);

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

                await manager1.SendConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout(Harness.TestTimeout);

                Assert.IsFalse(Backplane1Harness.Connection.Consumed.Select <Connection <MyHub> >().Any());
                Assert.IsFalse(Backplane2Harness.Connection.Consumed.Select <Connection <MyHub> >().Any());

                await AssertMessageAsync(client);

                Assert.Null(client.TryRead());
            }
        }