public async Task FactoryShutdownCanBeCancelled() { var listener = new DelayAsyncTraceListener(100); var factory = new LogFactoryBuilder() .UseTraceSource() .AddTraceListener(listener) .Build(); var log = factory.Create("Test"); for (int i = 0; i < 10; i++) { log.Info(i); } var cancellationTokenSource = new CancellationTokenSource(250); try { await factory.ShutdownAsync(cancellationTokenSource.Token); } catch (OperationCanceledException) { } Assert.AreNotEqual(0, listener.QueueCount); }
public async Task FactoryAllowsForGracefulShutdown() { var listener = new DelayAsyncTraceListener(100); var factory = new LogFactoryBuilder() .UseTraceSource() .AddTraceListener(listener) .Build(); var log = factory.Create("Test"); for (int i = 0; i < 10; i++) { log.Info(i); } await factory.ShutdownAsync(); Assert.AreEqual(0, listener.QueueCount); }