public void Configure_ValidatesArguments() { // Arrange var filter = new TaskExecutorStartupFilter( CreateTaskExecutor(), CreateApplicationLifetime()); // Act // Assert Assert.Throws <ArgumentNullException>(() => filter.Configure(null /* next */)); }
public void Configure_ExecutesStartupTasks() { // Arrange bool startupExecuted = false; var filter = new TaskExecutorStartupFilter( CreateTaskExecutor(onStartup: () => startupExecuted = true), CreateApplicationLifetime()); Action <IApplicationBuilder> configure = _ => { }; // Act filter.Configure(configure); // Assert Assert.True(startupExecuted); }
public void Configure_RegistersWitHCancellationToken_ToExecuteShutdownTasks() { // Arrange bool shutdownExecuted = false; var cts = new CancellationTokenSource(); var filter = new TaskExecutorStartupFilter( CreateTaskExecutor(onShutdown: () => shutdownExecuted = true), CreateApplicationLifetime(stopped: cts.Token)); Action <IApplicationBuilder> configure = _ => { }; // Act filter.Configure(configure); cts.Cancel(); // Assert Assert.True(shutdownExecuted); }