using Big.Application; using Big.Domain; namespace Big.Tests; /// An in-memory for the application-layer tests. Upserts /// keyed on the registration id, mirroring the production store (kept distinct from the production /// InMemoryRegistrationStore so tests can seed and inspect save counts). internal sealed class FakeRegistrationStore : IRegistrationStore { private readonly Dictionary _byId = []; public int SaveCount { get; private set; } public Task SaveAsync(Registration registration, CancellationToken ct = default) { SaveCount++; _byId[registration.Id] = registration; return Task.CompletedTask; } public Task GetAsync(RegistrationId id, CancellationToken ct = default) => Task.FromResult(_byId.GetValueOrDefault(id)); public void Seed(Registration registration) => _byId[registration.Id] = registration; } /// A fake Workflow Client that records the registration it was asked to start a process for /// and returns a fixed process-instance id. An optional callback runs at start time, letting a test /// assert ordering (e.g. that the registration was persisted before the process started). internal sealed class FakeWorkflowClient(string processInstanceId = "proc-1", Action? onStart = null) : IWorkflowClient { public RegistrationId? StartedFor { get; private set; } public Task StartRegistrationProcessAsync(RegistrationId registrationId, CancellationToken ct = default) { onStart?.Invoke(registrationId); StartedFor = registrationId; return Task.FromResult(processInstanceId); } } /// A fake ACL client that records the bsn it was asked to open a zaak for and returns a /// fixed zaak URL. internal sealed class FakeAclClient(Uri? zaakUrl = null) : IAclClient { public static readonly Uri DefaultZaakUrl = new("http://openzaak/zaken/api/v1/zaken/abc"); private readonly Uri _zaakUrl = zaakUrl ?? DefaultZaakUrl; public string? OpenedForBsn { get; private set; } public int CallCount { get; private set; } public Task OpenZaakAsync(string bsn, CancellationToken ct = default) { CallCount++; OpenedForBsn = bsn; return Task.FromResult(_zaakUrl); } }