public void LoggingTestWithConstraintExpressionWithKeyedExceptionHandler()
        {
            LogExceptionHandler exHandler = new LogExceptionHandler();

            ExecuteLoggingHandlerWithKeyedLogHandler(exHandler,
                                                     @"on exception (#e is T(System.ArithmeticException)) log 'Request Timeout occured'", "Request Timeout");
        }
        public void LoggingTestWithConstraintExpressionWithExceptionHandlerInList()
        {
            LogExceptionHandler exHandler = new LogExceptionHandler();

            exHandler.ConstraintExpressionText = "#e is T(System.ArithmeticException)";
            exHandler.LogName = "adviceHandler";
            exHandler.ActionExpressionText = "#log.Fatal('Request Timeout occured', #e)";

            ExecuteLoggingHandlerInList(exHandler, "Request Timeout");
        }
        public void LoggingTest()
        {
            LogExceptionHandler logHandler = new LogExceptionHandler();

            logHandler.LogName = "adviceHandler";
            string testText =
                @"'Hello World, exception message = ' + #e.Message + ', target method = ' + #method.Name";

            logHandler.SourceExceptionNames.Add("ArithmeticException");
            logHandler.ActionExpressionText = testText;

            exceptionHandlerAdvice.ExceptionHandlers.Add(logHandler);

            exceptionHandlerAdvice.AfterPropertiesSet();

            ProxyFactory pf = new ProxyFactory(new TestObject());

            pf.AddAdvice(exceptionHandlerAdvice);
            ITestObject to = (ITestObject)pf.GetProxy();

            try
            {
                to.Exceptional(new ArithmeticException());
                Assert.Fail("Should have thrown exception when only logging");
            }
            catch (ArithmeticException)
            {
                bool found = false;
                foreach (string message in loggerFactoryAdapter.LogMessages)
                {
                    if (message.IndexOf("Hello World") >= 0)
                    {
                        found = true;
                    }
                }
                Assert.IsTrue(found, "did not find logging output");
            }
        }