From eabea58353f12926bec8ed673470314c4d6701fa Mon Sep 17 00:00:00 2001 From: Arnaud Dartois Date: Sat, 10 Oct 2026 13:46:12 +0200 Subject: [PATCH] fix: narrow _dbFactory type to TestDbContextFactory to fix CA1859 The 7 failing test files used IDbContextFactory 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 --- .../Heimdall.Infrastructure.Tests/AgentDiscoveryServiceTests.cs | 2 +- tests/Heimdall.Infrastructure.Tests/AgentFailoverJobTests.cs | 2 +- .../AnalysisJobDispatcherJobTests.cs | 2 +- .../AnalysisJobSchedulerServiceTests.cs | 2 +- .../BusinessEntityPersistenceTests.cs | 2 +- .../CameraAssignmentServiceTests.cs | 2 +- tests/Heimdall.Infrastructure.Tests/CameraEventServiceTests.cs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/Heimdall.Infrastructure.Tests/AgentDiscoveryServiceTests.cs b/tests/Heimdall.Infrastructure.Tests/AgentDiscoveryServiceTests.cs index cf9d6f4..cbc37c6 100644 --- a/tests/Heimdall.Infrastructure.Tests/AgentDiscoveryServiceTests.cs +++ b/tests/Heimdall.Infrastructure.Tests/AgentDiscoveryServiceTests.cs @@ -18,7 +18,7 @@ namespace Heimdall.Infrastructure.Tests; public class AgentDiscoveryServiceTests : IDisposable { private readonly SqliteConnection _connection; - private readonly IDbContextFactory _dbFactory; + private readonly TestDbContextFactory _dbFactory; private readonly IOnvifProbeService _onvif = Substitute.For(); private readonly ICredentialProtector _protector = Substitute.For(); private readonly ILogger _logger = Substitute.For>(); diff --git a/tests/Heimdall.Infrastructure.Tests/AgentFailoverJobTests.cs b/tests/Heimdall.Infrastructure.Tests/AgentFailoverJobTests.cs index 5f61a24..be0bce9 100644 --- a/tests/Heimdall.Infrastructure.Tests/AgentFailoverJobTests.cs +++ b/tests/Heimdall.Infrastructure.Tests/AgentFailoverJobTests.cs @@ -17,7 +17,7 @@ namespace Heimdall.Infrastructure.Tests; [Collection("PostgresInfra")] public class AgentFailoverJobTests : IAsyncLifetime { - private readonly IDbContextFactory _dbFactory; + private readonly TestDbContextFactory _dbFactory; private readonly ICameraAssignmentService _assignmentService = Substitute.For(); private readonly ILogger _logger = Substitute.For>(); diff --git a/tests/Heimdall.Infrastructure.Tests/AnalysisJobDispatcherJobTests.cs b/tests/Heimdall.Infrastructure.Tests/AnalysisJobDispatcherJobTests.cs index 4ea19c5..136b19b 100644 --- a/tests/Heimdall.Infrastructure.Tests/AnalysisJobDispatcherJobTests.cs +++ b/tests/Heimdall.Infrastructure.Tests/AnalysisJobDispatcherJobTests.cs @@ -17,7 +17,7 @@ namespace Heimdall.Infrastructure.Tests; [Collection("PostgresInfra")] public class AnalysisJobDispatcherJobTests : IAsyncLifetime { - private readonly IDbContextFactory _dbFactory; + private readonly TestDbContextFactory _dbFactory; private readonly AnalysisJobSchedulerService _schedulerService; private readonly AnalysisJobDispatcherJob _dispatcher; diff --git a/tests/Heimdall.Infrastructure.Tests/AnalysisJobSchedulerServiceTests.cs b/tests/Heimdall.Infrastructure.Tests/AnalysisJobSchedulerServiceTests.cs index bf5e677..52f5ebf 100644 --- a/tests/Heimdall.Infrastructure.Tests/AnalysisJobSchedulerServiceTests.cs +++ b/tests/Heimdall.Infrastructure.Tests/AnalysisJobSchedulerServiceTests.cs @@ -16,7 +16,7 @@ namespace Heimdall.Infrastructure.Tests; [Collection("PostgresInfra")] public class AnalysisJobSchedulerServiceTests : IAsyncLifetime { - private readonly IDbContextFactory _dbFactory; + private readonly TestDbContextFactory _dbFactory; private readonly AnalysisJobSchedulerService _service; private readonly ILogger _logger = Substitute.For>(); diff --git a/tests/Heimdall.Infrastructure.Tests/BusinessEntityPersistenceTests.cs b/tests/Heimdall.Infrastructure.Tests/BusinessEntityPersistenceTests.cs index 51b16f9..e8f0545 100644 --- a/tests/Heimdall.Infrastructure.Tests/BusinessEntityPersistenceTests.cs +++ b/tests/Heimdall.Infrastructure.Tests/BusinessEntityPersistenceTests.cs @@ -17,7 +17,7 @@ namespace Heimdall.Infrastructure.Tests; [Collection("PostgresInfra")] public class BusinessEntityPersistenceTests : IAsyncLifetime { - private readonly IDbContextFactory _dbFactory; + private readonly TestDbContextFactory _dbFactory; public BusinessEntityPersistenceTests(PostgreSqlContainerFixture postgres) { diff --git a/tests/Heimdall.Infrastructure.Tests/CameraAssignmentServiceTests.cs b/tests/Heimdall.Infrastructure.Tests/CameraAssignmentServiceTests.cs index f85178c..3ba9e22 100644 --- a/tests/Heimdall.Infrastructure.Tests/CameraAssignmentServiceTests.cs +++ b/tests/Heimdall.Infrastructure.Tests/CameraAssignmentServiceTests.cs @@ -16,7 +16,7 @@ namespace Heimdall.Infrastructure.Tests; [Collection("PostgresInfra")] public class CameraAssignmentServiceTests : IAsyncLifetime { - private readonly IDbContextFactory _dbFactory; + private readonly TestDbContextFactory _dbFactory; private readonly ILogger _logger = Substitute.For>(); public CameraAssignmentServiceTests(PostgreSqlContainerFixture postgres) diff --git a/tests/Heimdall.Infrastructure.Tests/CameraEventServiceTests.cs b/tests/Heimdall.Infrastructure.Tests/CameraEventServiceTests.cs index cefc7e9..c776358 100644 --- a/tests/Heimdall.Infrastructure.Tests/CameraEventServiceTests.cs +++ b/tests/Heimdall.Infrastructure.Tests/CameraEventServiceTests.cs @@ -17,7 +17,7 @@ namespace Heimdall.Infrastructure.Tests; [Collection("PostgresInfra")] public class CameraEventServiceTests : IAsyncLifetime { - private readonly IDbContextFactory _dbFactory; + private readonly TestDbContextFactory _dbFactory; private readonly ILogger _logger = Substitute.For>(); private readonly IServiceProvider _serviceProvider = Substitute.For();