public void should_allocate_correctly() { var initialSize = 1; var componentPool = new ComponentPool <TestComponentOne>(initialSize); var allocation = componentPool.Allocate(); Assert.Equal(0, allocation); Assert.Equal(0, componentPool.IndexesRemaining); }
public void should_expand_for_allocations_exceeding_count_correctly() { var expectedAllocationCount = 10; var expansionSize = 2; var initialSize = 2; var expectedAllocations = Enumerable.Range(0, expectedAllocationCount).ToList(); var actualAllocations = new List <int>(); var componentPool = new ComponentPool <TestComponentOne>(expansionSize, initialSize); for (var i = 0; i < expectedAllocationCount; i++) { var allocation = componentPool.Allocate(); actualAllocations.Add(allocation); } Assert.Equal(expectedAllocationCount, actualAllocations.Count); Assert.All(actualAllocations, x => expectedAllocations.Contains(x)); Assert.Equal(expectedAllocationCount, componentPool.Components.Length); Assert.Equal(expectedAllocationCount, componentPool.Count); }