//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReadDefragCountUsingStaticMethod() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReadDefragCountUsingStaticMethod() { EphemeralFileSystemAbstraction fs = Fsr.get(); IdGeneratorImpl.CreateGenerator(fs, _file, 0, false); IdGeneratorImpl idGenerator = new IdGeneratorImpl(fs, _file, 1, 10000, false, IdType.Node, () => 0L); idGenerator.NextId(); long a = idGenerator.NextId(); idGenerator.NextId(); long b = idGenerator.NextId(); idGenerator.NextId(); idGenerator.FreeId(a); idGenerator.FreeId(b); long expectedDefragCount = idGenerator.DefragCount; idGenerator.Dispose(); long actualDefragCount = IdGeneratorImpl.ReadDefragCount(fs, _file); assertEquals(2, expectedDefragCount); assertEquals(expectedDefragCount, actualDefragCount); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToReadWrittenGenerator() public virtual void ShouldBeAbleToReadWrittenGenerator() { // Given IdGeneratorImpl.CreateGenerator(Fsr.get(), _file, 42, false); IdGeneratorImpl idGenerator = new IdGeneratorImpl(Fsr.get(), _file, 100, 100, false, IdType.Node, () => 42L); idGenerator.Dispose(); // When idGenerator = new IdGeneratorImpl(Fsr.get(), _file, 100, 100, false, IdType.Node, () => 0L); // Then assertThat(idGenerator.HighId, equalTo(42L)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void correctDefragCountWhenHaveIdsInFile() public virtual void CorrectDefragCountWhenHaveIdsInFile() { IdGeneratorImpl.CreateGenerator(Fsr.get(), _file, 100, false); IdGenerator idGenerator = new IdGeneratorImpl(Fsr.get(), _file, 100, 100, true, IdType.Node, () => 100L); idGenerator.FreeId(5); idGenerator.Dispose(); IdGenerator reloadedIdGenerator = new IdGeneratorImpl(Fsr.get(), _file, 100, 100, true, IdType.Node, () => 100L); assertEquals(1, reloadedIdGenerator.DefragCount); assertEquals(5, reloadedIdGenerator.NextId()); assertEquals(0, reloadedIdGenerator.DefragCount); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void constructorShouldNotCallHighIdSupplierOnCleanIdFile() public virtual void ConstructorShouldNotCallHighIdSupplierOnCleanIdFile() { // Given // A non empty, clean id file IdContainer.CreateEmptyIdFile(Fsr.get(), _file, 42, true); // and a mock supplier to test against System.Func <long> highId = mock(typeof(System.Func <long>)); // When // An IdGenerator is created over the previous properly closed file IdGenerator idGenerator = new IdGeneratorImpl(Fsr.get(), _file, 100, 100, false, IdType.Node, highId); idGenerator.Dispose(); // Then // The supplier must have remained untouched verifyZeroInteractions(highId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void constructorShouldCallHighIdSupplierOnNonExistingIdFile() public virtual void ConstructorShouldCallHighIdSupplierOnNonExistingIdFile() { // Given // An empty file (default, nothing to do) // and a mock supplier to test against System.Func <long> highId = mock(typeof(System.Func <long>)); when(highId()).thenReturn(0L); // necessary, otherwise it runs into NPE in the constructor below // When // The id generator is started IdGeneratorImpl idGenerator = new IdGeneratorImpl(Fsr.get(), _file, 100, 100, false, IdType.Node, highId); // Then // The highId supplier must have been called to get the high id verify(highId).AsLong; idGenerator.Dispose(); }