using System; using System.Collections.Generic; using System.Linq; using BoundaryLab.Domain; using BoundaryLab.Application; namespace BoundaryLab.Infrastructure; internal sealed class InventoryState(int capacity) { public int Free { get; private set; } = capacity; public bool Allocate(int units) { if (units < 1 || units > Free) return false; Free -= units; return true; } } public sealed class InventoryFacade : IInventoryModule { private readonly InventoryState state; public InventoryFacade(int capacity) { if (capacity < 0) throw new ArgumentOutOfRangeException(nameof(capacity)); state = new InventoryState(capacity); } public int Remaining => state.Free; public bool Allocate(int units) => state.Allocate(units); }