public async Task InvokeAllAsync_DoesNotWriteTo_DisconnectedConnections_Output() { using (var client1 = new TestClient()) using (var client2 = new TestClient()) { var output1 = Channel.CreateUnbounded <HubMessage>(); var output2 = Channel.CreateUnbounded <HubMessage>(); var manager = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client); var connection1 = new HubConnectionContext(output1, client1.Connection); var connection2 = new HubConnectionContext(output2, client2.Connection); await manager.OnConnectedAsync(connection1); await manager.OnConnectedAsync(connection2); await manager.OnDisconnectedAsync(connection2); await manager.InvokeAllAsync("Hello", new object[] { "World" }); AssertMessage(output1); Assert.False(output2.In.TryRead(out var item)); } }
public async Task InvokeAllAsync_ForSpecificHub_WithMultipleServers_WritesTo_AllConnections_Output() { var manager1 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client); var manager2 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client); var manager3 = new OrleansHubLifetimeManager <DifferentHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <DifferentHub> >(), this._fixture.Client); using (var client1 = new TestClient()) using (var client2 = new TestClient()) using (var client3 = new TestClient()) { var output1 = Channel.CreateUnbounded <HubMessage>(); var output2 = Channel.CreateUnbounded <HubMessage>(); var output3 = Channel.CreateUnbounded <HubMessage>(); var connection1 = new HubConnectionContext(output1, client1.Connection); var connection2 = new HubConnectionContext(output2, client2.Connection); var connection3 = new HubConnectionContext(output3, client3.Connection); await manager1.OnConnectedAsync(connection1); await manager2.OnConnectedAsync(connection2); await manager3.OnConnectedAsync(connection3); await manager1.InvokeAllAsync("Hello", new object[] { "World" }); AssertMessage(output1); AssertMessage(output2); Assert.False(output3.In.TryRead(out var item)); } }