using Microsoft.Extensions.DependencyInjection;
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories;
namespace ZB.MOM.WW.ScadaBridge.AuditLog.Tests.TestSupport;
///
/// Deferred-work register row 61 — the replacement for AuditLogIngestActor's deleted
/// repository-taking "test-mode" constructor.
///
///
/// That constructor cached a scoped repository on an actor field for the actor's whole
/// lifetime. Nothing in production selected it, but the shape was one call site away from
/// re-introducing a captive-dependency bug, so it had to be allowlisted in the Host tests'
/// CaptiveDependencyGuard. The actor now has a single
/// constructor; a fixture that wants a concrete repository builds one of these instead.
///
///
///
/// Behaviour is unchanged for the ingest path: the old ctor passed redactor: null and
/// failureCounter: null, and a provider with neither registered resolves both to null
/// too — so the actor still falls back to SafeDefaultAuditRedactor and still logs
/// without a health counter. The one deliberate difference is that
/// IngestCachedTelemetryCommand now takes the real dual-write handler rather than the
/// deleted "no dual write" stub; no fixture built on this helper sends that message.
///
///
internal static class StubAuditRepositoryProvider
{
///
/// Builds a provider whose every scope yields the same audit-log repository instance.
///
/// Repository instance shared by every scope.
public static ServiceProvider Build(IAuditLogRepository repository)
{
ArgumentNullException.ThrowIfNull(repository);
return new ServiceCollection()
.AddScoped(_ => repository)
.BuildServiceProvider();
}
}