< Summary

Information
Class: ProjectTemplate.Infrastructure.Data.Extensions.ApplicationAuditReconciliationServiceExtensions
Assembly: ProjectTemplate.Infrastructure
File(s): /home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/src/ProjectTemplate.Infrastructure/Data/Extensions/ApplicationAuditReconciliationServiceExtensions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 26
Coverable lines: 26
Total lines: 46
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
AddApplicationAuditReconciliationCore(...)0%2040%

File(s)

/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/src/ProjectTemplate.Infrastructure/Data/Extensions/ApplicationAuditReconciliationServiceExtensions.cs

#LineLine coverage
 1using Microsoft.Extensions.DependencyInjection;
 2using Microsoft.Extensions.DependencyInjection.Extensions;
 3using Microsoft.Extensions.Options;
 4using ProjectTemplate.Infrastructure.Data.Auditing;
 5
 6namespace ProjectTemplate.Infrastructure.Data.Extensions;
 7
 8public static class ApplicationAuditReconciliationServiceExtensions
 9{
 10    public static IServiceCollection AddApplicationAuditReconciliationCore(
 11        this IServiceCollection services,
 12        Action<ApplicationAuditReconciliationOptions>? configure = null)
 13    {
 014        ArgumentNullException.ThrowIfNull(services);
 15
 016        OptionsBuilder<ApplicationAuditReconciliationOptions> optionsBuilder = services
 017            .AddOptions<ApplicationAuditReconciliationOptions>()
 018            .Validate(options => options.Interval > TimeSpan.Zero,
 019                "The audit reconciliation interval must be greater than zero.")
 020            .Validate(options => options.CompletionGracePeriod >= TimeSpan.Zero,
 021                "The completion grace period must not be negative.")
 022            .Validate(options => options.StalePendingThreshold > TimeSpan.Zero,
 023                "The stale pending threshold must be greater than zero.")
 024            .Validate(options => options.StaleRetryReadyThreshold > TimeSpan.Zero,
 025                "The stale retry-ready threshold must be greater than zero.")
 026            .Validate(options => options.MaximumBatchesPerRun is > 0 and <= 10_000,
 027                "Maximum batches per reconciliation run must be between 1 and 10000.")
 028            .Validate(options => options.HealthWarningFindingCount >= 0,
 029                "The warning finding threshold must not be negative.")
 030            .Validate(options => options.HealthUnhealthyFindingCount >= options.HealthWarningFindingCount,
 031                "The unhealthy finding threshold must not be less than the warning threshold.")
 032            .ValidateOnStart();
 33
 034        if (configure is not null)
 35        {
 036            optionsBuilder.Configure(configure);
 37        }
 38
 039        services.TryAddSingleton(TimeProvider.System);
 040        services.TryAddSingleton<ApplicationAuditReconciliationMetrics>();
 041        services.TryAddScoped<ApplicationAuditReconciler>();
 042        services.TryAddScoped<IApplicationAuditReconciler>(serviceProvider =>
 043            serviceProvider.GetRequiredService<ApplicationAuditReconciler>());
 044        return services;
 45    }
 46}