public async Task DisconnectsClusterClient() { // arrange var id = Guid.NewGuid(); var config = new ConfigurationBuilder() .AddInMemoryCollection(new Dictionary <string, string> { { "Orleans:Ports:Gateway:Start", "30000" }, { "Orleans:Ports:Gateway:End", "30000" }, { "Orleans:ClusterId", "dev" }, { "Orleans:ServiceId", "dev" }, { "Orleans:Providers:Clustering:Provider", "Localhost" } }) .Build(); // act var service = new ClusterClientHostedService(config, loggerProvider); await service.StartAsync(default(CancellationToken)); await service.StopAsync(default(CancellationToken)); // assert Assert.False(service.ClusterClient.IsInitialized); await Assert.ThrowsAsync <ObjectDisposedException>(async() => { await service.ClusterClient.GetGrain <ITestGrain>(id).GetKeyAsync(); }); }
public async Task FailsToConnectClusterClient() { // arrange var id = Guid.NewGuid(); var config = new ConfigurationBuilder() .AddInMemoryCollection(new Dictionary <string, string> { { "Orleans:Ports:Gateway:Start", "12345" }, { "Orleans:Ports:Gateway:End", "12345" }, { "Orleans:ClusterId", "dev" }, { "Orleans:ServiceId", "dev" }, { "Orleans:Providers:Clustering:Provider", "Localhost" } }) .Build(); // act and assert var service = new ClusterClientHostedService(config, loggerProvider); await Assert.ThrowsAsync <OrleansMessageRejectionException>(async() => { await service.StartAsync(default(CancellationToken)); }); }