fix: narrow _dbFactory type to TestDbContextFactory to fix CA1859

The 7 failing test files used IDbContextFactory<AppDbContext> for a field
that's always initialized with TestDbContextFactory. Narrowing to the
concrete type satisfies the analyzer and matches the pattern already used
in 5 other tests in the same folder.

Fixes: AgentFailoverJobTests, BusinessEntityPersistenceTests,
AnalysisJobDispatcherJobTests, AnalysisJobSchedulerServiceTests,
AgentDiscoveryServiceTests, CameraAssignmentServiceTests,
CameraEventServiceTests
This commit is contained in:
Arnaud Dartois committed 2026-10-10 13:46:12 +02:00
1 parent bbd80ec04d
commit eabea58353
7 files changed
+7 -7

No files matched your search

@@ -18,7 +18,7 @@ namespace Heimdall.Infrastructure.Tests;
public class AgentDiscoveryServiceTests : IDisposable
{
private readonly SqliteConnection _connection;
private readonly IDbContextFactory<AppDbContext> _dbFactory;
private readonly TestDbContextFactory _dbFactory;
private readonly IOnvifProbeService _onvif = Substitute.For<IOnvifProbeService>();
private readonly ICredentialProtector _protector = Substitute.For<ICredentialProtector>();
private readonly ILogger<CameraDiscoveryService> _logger = Substitute.For<ILogger<CameraDiscoveryService>>();
@@ -17,7 +17,7 @@ namespace Heimdall.Infrastructure.Tests;
[Collection("PostgresInfra")]
public class AgentFailoverJobTests : IAsyncLifetime
{
private readonly IDbContextFactory<AppDbContext> _dbFactory;
private readonly TestDbContextFactory _dbFactory;
private readonly ICameraAssignmentService _assignmentService = Substitute.For<ICameraAssignmentService>();
private readonly ILogger<AgentFailoverJob> _logger = Substitute.For<ILogger<AgentFailoverJob>>();
@@ -17,7 +17,7 @@ namespace Heimdall.Infrastructure.Tests;
[Collection("PostgresInfra")]
public class AnalysisJobDispatcherJobTests : IAsyncLifetime
{
private readonly IDbContextFactory<AppDbContext> _dbFactory;
private readonly TestDbContextFactory _dbFactory;
private readonly AnalysisJobSchedulerService _schedulerService;
private readonly AnalysisJobDispatcherJob _dispatcher;
@@ -16,7 +16,7 @@ namespace Heimdall.Infrastructure.Tests;
[Collection("PostgresInfra")]
public class AnalysisJobSchedulerServiceTests : IAsyncLifetime
{
private readonly IDbContextFactory<AppDbContext> _dbFactory;
private readonly TestDbContextFactory _dbFactory;
private readonly AnalysisJobSchedulerService _service;
private readonly ILogger<AnalysisJobSchedulerService> _logger = Substitute.For<ILogger<AnalysisJobSchedulerService>>();
@@ -17,7 +17,7 @@ namespace Heimdall.Infrastructure.Tests;
[Collection("PostgresInfra")]
public class BusinessEntityPersistenceTests : IAsyncLifetime
{
private readonly IDbContextFactory<AppDbContext> _dbFactory;
private readonly TestDbContextFactory _dbFactory;
public BusinessEntityPersistenceTests(PostgreSqlContainerFixture postgres)
{
@@ -16,7 +16,7 @@ namespace Heimdall.Infrastructure.Tests;
[Collection("PostgresInfra")]
public class CameraAssignmentServiceTests : IAsyncLifetime
{
private readonly IDbContextFactory<AppDbContext> _dbFactory;
private readonly TestDbContextFactory _dbFactory;
private readonly ILogger<CameraAssignmentService> _logger = Substitute.For<ILogger<CameraAssignmentService>>();
public CameraAssignmentServiceTests(PostgreSqlContainerFixture postgres)
@@ -17,7 +17,7 @@ namespace Heimdall.Infrastructure.Tests;
[Collection("PostgresInfra")]
public class CameraEventServiceTests : IAsyncLifetime
{
private readonly IDbContextFactory<AppDbContext> _dbFactory;
private readonly TestDbContextFactory _dbFactory;
private readonly ILogger<CameraEventService> _logger = Substitute.For<ILogger<CameraEventService>>();
private readonly IServiceProvider _serviceProvider = Substitute.For<IServiceProvider>();