示例#1
0
        public void IDisposable_Dispose()
        {
            int managedCalls = 0;
            int unmanagedCalls = 0;
            var presenter = new TEMPLATEMock(null, () => managedCalls++, () => unmanagedCalls++);

            presenter.Dispose();

            Assert.AreEqual(1, managedCalls, "DisposeManagedResources should have been called exactly once");
            Assert.AreEqual(1, unmanagedCalls, "DisposeUnmanagedResources should have been called exactly once");
        }
示例#2
0
        public void IDisposable_Dispose()
        {
            int managedCalls   = 0;
            int unmanagedCalls = 0;
            var presenter      = new TEMPLATEMock(null, () => managedCalls++, () => unmanagedCalls++);

            presenter.Dispose();

            Assert.AreEqual(1, managedCalls, "DisposeManagedResources should have been called exactly once");
            Assert.AreEqual(1, unmanagedCalls, "DisposeUnmanagedResources should have been called exactly once");
        }
示例#3
0
        public void IDisposable_Finalizer()
        {
            int unmanagedCalls = 0;
            var presenter = new TEMPLATEMock(null,
                () => Assert.Fail("DisposeManagedResources MUST not be called from finalizer"),
                () => unmanagedCalls++);

            presenter = null;
            System.GC.Collect();
            System.GC.WaitForPendingFinalizers();

            Assert.AreEqual(1, unmanagedCalls, "DisposeUnmanagedResources should have been called exactly once");
        }
示例#4
0
        public void IDisposable_Finalizer()
        {
            int unmanagedCalls = 0;
            var presenter      = new TEMPLATEMock(null,
                                                  () => Assert.Fail("DisposeManagedResources MUST not be called from finalizer"),
                                                  () => unmanagedCalls++);

            presenter = null;
            System.GC.Collect();
            System.GC.WaitForPendingFinalizers();

            Assert.AreEqual(1, unmanagedCalls, "DisposeUnmanagedResources should have been called exactly once");
        }