//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldFreeOnClose()
        internal virtual void ShouldFreeOnClose()
        {
            // given
            MemoryAllocationTracker tracker = new LocalMemoryTracker();

            using (UnsafeDirectByteBufferAllocator factory = new UnsafeDirectByteBufferAllocator(tracker))
            {
                // when
                factory.Allocate(256);
            }

            // then
            assertEquals(0, tracker.UsedDirectMemory());
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldHandleMultipleClose()
        internal virtual void ShouldHandleMultipleClose()
        {
            // given
            MemoryAllocationTracker         tracker = new LocalMemoryTracker();
            UnsafeDirectByteBufferAllocator factory = new UnsafeDirectByteBufferAllocator(tracker);

            // when
            factory.Allocate(256);
            factory.Close();

            // then
            assertEquals(0, tracker.UsedDirectMemory());
            factory.Close();
            assertEquals(0, tracker.UsedDirectMemory());
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldAllocateBuffer()
        internal virtual void ShouldAllocateBuffer()
        {
            // given
            MemoryAllocationTracker tracker = new LocalMemoryTracker();

            using (UnsafeDirectByteBufferAllocator factory = new UnsafeDirectByteBufferAllocator(tracker))
            {
                // when
                int bufferSize = 128;
                factory.Allocate(bufferSize);

                // then
                assertEquals(bufferSize, tracker.UsedDirectMemory());
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotAllocateAfterClosed()
        internal virtual void ShouldNotAllocateAfterClosed()
        {
            // given
            UnsafeDirectByteBufferAllocator factory = new UnsafeDirectByteBufferAllocator(new LocalMemoryTracker());

            factory.Close();

            // when
            try
            {
                factory.Allocate(8);
            }
            catch (System.InvalidOperationException)
            {
                // then good
            }
        }