using System; using System.Collections.Generic; using System.Linq; using BoundaryLab.Domain; using BoundaryLab.Application; namespace BoundaryLab.Infrastructure; public sealed class MemoryReservationStore(InventoryState initial) : IReservationStore { private readonly List outbox = new(); public InventoryState Current { get; private set; } = initial; public IReadOnlyList Outbox => outbox.ToArray(); public bool TryCommit(InventoryState expected, InventoryState next, ReservationNotice notice) { if (Current.Version != expected.Version) return false; Current = next; outbox.Add(notice); return true; } }