//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRemoveUpwardsFrom() public virtual void ShouldRemoveUpwardsFrom() { // given int cacheSize = 100; RaftLogMetadataCache cache = new RaftLogMetadataCache(cacheSize); for (int i = 0; i < cacheSize; i++) { cache.CacheMetadata(i, i, new LogPosition(i, i)); } // when int upFrom = 60; cache.RemoveUpwardsFrom(upFrom); // then long i = 0; for ( ; i < upFrom; i++) { RaftLogMetadataCache.RaftLogEntryMetadata metadata = cache.GetMetadata(i); assertNotNull(metadata); assertEquals(i, metadata.EntryTerm); } for ( ; i < cacheSize; i++) { assertNull(cache.GetMetadata(i)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAcceptAndReturnIndexesInRangeJustDeleted() public virtual void ShouldAcceptAndReturnIndexesInRangeJustDeleted() { // given int cacheSize = 100; RaftLogMetadataCache cache = new RaftLogMetadataCache(cacheSize); for (int i = 0; i < cacheSize; i++) { cache.CacheMetadata(i, i, new LogPosition(i, i)); } // when int upFrom = 60; cache.RemoveUpwardsFrom(upFrom); // and we add something in the deleted range int insertedIndex = 70; long insertedTerm = 150; cache.CacheMetadata(insertedIndex, insertedTerm, new LogPosition(insertedIndex, insertedIndex)); // then // nothing should be resurrected in the deleted range just because we inserted something there int i = upFrom; for ( ; i < insertedIndex; i++) { assertNull(cache.GetMetadata(i)); } // i here should be insertedIndex assertEquals(insertedTerm, cache.GetMetadata(i).EntryTerm); i++; // to continue iteration in the rest of the deleted range for ( ; i < cacheSize; i++) { assertNull(cache.GetMetadata(i)); } }