using Acceptance.Support; using EventSubscriber.Application; using Reqnroll; using Xunit; namespace Acceptance.Steps; /// Bindings for RegisterProjectieBijwerken.feature (S-06). Reqnroll creates /// one instance per scenario, so instance fields hold scenario-scoped state. [Binding] public sealed class RegisterProjectieBijwerkenSteps { private const string ZaakBase = "http://openzaak:8000/zaken/api/v1/zaken/"; private readonly InMemoryNotificationLog _log = new(); private readonly InMemoryProjectionStore _store = new(); private readonly NotificationProjector _projector; private Notification? _notification; public RegisterProjectieBijwerkenSteps() => _projector = new NotificationProjector(_log, _store, new InMemoryAclReferenceClient()); [Given("a zaak is created in OpenZaak with id \"(.*)\"")] public void GivenAZaakIsCreatedInOpenZaakWithId(string id) => _notification = new Notification("zaken", "zaak", "create", new Uri(ZaakBase + id)); [When("the NRC notification for that zaak is delivered to the event subscriber")] public Task WhenTheNotificationIsDelivered() => _projector.HandleAsync(_notification!); [When("the same NRC notification is delivered again")] public Task WhenTheSameNotificationIsDeliveredAgain() => _projector.HandleAsync(_notification!); [Then("the register projection contains a row for \"(.*)\" with status \"(.*)\"")] public async Task ThenTheProjectionContainsARowWithStatus(string id, string status) { var entry = Assert.Single(await _store.AllAsync()); Assert.Equal(id, entry.Id); Assert.Equal(status, entry.Status); } [Then("the register projection contains exactly one row for \"(.*)\"")] public async Task ThenTheProjectionContainsExactlyOneRowFor(string id) { await _store.AllAsync(); Assert.Single(_store.RowsFor(id)); } }