Example #1
0
        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);
            }
        }
Example #2
0
        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);
            }
        }
Example #3
0
 public TestClassThrowInMethod(DisposeNotice dn)
 {
     _dn = dn;
 }
Example #4
0
 public TestClassThrowInConstructor(DisposeNotice dn)
 {
     _dn = dn;
     throw new ApplicationException("TestClassThrowInConstructor");
 }