//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldTrackUsedMemory() public virtual void ShouldTrackUsedMemory() { int capacity = 4; ConsecutiveInFlightCache cache = new ConsecutiveInFlightCache(capacity, 1000, InFlightCacheMonitor.VOID, true); for (int i = 0; i < capacity; i++) { // when cache.Put(i, Content(100)); // then assertEquals((i + 1) * 100, cache.TotalBytes()); } // when cache.Put(capacity, Content(100)); // then assertEquals(capacity, cache.ElementCount()); assertEquals(capacity * 100, cache.TotalBytes()); // when cache.Put(capacity + 1, Content(500)); assertEquals(capacity, cache.ElementCount()); assertEquals(800, cache.TotalBytes()); // when cache.Put(capacity + 2, Content(500)); assertEquals(2, cache.ElementCount()); assertEquals(1000, cache.TotalBytes()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRemoveTruncatedItems() public virtual void ShouldRemoveTruncatedItems() { // given int capacity = 20; ConsecutiveInFlightCache cache = new ConsecutiveInFlightCache(capacity, 1000, InFlightCacheMonitor.VOID, true); for (int i = 0; i < capacity; i++) { cache.Put(i, Content(i)); } // when int fromIndex = capacity / 2; cache.Truncate(fromIndex); // then assertEquals(fromIndex, cache.ElementCount()); assertEquals((fromIndex * (fromIndex - 1)) / 2, cache.TotalBytes()); for (int i = fromIndex; i < capacity; i++) { assertNull(cache.Get(i)); } }