Пример #1
0
        public void TestNewByteBuf_5()
        {
            NativePooledByteBuffer sb5 = (NativePooledByteBuffer)_factory.NewByteBuffer(5);

            Assert.AreEqual(8, sb5._bufRef.Get().Size);
            Assert.AreEqual(1, sb5._bufRef.GetUnderlyingReferenceTestOnly().GetRefCountTestOnly());
            _stats.Refresh();
            var testStat = new Dictionary <int, Tuple <int, int> >()
            {
                { 32, new Tuple <int, int>(0, 0) },
                { 16, new Tuple <int, int>(0, 0) },
                { 8, new Tuple <int, int>(1, 0) },
                { 4, new Tuple <int, int>(0, 0) }
            };

            Assert.IsTrue(testStat.All(e => _stats.BucketStats.Contains(e)));
            sb5.Dispose();

            _stats.Refresh();
            testStat = new Dictionary <int, Tuple <int, int> >()
            {
                { 32, new Tuple <int, int>(0, 0) },
                { 16, new Tuple <int, int>(0, 0) },
                { 8, new Tuple <int, int>(0, 1) },
                { 4, new Tuple <int, int>(0, 0) }
            };

            Assert.IsTrue(testStat.All(e => _stats.BucketStats.Contains(e)));
        }
Пример #2
0
        public void TestWriteAfterToByteBuf()
        {
            NativePooledByteBufferOutputStream os1 = new NativePooledByteBufferOutputStream(_pool);

            byte[] _data1 = new byte[9];
            byte[] _data2 = new byte[3];
            Array.Copy(_data, _data1, _data1.Length);
            Array.Copy(_data, _data2, _data2.Length);
            NativePooledByteBuffer buf1 = DoWrite(os1, _data1);
            NativePooledByteBuffer buf2 = DoWrite(os1, _data2);

            Assert.AreEqual(12, buf2.Size);

            CloseableReference <NativeMemoryChunk> chunk = buf1._bufRef;

            Assert.AreEqual(3, chunk.GetUnderlyingReferenceTestOnly().GetRefCountTestOnly());
            os1.Dispose();
            buf1.Dispose();
            buf2.Dispose();
            Assert.AreEqual(0, chunk.GetUnderlyingReferenceTestOnly().GetRefCountTestOnly());
        }
 /// <summary>
 /// Test cleanup.
 /// </summary>
 public void Dispose()
 {
     _pooledByteBuffer.Dispose();
     _chunk.Dispose();
 }