Exemplo n.º 1
0
        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());
        }
Exemplo n.º 3
0
        public void TestClone()
        {
            CloseableReference <IDisposable> copy = _closeableReference.Clone();

            Assert.AreEqual(2, _closeableReference.GetUnderlyingReferenceTestOnly().GetRefCountTestOnly());
            Assert.AreSame(_closeableReference.GetUnderlyingReferenceTestOnly(), copy.GetUnderlyingReferenceTestOnly());
        }
Exemplo n.º 4
0
 public void TestAnotherPut()
 {
     _stagingArea.Put(_cacheKey, _secondEncodedImage);
     Assert.AreEqual(2, _closeableReference.GetUnderlyingReferenceTestOnly().GetRefCountTestOnly());
     Assert.AreSame(
         _closeableReference2.GetUnderlyingReferenceTestOnly(),
         _stagingArea.Get(_cacheKey).GetByteBufferRef().GetUnderlyingReferenceTestOnly());
 }
Exemplo n.º 5
0
 /// <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);
     }
 }
Exemplo n.º 6
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());
        }
Exemplo n.º 7
0
 /// <summary>
 /// Reference assertions
 /// </summary>
 private void AssertReferenceCount <T>(int expectedCount, CloseableReference <T> reference)
 {
     Assert.IsTrue(expectedCount == reference.GetUnderlyingReferenceTestOnly().GetRefCountTestOnly());
 }
Exemplo n.º 8
0
 public void TestCreation()
 {
     Assert.AreEqual(1, _closeableReference.GetUnderlyingReferenceTestOnly().GetRefCountTestOnly());
 }
Exemplo n.º 9
0
 public void TestGetValue()
 {
     Assert.AreSame(
         _closeableReference.GetUnderlyingReferenceTestOnly(),
         _stagingArea.Get(_cacheKey).GetByteBufferRef().GetUnderlyingReferenceTestOnly());
 }