public async void TestShutdown() { var index = new StrongBox <int>(); var clientManager = new TestClientConnectionManager(index); var serviceManager = new TestServiceConnectionManager <Hub>(index); var options = new TestOptions(); options.Value.GracefulShutdown = new GracefulShutdownOptions() { Timeout = TimeSpan.FromSeconds(1), Mode = GracefulShutdownMode.WaitForClientsClose }; var dispatcher = new ServiceHubDispatcher <Hub>( null, TestHubContext <Hub> .GetInstance(), serviceManager, clientManager, null, options, NullLoggerFactory.Instance, new TestRouter(), null, null, null ); await dispatcher.ShutdownAsync(); Assert.Equal(3, serviceManager.StopIndex); Assert.Equal(2, clientManager.CompleteIndex); Assert.Equal(1, serviceManager.OfflineIndex); }
public async void TestShutdown() { var clientManager = new TestClientConnectionManager(); var serviceManager = new TestServiceConnectionManager <Hub>(); var options = new TestOptions(); options.Value.GracefulShutdown = new GracefulShutdownOptions() { Timeout = TimeSpan.FromSeconds(1), Mode = GracefulShutdownMode.WaitForClientsClose }; var dispatcher = new ServiceHubDispatcher <Hub>( null, serviceManager, clientManager, null, options, NullLoggerFactory.Instance, new TestRouter(), null, null, null ); await dispatcher.ShutdownAsync(); DateTime now = DateTime.Now; Assert.True(now > serviceManager.StopTime); Assert.True(serviceManager.StopTime > clientManager.CompleteTime); Assert.True(clientManager.CompleteTime > serviceManager.OfflineTime); }
public async void TestShutdown() { var clientManager = new TestClientConnectionManager(); var serviceManager = new TestServiceConnectionManager <Hub>(); var options = new TestOptions(); options.Value.EnableGracefulShutdown = true; options.Value.ServerShutdownTimeout = TimeSpan.FromSeconds(1); var dispatcher = new ServiceHubDispatcher <Hub>( null, serviceManager, clientManager, null, options, NullLoggerFactory.Instance, new TestRouter(), null, null, null ); await dispatcher.ShutdownAsync(); Assert.True(clientManager.completeTime.Subtract(serviceManager.offlineTime) > TimeSpan.FromMilliseconds(100)); Assert.True(clientManager.completeTime.Subtract(serviceManager.stopTime) < -TimeSpan.FromMilliseconds(100)); Assert.True(serviceManager.offlineTime != serviceManager.stopTime); }