public void TestValidateLoggerNotNullWithValid()
 {
     Logger logger = new SimpleLogger(NAME);
     Assert.AreSame(logger, Helper.ValidateLoggerNotNull(logger, NAME), "incorrect logger returned");
 }
        protected void SetUp()
        {
            namedMsg = new NamedMessage(MESSAGE, NAMEDMESSAGE, new List<string>(PARAMETER_NAMES),
                Level.ERROR);

            IDictionary<string, NamedMessage> msgs = new Dictionary<string, NamedMessage>();
            msgs.Add(NAMEDMESSAGE, new NamedMessage(MESSAGE, NAMEDMESSAGE,
                new List<string>(PARAMETER_NAMES), Level.ERROR));

            simpleLogger = new SimpleLogger(LOGGER_NAME, DEFAULT_LEVEL, msgs);

            filteredLevels = new List<Level>();
            filteredLevels.Add(Level.FATAL);

            logger = new LevelFilteredLogger(simpleLogger, filteredLevels);
        }
        protected void SetUp()
        {
            namedMsg = new NamedMessage(MESSAGE, NAMEDMESSAGE, new List<string>(PARAMETER_NAMES),
                Level.ERROR);

            config = new DefaultConfiguration("default");
            config.SetSimpleAttribute("logger_name", LOGGER_NAME);
            config.SetSimpleAttribute("default_level", DEFAULT_LEVEL.ToString());

            IConfiguration msgsConfig = new DefaultConfiguration("NamedMessages");

            IConfiguration msgConfig = new DefaultConfiguration(NAMEDMESSAGE);
            msgConfig.SetSimpleAttribute("text", MESSAGE);
            msgConfig.SetSimpleAttribute("default_level", Level.DEBUG.ToString());
            msgConfig.SetAttribute("parameters", new object[] {PARAMETER_NAMES[0], PARAMETER_NAMES[1]});
            msgsConfig.AddChild(msgConfig);

            config.AddChild(msgsConfig);

            simpleLogger = new SimpleLogger(config);

            anotherLogger = new AnotherSimpleLogger(EXCEPTION_LOGGER_NAME);

            logger = new ExceptionSafeLogger(simpleLogger, anotherLogger);
        }
        protected void SetUp()
        {
            IList<string> param = new List<string>();
            param.Add("param1");
            param.Add("param2");

            namedMsg = new NamedMessage("text1", NAME1, param, Level.ERROR);

            msgs = new Dictionary<string, NamedMessage>();
            msgs.Add(NAME1, namedMsg);
            msgs.Add(NAME2, new NamedMessage("text2", NAME2, new List<string>(), Level.WARN));

            config = new DefaultConfiguration("default");
            config.SetSimpleAttribute("logger_name", LOGNAME);
            config.SetSimpleAttribute("default_level", LEVEL.ToString());

            IConfiguration msgsConfig = new DefaultConfiguration("NamedMessages");

            IConfiguration msgConfig = new DefaultConfiguration(NAME1);
            msgConfig.SetSimpleAttribute("text", "text1");
            msgConfig.SetSimpleAttribute("default_level", Level.ERROR);
            msgConfig.SetAttribute("parameters", new object[] {"param1", "param2"});
            msgsConfig.AddChild(msgConfig);

            msgConfig = new DefaultConfiguration(NAME2);
            msgConfig.SetSimpleAttribute("text", "text2");
            msgConfig.SetSimpleAttribute("default_level", Level.WARN);
            msgsConfig.AddChild(msgConfig);

            config.AddChild(msgsConfig);

            logger = new SimpleLogger(LOGNAME, LEVEL, msgs);
        }
        public void TestCtorAccuracy2()
        {
            logger = new SimpleLogger(LOGNAME, LEVEL);

            Assert.AreEqual(0, logger.NamedMessages.Count, "incorrect number of named messages");
        }
        public void TestCtorConfigNoParametersInNamedMessage()
        {
            config.GetChild("NamedMessages").GetChild(NAME1).RemoveAttribute("parameters");

            logger = new SimpleLogger(config);

            Assert.AreEqual(0, logger.NamedMessages[NAME1].ParameterNames.Count,
                "incorrect number of parmeters of named message");
        }
        public void TestCtorConfigNoNamedMessages()
        {
            config.RemoveChild("NamedMessages");

            logger = new SimpleLogger(config);

            Assert.AreEqual(0, logger.NamedMessages.Count, "incorrect number of named messages");
        }
        public void TestCtorConfigNoDefaultLevelInNamedMessage()
        {
            config.GetChild("NamedMessages").GetChild(NAME1).RemoveAttribute("default_level");

            logger = new SimpleLogger(config);

            Assert.AreEqual(Level.INFO, logger.NamedMessages[NAME1].DefaultLevel,
                "incorrect default level of named message");
        }
        public void TestCtorConfigNoDefaultLevel()
        {
            config.RemoveAttribute("default_level");

            logger = new SimpleLogger(config);

            Assert.AreEqual(Level.DEBUG, logger.DefaultLevel, "incorrect default level");
        }
        public void TestCtorConfigAccuracy()
        {
            logger = new SimpleLogger(config);

            Assert.AreEqual(LOGNAME, logger.Logname, "incrrect log name");
            Assert.AreEqual(LEVEL, logger.DefaultLevel, "incorrect default level");
            Assert.AreEqual(msgs.Count, logger.NamedMessages.Count, "incorrect number of named messages");
            foreach (string s in new string[] {NAME1, NAME2})
            {
                Assert.AreEqual(msgs[s].Name, logger.NamedMessages[s].Name,
                    "incorrect name of named message");
                Assert.AreEqual(msgs[s].Text, logger.NamedMessages[s].Text,
                    "incorrect text of named message");
                Assert.AreEqual(msgs[s].ParameterNames.Count, logger.NamedMessages[s].ParameterNames.Count,
                    "incorrect number of parameters of named message");
                foreach (string name in msgs[s].ParameterNames)
                {
                    Assert.IsTrue(logger.NamedMessages[s].ParameterNames.Contains(name),
                        "incorrect parameter of named message");
                }
            }
        }