< 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
73%
Covered lines: 11
Uncovered lines: 4
Coverable lines: 15
Total lines: 52
Line coverage: 73.3%
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%5463.63%
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
 1286internal sealed partial class DataAccessStartupLogger(
 1287    ILogger<DataAccessStartupLogger> logger,
 1288    IOptions<DataAccessOptions> options) : IHostedService
 9{
 10    public Task StartAsync(CancellationToken cancellationToken)
 11    {
 12612        if (DataAccessOptions.IsDisabledProvider(options.Value.Provider))
 13        {
 014            LogDataAccessDisabled(
 015                logger,
 016                options.Value.Provider);
 17
 018            return Task.CompletedTask;
 19        }
 20
 12621        LogDataAccessConfiguration(
 12622            logger,
 12623            options.Value.Provider,
 12624            options.Value.ConnectionStringName,
 12625            options.Value.Auditing.Enabled ? "enabled" : "disabled");
 26
 12627        return Task.CompletedTask;
 28    }
 29
 30    public Task StopAsync(CancellationToken cancellationToken)
 31    {
 25232        return Task.CompletedTask;
 33    }
 34
 35    [LoggerMessage(
 36        EventId = 19100,
 37        Level = LogLevel.Information,
 38        Message = "Data access configured. Provider: {Provider}; ConnectionStringName: {ConnectionStringName}; EF Core a
 39    private static partial void LogDataAccessConfiguration(
 40        ILogger logger,
 41        string provider,
 42        string connectionStringName,
 43        string auditingStatus);
 44
 45    [LoggerMessage(
 46        EventId = 19101,
 47        Level = LogLevel.Information,
 48        Message = "Application data access disabled. Provider: {Provider}; EF Core services were not registered.")]
 49    private static partial void LogDataAccessDisabled(
 50        ILogger logger,
 51        string provider);
 52}