public async Task TestWritesToDiskCache() { await _bufferedDiskCache.Put(_cacheKey, _encodedImage); // Ref count should be equal to 2 ('owned' by the _closeableReference and other 'owned' by // _encodedImage) Assert.IsTrue(2 == _closeableReference.GetUnderlyingReferenceTestOnly().GetRefCountTestOnly()); }
public void TestByteBufferRef() { EncodedImage encodedImage = new EncodedImage(_byteBufferRef); Assert.AreEqual(2, _byteBufferRef.GetUnderlyingReferenceTestOnly().GetRefCountTestOnly()); Assert.AreSame( encodedImage.GetByteBufferRef().GetUnderlyingReferenceTestOnly(), _byteBufferRef.GetUnderlyingReferenceTestOnly()); }
public void TestClone() { CloseableReference <IDisposable> copy = _closeableReference.Clone(); Assert.AreEqual(2, _closeableReference.GetUnderlyingReferenceTestOnly().GetRefCountTestOnly()); Assert.AreSame(_closeableReference.GetUnderlyingReferenceTestOnly(), copy.GetUnderlyingReferenceTestOnly()); }
public void TestAnotherPut() { _stagingArea.Put(_cacheKey, _secondEncodedImage); Assert.AreEqual(2, _closeableReference.GetUnderlyingReferenceTestOnly().GetRefCountTestOnly()); Assert.AreSame( _closeableReference2.GetUnderlyingReferenceTestOnly(), _stagingArea.Get(_cacheKey).GetByteBufferRef().GetUnderlyingReferenceTestOnly()); }
/// <summary> /// A test-only method to get the underlying references. /// /// <para /><b>DO NOT USE in application code.</b> /// </summary> public SharedReference <IPooledByteBuffer> GetUnderlyingReferenceTestOnly() { lock (_imageGate) { return((_pooledByteBufferRef != null) ? _pooledByteBufferRef.GetUnderlyingReferenceTestOnly() : null); } }
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> /// Reference assertions /// </summary> private void AssertReferenceCount <T>(int expectedCount, CloseableReference <T> reference) { Assert.IsTrue(expectedCount == reference.GetUnderlyingReferenceTestOnly().GetRefCountTestOnly()); }
public void TestCreation() { Assert.AreEqual(1, _closeableReference.GetUnderlyingReferenceTestOnly().GetRefCountTestOnly()); }
public void TestGetValue() { Assert.AreSame( _closeableReference.GetUnderlyingReferenceTestOnly(), _stagingArea.Get(_cacheKey).GetByteBufferRef().GetUnderlyingReferenceTestOnly()); }