コード例 #1
0
        public async Task SendConnectionAsyncWritesToConnectionsOutput(bool fromManager)
        {
            var hubProxy = new HubProxy <MyHub>(_fixture.TestCluster.Client);

            using (var manager = CreateNewHubLifetimeManager <MyHub>())
                using (var client1 = new TestClient())
                    using (var client2 = new TestClient())
                    {
                        var connection1 = HubConnectionContextUtils.Create(client1.Connection);
                        var connection2 = HubConnectionContextUtils.Create(client2.Connection);

                        await manager.OnConnectedAsync(connection1).OrTimeout();

                        await manager.OnConnectedAsync(connection2).OrTimeout();

                        if (fromManager)
                        {
                            await manager.SendConnectionsAsync(new[] { connection1.ConnectionId, connection2.ConnectionId }, "Hello",
                                                               new object[] { "World" }).OrTimeout();
                        }
                        else
                        {
                            await hubProxy.SendClientsAsync(new[] { connection1.ConnectionId, connection2.ConnectionId }, "Hello", "World").OrTimeout();
                        }

                        await AssertMessageAsync(client1);
                        await AssertMessageAsync(client2);
                    }
        }