public int GetId(int?id = null) { if (false == id.HasValue) { return(IdPool.AllocateInstance()); } IdPool.AllocateSpecificId(id.Value); return(id.Value); }
public void should_expand_and_allocate_and_remove_specific_id_when_claiming_bigger_than_available() { var explicitNewId = 30; var idPool = new IdPool(10, 10); idPool.AllocateSpecificId(explicitNewId); Assert.Equal(idPool.AvailableIds.Count, explicitNewId - 1); var expectedIdEntries = Enumerable.Range(1, explicitNewId - 2).ToArray(); Assert.All(idPool.AvailableIds, x => expectedIdEntries.Contains(x)); }