public void HandlerMethodThrowsException()
        {
            Exception               exception   = new Exception();
            MyThrowsHandler         handler     = new ThrowingMyHandler(exception);
            ThrowsAdviceInterceptor interceptor = new ThrowsAdviceInterceptor(handler);
            // extends RemotingException...
            RemotingTimeoutException ex = new RemotingTimeoutException();

            MockRepository    repository = new MockRepository();
            IMethodInvocation mi         = (IMethodInvocation)repository.CreateMock(typeof(IMethodInvocation));

            Expect.Call(mi.Proceed()).Throw(ex);
            repository.ReplayAll();
            try
            {
                interceptor.Invoke(mi);
                Assert.Fail("Should not have reached this point, should have thrown an exception.");
            }
            catch (Exception caught)
            {
                Assert.AreEqual(exception, caught);
            }
            Assert.AreEqual(1, handler.GetCalls());
            Assert.AreEqual(1, handler.GetCalls("RemotingException"));
            repository.VerifyAll();
        }
        public void CorrectHandlerUsedForSubclass()
        {
            MyThrowsHandler         th = new MyThrowsHandler();
            ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
            // Extends RemotingException
            RemotingTimeoutException ex = new RemotingTimeoutException();

            MockRepository    repository = new MockRepository();
            IMethodInvocation mi         = (IMethodInvocation)repository.CreateMock(typeof(IMethodInvocation));

            Expect.Call(mi.Proceed()).Throw(ex);
            repository.ReplayAll();
            try
            {
                ti.Invoke(mi);
                Assert.Fail();
            }
            catch (Exception caught)
            {
                Assert.AreEqual(ex, caught);
            }
            Assert.AreEqual(1, th.GetCalls());
            Assert.AreEqual(1, th.GetCalls("RemotingException"));

            repository.VerifyAll();
        }
        public void CorrectHandlerUsedForSubclass()
        {
            MyThrowsHandler         th = new MyThrowsHandler();
            ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
            // Extends RemotingException
            RemotingTimeoutException ex = new RemotingTimeoutException();

            IMethodInvocation mi = A.Fake <IMethodInvocation>();

            A.CallTo(() => mi.Proceed()).Throws(ex);

            try
            {
                ti.Invoke(mi);
                Assert.Fail();
            }
            catch (Exception caught)
            {
                Assert.AreEqual(ex, caught);
            }
            Assert.AreEqual(1, th.GetCalls());
            Assert.AreEqual(1, th.GetCalls("RemotingException"));
        }