Esempio n. 1
0
        public void Release_ShouldThrowIfTheObjectWasDisposed()
        {
            var obj = new DisposeByRefObject();

            Assert.That(obj.Release(), Is.EqualTo(0));
            Assert.Throws <ObjectDisposedException>(() => obj.Release());
        }
Esempio n. 2
0
        public void Release_ShouldDisposeTheObjectIfRefCountReachesTheZero()
        {
            var obj = new DisposeByRefObject();

            obj.AddRef();
            Assert.That(obj.Release(), Is.EqualTo(1));
            Assert.That(obj.Disposed, Is.False);
            Assert.That(obj.Release(), Is.EqualTo(0));
            Assert.That(obj.Disposed);
        }
Esempio n. 3
0
        public void Release_ShouldDecrementTheReferenceCount()
        {
            var obj = new DisposeByRefObject();

            Assert.That(obj.RefCount, Is.EqualTo(1));
            Assert.That(obj.Release(), Is.EqualTo(0));
            Assert.That(obj.RefCount, Is.EqualTo(0));
        }