Пример #1
0
        public int GetId(int?id = null)
        {
            if (false == id.HasValue)
            {
                return(IdPool.AllocateInstance());
            }

            IdPool.AllocateSpecificId(id.Value);

            return(id.Value);
        }
Пример #2
0
        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));
        }