public async Task RemoveGroupAsync_ForConnection_OnDifferentServer_Works() { 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); using (var client = new TestClient()) { var output = Channel.CreateUnbounded <HubMessage>(); var connection = new HubConnectionContext(output, client.Connection); await manager1.OnConnectedAsync(connection); await manager1.AddGroupAsync(connection.ConnectionId, "snoop"); await manager2.InvokeGroupAsync("snoop", "Hello", new object[] { "World" }); AssertMessage(output); await manager2.RemoveGroupAsync(connection.ConnectionId, "snoop"); await manager2.InvokeGroupAsync("snoop", "Hello", new object[] { "World" }); Assert.False(output.In.TryRead(out var item)); } }
public async Task InvokeGroupAsync_WritesTo_AllConnections_InGroup_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.AddGroupAsync(connection1.ConnectionId, "gunit"); await manager.InvokeGroupAsync("gunit", "Hello", new object[] { "World" }); AssertMessage(output1); Assert.False(output2.In.TryRead(out var item)); } }
public async Task InvokeGroupAsync_OnServer_WithoutConnection_WritesOutputTo_GroupConnection() { 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); using (var client = new TestClient()) { var output = Channel.CreateUnbounded <HubMessage>(); var connection = new HubConnectionContext(output, client.Connection); await manager1.OnConnectedAsync(connection); await manager1.AddGroupAsync(connection.ConnectionId, "tupac"); await manager2.InvokeGroupAsync("tupac", "Hello", new object[] { "World" }); AssertMessage(output); } }