using System; using System.Collections.Generic; using System.Linq; using BoundaryLab.Domain; using BoundaryLab.Application; namespace BoundaryLab.Infrastructure; public sealed class MemoryCapacity : ICapacity { public int Free { get; private set; } public MemoryCapacity(int free) { if (free < 0) throw new ArgumentOutOfRangeException(nameof(free)); Free = free; } public void Commit(int units) { if (!CapacityRule.CanTake(units, Free)) throw new InvalidOperationException(); Free -= units; } }