public async Task InvokeConnectionAsync_OnNonExistentConnection_DoesNotThrow() { var invalidConnection = "NotARealConnectionId"; var grain = this._fixture.Client.GetClientGrain("MyHub", invalidConnection); await grain.OnConnect(Guid.NewGuid(), "MyHub", invalidConnection); var manager = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client); await manager.InvokeConnectionAsync(invalidConnection, "Hello", new object[] { "World" }); }
public async Task InvokeConnectionAsync_WritesToConnection_Output() { using (var client = new TestClient()) { var output = Channel.CreateUnbounded <HubMessage>(); var manager = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client); var connection = new HubConnectionContext(output, client.Connection); await manager.OnConnectedAsync(connection); await manager.InvokeConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }); AssertMessage(output); } }
public async Task InvokeConnectionAsync_ForLocalConnection_DoesNotPublish() { 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); // Add connection to both "servers" to see if connection receives message twice await manager1.OnConnectedAsync(connection); await manager2.OnConnectedAsync(connection); await manager1.InvokeConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }); AssertMessage(output); Assert.False(output.In.TryRead(out var item)); } }
public async Task InvokeConnectionAsync_OnNonExistentConnection_WithoutCalling_OnConnect_ThrowsException() { var manager = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client); await Assert.ThrowsAsync <InvalidOperationException>(() => manager.InvokeConnectionAsync("NotARealConnectionIdV2", "Hello", new object[] { "World" })); }