예제 #1
0
        public void Resource_DecRef()
        {
            Resource resource;

            // Calling DecRef with a RefCount equal to 0 dispose
            resource = new TestResource();
            Assert.IsFalse(resource.IsDisposed);
            Assert.AreEqual(0u, resource.RefCount);

            resource.DecRef();
            Assert.IsTrue(resource.IsDisposed);

            // Calling DecRef with a RefCount equal to 1 dispose all the same
            resource = new TestResource();
            Assert.IsFalse(resource.IsDisposed);
            Assert.AreEqual(0u, resource.RefCount);

            resource.IncRef();
            Assert.AreEqual(1u, resource.RefCount);

            resource.DecRef();
            Assert.IsTrue(resource.IsDisposed);
        }