public void CreateGrowArrayProcess() { var concurrentArray = new ConcurrentArrayBuilder <string, object>().Build(); var newArraySize = LinearDoublingPrimeStrategy.GetNextCapacity(concurrentArray.Capacity); var spy = new ExchangeArraySpy <string, object>(); var growArrayProcess = new GrowArrayProcess <string, object>(concurrentArray, newArraySize, spy.ExchangeArray); var existingProcess = concurrentArray.EstablishGrowArrayProcess(growArrayProcess); existingProcess.Should().Be(null); concurrentArray.ReadGrowArrayProcessVolatile().Should().BeSameAs(growArrayProcess); spy.ExchangeArrayMustNotHaveBeenCalled(); }
public void GetExistingGrowArrayProcess() { var concurrentArray = new ConcurrentArrayBuilder <Type, object>().Build(); var newArraySize = LinearDoublingPrimeStrategy.GetNextCapacity(concurrentArray.Capacity); var spy = new ExchangeArraySpy <Type, object>(); var growArrayProcess = new GrowArrayProcess <Type, object>(concurrentArray, newArraySize, spy.ExchangeArray); concurrentArray.EstablishGrowArrayProcess(growArrayProcess); var otherGrowArrayProcess = new GrowArrayProcess <Type, object>(concurrentArray, newArraySize, spy.ExchangeArray); var existingProcess = concurrentArray.EstablishGrowArrayProcess(otherGrowArrayProcess); existingProcess.Should().BeSameAs(growArrayProcess); concurrentArray.ReadGrowArrayProcessVolatile().Should().BeSameAs(growArrayProcess); }