public void Constructor_UsingWithThrowInConstructor_DisposeNotCalled() { var dn = new DisposeNotice(); try { // Expecting that Dispose is not called using (var testClass = new TestClassThrowInConstructor(dn)) { } } catch (ApplicationException) { } finally { Assert.IsFalse(dn.DisposeCalled); } }
public void Constructor_UsingWithThrowInMethod_DisposeIsCalled() { var dn = new DisposeNotice(); try { // Expecting that Dispose is called using (var testClass = new TestClassThrowInMethod(dn)) { testClass.ThrowMe(); } } catch (ApplicationException) { } finally { Assert.IsTrue(dn.DisposeCalled); } }
public TestClassThrowInMethod(DisposeNotice dn) { _dn = dn; }
public TestClassThrowInConstructor(DisposeNotice dn) { _dn = dn; throw new ApplicationException("TestClassThrowInConstructor"); }