using Acceptance.Support; using Big.Application; using Big.Domain; using Reqnroll; using Xunit; namespace Acceptance.Steps; /// Bindings for RegistratieIndienen.feature (S-05). Drives the SubmitRegistration /// and OpenZaakWorker use cases against in-memory ports; one instance per scenario. [Binding] public sealed class RegistratieIndienenSteps { private readonly InMemoryWorkflowClient _workflow = new(); private readonly InMemoryAclClient _acl = new(); private readonly InMemoryRegistrationStore _store = new(); private string _bsn = ""; private RegistrationId _id; [Given("a zorgprofessional submits a registration for BSN \"(.*)\"")] public void GivenAZorgprofessionalSubmitsARegistration(string bsn) => _bsn = bsn; [When("the domain service handles the submission")] public async Task WhenTheDomainServiceHandlesTheSubmission() => _id = await new SubmitRegistration(_store, _workflow).HandleAsync(new SubmitRegistrationCommand(_bsn)); [Then("a registratie process is started for the registration")] public void ThenARegistratieProcessIsStarted() => Assert.Equal(_id, _workflow.StartedFor); [Then("the registration has status \"(.*)\"")] public async Task ThenTheRegistrationHasStatus(string expected) { var registration = await _store.GetAsync(_id); Assert.NotNull(registration); Assert.Equal(expected, registration.Status.ToString().ToUpperInvariant()); Assert.Equal(InMemoryWorkflowClient.StartedProcessInstanceId, registration.ProcessInstanceId); } [When("the OpenZaakAanmaken external task is handled for the registration")] public async Task WhenTheExternalTaskIsHandled() => await new OpenZaakWorker(_store, _acl).HandleAsync(new OpenZaakJob("job-acc-1", _id)); [Then("a zaak is opened via the ACL for BSN \"(.*)\"")] public void ThenAZaakIsOpenedViaTheAcl(string bsn) => Assert.Equal(bsn, _acl.OpenedForBsn); [Then("the zaak is recorded on the registration")] public async Task ThenTheZaakIsRecordedOnTheRegistration() { var registration = await _store.GetAsync(_id); Assert.Equal(InMemoryAclClient.OpenedZaakUrl, registration!.ZaakUrl); } }