public void TestToByteBufException() { NativePooledByteBufferOutputStream os1 = new NativePooledByteBufferOutputStream(_pool); os1.Dispose(); try { os1.ToByteBuffer(); Assert.Fail(); } catch (InvalidStreamException) { // This is expected } }
public void TestClose() { NativePooledByteBufferOutputStream os = new NativePooledByteBufferOutputStream(_pool); os.Dispose(); _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>(0, 0) }, { 4, new Tuple <int, int>(0, 1) } }; Assert.IsTrue(testStat.All(e => _stats.BucketStats.Contains(e))); }
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()); }