Пример #1
0
        public void Configure_ValidatesArguments()
        {
            // Arrange
            var filter = new TaskExecutorStartupFilter(
                CreateTaskExecutor(),
                CreateApplicationLifetime());

            // Act

            // Assert
            Assert.Throws <ArgumentNullException>(() => filter.Configure(null /* next */));
        }
Пример #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);
        }
Пример #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);
        }