コード例 #1
0
        public void LogDebugFull()
        {
            ILogger logger = LogFactory.GetLogger <LogFactoryTests>();

            logger.filterLogType = LogType.Log;

            ILogHandler mockHandler = Substitute.For <ILogHandler>();

            logger.logHandler = mockHandler;
            logger.Log("This message be logged");
            mockHandler.Received().LogFormat(LogType.Log, null, "{0}", "This message be logged");
        }
コード例 #2
0
        void ExpectLog(Action action, string log)
        {
            ILogger     logger        = LogFactory.GetLogger(typeof(MessageHandler));
            ILogHandler existing      = logger.logHandler;
            LogType     existingLevel = logger.filterLogType;

            try
            {
                ILogHandler handler = Substitute.For <ILogHandler>();
                logger.logHandler    = handler;
                logger.filterLogType = LogType.Log;

                action.Invoke();

                handler.Received(1).LogFormat(LogType.Log, null, "{0}", log);
            }
            finally
            {
                logger.logHandler    = existing;
                logger.filterLogType = existingLevel;
            }
        }