Exemple #1
0
        static void Main(string[] args)
        {
            #region Initialization

            var config = new nk.logger.csv.LoggerConfig()
                         .SetReplacementValue(';')
                         .SetRelativePath("logs");
            var logger = new nk.logger.csv.Logger(config);

            #endregion Initialization

            #region Logging

            // inner exception should be logged
            var exception = new ArgumentNullException("arg-1", new Exception("args-2"));
            logger.Error(exception);

            // comma should not be logged
            logger.Info("sample info text,");

            // should not be logged
            logger.Error("");

            // should not be logged
            logger.Fatal(ex: null);

            #endregion Logging

            Console.WriteLine("Completed Test");
            Console.WriteLine("Check if the Excel file is created");
        }
Exemple #2
0
        /// <summary>
        /// Initiate an instance of Logger class.
        /// </summary>
        public CsvLogger()
        {
            var config = new nk.logger.csv.LoggerConfig();

            config.SetDateTimeFormat(Config.Logger.DateFormat)
            .SetFileName(Config.Logger.FileName)
            .SetRelativePath(Config.Logger.RelativePath)
            .SetReplacementValue(Config.Logger.ReplacementValue);

            csvLogger = new nk.logger.csv.Logger(config);
        }
Exemple #3
0
        public void TestConfigSetters()
        {
            var config = new nk.logger.csv.LoggerConfig();

            Assert.Throws <ArgumentNullException>(() => config.SetDateTimeFormat(null));
            Assert.Throws <ArgumentNullException>(() => config.SetDateTimeFormat(" "));

            Assert.Throws <ArgumentNullException>(() => config.SetFileName(null));
            Assert.Throws <ArgumentNullException>(() => config.SetFileName(" "));

            Assert.Throws <ArgumentNullException>(() => config.SetRelativePath(null));

            Assert.Throws <ArgumentNullException>(() => config.SetReplacementValue(' '));
        }
Exemple #4
0
        public void TestConfigGetters()
        {
            var config = new nk.logger.csv.LoggerConfig()
                         .SetReplacementValue(replacementValue)
                         .SetFileName(fileName)
                         .SetDateTimeFormat(dateFormat)
                         .SetRelativePath(relativePath);

            Assert.AreEqual(config.GetReplacementValue(), replacementValue);
            Assert.AreEqual(config.GetFileName(), fileName);
            Assert.AreEqual(config.GetDateTimeFormat(), dateFormat);
            Assert.AreEqual(config.GetRelativePath(), relativePath);

            Assert.Pass();
        }