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"); }
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"); }