Exemple #1
0
        public void Configure_ValidatesArguments()
        {
            // Arrange
            var filter = new TaskExecutorStartupFilter(
                CreateTaskExecutor(),
                CreateApplicationLifetime());

            // Act

            // Assert
            Assert.Throws <ArgumentNullException>(() => filter.Configure(null /* next */));
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }