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 DisconnectConnection_RemovesConnection_FromGroup() { var manager = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.ClientProvider); using (var client = new TestClient()) { var connection = HubConnectionContextUtils.Create(client.Connection); await manager.OnConnectedAsync(connection); await manager.AddToGroupAsync(connection.ConnectionId, "dre"); await manager.OnDisconnectedAsync(connection); var grain = this._fixture.ClientProvider.GetClient().GetGroupGrain("MyHub", "dre"); var result = await grain.Count(); Assert.Equal(0, result); } }
public async Task DisconnectConnection_RemovesConnection_FromGroup() { var manager = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client); using (var client = new TestClient()) { var output = Channel.CreateUnbounded <HubMessage>(); var connection = new HubConnectionContext(output, client.Connection); await manager.OnConnectedAsync(connection); await manager.AddGroupAsync(connection.ConnectionId, "dre"); await manager.OnDisconnectedAsync(connection); var grain = this._fixture.Client.GetGroupGrain("MyHub", "dre"); var result = await grain.Count(); Assert.Equal(0, result); } }
public async Task InvokeAllAsync_DoesNotWriteTo_DisconnectedConnections_Output() { using (var client1 = new TestClient()) using (var client2 = new TestClient()) { var manager = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.ClientProvider); var connection1 = HubConnectionContextUtils.Create(client1.Connection); var connection2 = HubConnectionContextUtils.Create(client2.Connection); await manager.OnConnectedAsync(connection1); await manager.OnConnectedAsync(connection2); await manager.OnDisconnectedAsync(connection2); await manager.SendAllAsync("Hello", new object[] { "World" }); await AssertMessageAsync(client1); Assert.Null(client2.TryRead()); } }