public void TestDisposeCalled()
 {
     TestDisposable.ParamValue    = null;
     TestDisposable.DisposeCalled = false;
     using (var c = new TestDisposable())
     {
     }
     Assert.IsTrue(TestDisposable.DisposeCalled);
     Assert.IsNotNull(TestDisposable.ParamValue);
     Assert.IsTrue(TestDisposable.ParamValue.Value);
 }
 public void TestFinalizerCalled()
 {
     TestDisposable.ParamValue = null;
     TestDisposable.DisposeCalled = false;
     var c = new TestDisposable();
     c = null;
     GC.Collect();
     GC.WaitForPendingFinalizers();
     Assert.IsTrue(TestDisposable.DisposeCalled);
     Assert.IsNotNull(TestDisposable.ParamValue);
     Assert.IsFalse(TestDisposable.ParamValue.Value);
 }
        public void TestDisposeCalled()
        {
            TestDisposable.ParamValue = null;
            TestDisposable.DisposeCalled = false;
            using (var c = new TestDisposable())
            {

            }
            Assert.IsTrue(TestDisposable.DisposeCalled);
            Assert.IsNotNull(TestDisposable.ParamValue);
            Assert.IsTrue(TestDisposable.ParamValue.Value);
        }
        public void TestFinalizerCalled()
        {
            TestDisposable.ParamValue    = null;
            TestDisposable.DisposeCalled = false;
            var c = new TestDisposable();

            c = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
            Assert.IsTrue(TestDisposable.DisposeCalled);
            Assert.IsNotNull(TestDisposable.ParamValue);
            Assert.IsFalse(TestDisposable.ParamValue.Value);
        }
 public void TestDoubleDisposedCalled()
 {
     TestDisposable.ParamValue = null;
     TestDisposable.DisposeCalled = false;
     var c = new TestDisposable();
     c.Dispose();
     Assert.IsTrue(TestDisposable.DisposeCalled);
     Assert.IsNotNull(TestDisposable.ParamValue);
     Assert.IsTrue(TestDisposable.ParamValue.Value);
     c.Dispose();
     TestDisposable.ParamValue = null;
     TestDisposable.DisposeCalled = false;
     Assert.IsFalse(TestDisposable.DisposeCalled);
     Assert.IsNull(TestDisposable.ParamValue);
 }
        public void TestDoubleDisposedCalled()
        {
            TestDisposable.ParamValue    = null;
            TestDisposable.DisposeCalled = false;
            var c = new TestDisposable();

            c.Dispose();
            Assert.IsTrue(TestDisposable.DisposeCalled);
            Assert.IsNotNull(TestDisposable.ParamValue);
            Assert.IsTrue(TestDisposable.ParamValue.Value);
            c.Dispose();
            TestDisposable.ParamValue    = null;
            TestDisposable.DisposeCalled = false;
            Assert.IsFalse(TestDisposable.DisposeCalled);
            Assert.IsNull(TestDisposable.ParamValue);
        }