< Summary

Information
Class: ProjectTemplate.Infrastructure.Data.Services.DataAccessStartupLogger
Assembly: ProjectTemplate.Web
File(s): /home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/src/ProjectTemplate.Web/Services/DataAccessStartupLogger.cs
Line coverage
75%
Covered lines: 12
Uncovered lines: 4
Coverable lines: 16
Total lines: 54
Line coverage: 75%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
StartAsync(...)50%5466.66%
StopAsync(...)100%11100%

File(s)

/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/src/ProjectTemplate.Web/Services/DataAccessStartupLogger.cs

#LineLine coverage
 1using Microsoft.Extensions.Options;
 2using ProjectTemplate.Infrastructure.Data.Options;
 3
 4namespace ProjectTemplate.Infrastructure.Data.Services;
 5
 1366internal sealed partial class DataAccessStartupLogger(
 1367    ILogger<DataAccessStartupLogger> logger,
 1368    IOptions<DataAccessOptions> options) : IHostedService
 9{
 10    public Task StartAsync(CancellationToken cancellationToken)
 11    {
 13612        if (DataAccessOptions.IsDisabledProvider(options.Value.Provider))
 13        {
 014            LogDataAccessDisabled(
 015                logger,
 016                options.Value.Provider);
 17
 018            return Task.CompletedTask;
 19        }
 20
 13621        LogDataAccessConfiguration(
 13622            logger,
 13623            options.Value.Provider,
 13624            options.Value.ConnectionStringName,
 13625            options.Value.Auditing.Enabled ? "enabled" : "disabled",
 13626            options.Value.Auditing.StorageMode);
 27
 13628        return Task.CompletedTask;
 29    }
 30
 31    public Task StopAsync(CancellationToken cancellationToken)
 32    {
 27233        return Task.CompletedTask;
 34    }
 35
 36    [LoggerMessage(
 37        EventId = 19100,
 38        Level = LogLevel.Information,
 39        Message = "Data access configured. Provider: {Provider}; ConnectionStringName: {ConnectionStringName}; EF Core a
 40    private static partial void LogDataAccessConfiguration(
 41        ILogger logger,
 42        string provider,
 43        string connectionStringName,
 44        string auditingStatus,
 45        string auditStorageMode);
 46
 47    [LoggerMessage(
 48        EventId = 19101,
 49        Level = LogLevel.Information,
 50        Message = "Application data access disabled. Provider: {Provider}; EF Core services were not registered.")]
 51    private static partial void LogDataAccessDisabled(
 52        ILogger logger,
 53        string provider);
 54}