Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void delete()
        public virtual void Delete()
        {
            IdGeneratorImpl.createGenerator(_fs, IdGeneratorFile(), 0, false);
            IdGeneratorImpl idGenerator = new IdGeneratorImpl(_fs, IdGeneratorFile(), 10, 1000, false, IdType.NODE, () => 0L);
            long            id          = idGenerator.NextId();

            idGenerator.NextId();
            idGenerator.FreeId(id);
            idGenerator.Dispose();
            idGenerator.Delete();
            assertFalse(IdGeneratorFile().exists());
            IdGeneratorImpl.createGenerator(_fs, IdGeneratorFile(), 0, false);
            idGenerator = new IdGeneratorImpl(_fs, IdGeneratorFile(), 10, 1000, false, IdType.NODE, () => 0L);
            assertEquals(id, idGenerator.NextId());
            idGenerator.Dispose();
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustOverwriteExistingFileIfRequested()
        public virtual void MustOverwriteExistingFileIfRequested()
        {
            IdGeneratorImpl.createGenerator(_fs, IdGeneratorFile(), 0, false);
            IdGenerator idGenerator = new IdGeneratorImpl(_fs, IdGeneratorFile(), 1008, 1000, false, IdType.NODE, () => 0L);

            long[] firstFirstIds = new long[] { idGenerator.NextId(), idGenerator.NextId(), idGenerator.NextId() };
            idGenerator.Dispose();

            IdGeneratorImpl.createGenerator(_fs, IdGeneratorFile(), 0, false);
            idGenerator = new IdGeneratorImpl(_fs, IdGeneratorFile(), 1008, 1000, false, IdType.NODE, () => 0L);
            long[] secondFirstIds = new long[] { idGenerator.NextId(), idGenerator.NextId(), idGenerator.NextId() };
            idGenerator.Dispose();

            // Basically, recreating the id file should be the same as start over with the ids.
            assertThat(secondFirstIds, @is(firstFirstIds));
        }