Exemplo n.º 1
0
        public async Task WhenInvalidRetentionPeriod_DoesNotRun(int?retentionPeriodInDays)
        {
            CleanupAuthorizedTasksCommand executedCommand = null;

            using var app = _appFactory.Create(s =>
            {
                s.Configure <AuthorizedTaskCleanupSettings>(c => c.RetentionPeriodInDays = retentionPeriodInDays);
                s.MockHandler <CleanupAuthorizedTasksCommand>(c => executedCommand       = c);
            });

            var backgroundTask = app.Services.GetRequiredService <AuthorizedTaskCleanupBackgroundTask>();
            await backgroundTask.ExecuteAsync();

            using (new AssertionScope())
            {
                executedCommand.Should().BeNull();
            }
        }
Exemplo n.º 2
0
        public async Task WhenEnabled_Runs()
        {
            CleanupAuthorizedTasksCommand executedCommand = null;

            using var app = _appFactory.Create(s =>
            {
                s.Configure <AuthorizedTaskCleanupSettings>(c => c.RetentionPeriodInDays = 11);
                s.MockHandler <CleanupAuthorizedTasksCommand>(c => executedCommand       = c);
            });

            var backgroundTask = app.Services.GetRequiredService <AuthorizedTaskCleanupBackgroundTask>();
            await backgroundTask.ExecuteAsync();

            using (new AssertionScope())
            {
                executedCommand.Should().NotBeNull();
                executedCommand.RetentionPeriod.Should().Be(TimeSpan.FromDays(11));
            }
        }