예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotUseForbiddenMinusOneIdFromIdBatches()
        public virtual void ShouldNotUseForbiddenMinusOneIdFromIdBatches()
        {
            // GIVEN
            long[]  defragIds = new long[] { 3, 5 };
            int     size      = 10;
            long    low       = IdGeneratorImpl.INTEGER_MINUS_ONE - size / 2;
            IdRange idRange   = new IdRange(defragIds, low, size);

            // WHEN
            IdRangeIterator iterator = idRange.GetEnumerator();

            // THEN
            foreach (long id in defragIds)
            {
                assertEquals(id, iterator.NextId());
            }

            int expectedRangeSize = size - 1;               // due to the forbidden id

            for (long i = 0, expectedId = low; i < expectedRangeSize; i++, expectedId++)
            {
                if (expectedId == IdGeneratorImpl.INTEGER_MINUS_ONE)
                {
                    expectedId++;
                }

                long id = iterator.NextId();
                assertNotEquals(IdGeneratorImpl.INTEGER_MINUS_ONE, id);
                assertEquals(expectedId, id);
            }
            assertEquals(VALUE_REPRESENTING_NULL, iterator.NextId());
        }
예제 #2
0
 internal IdAllocation(IdRange idRange, long highestIdInUse, long defragCount)
 {
     this._idRange        = idRange;
     this._highestIdInUse = highestIdInUse;
     this._defragCount    = defragCount;
 }