Esempio n. 1
0
        public void SqlLogTest()
        {
            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }
            SqlLog.Debug("Test message", null);
            SqlLog.Debug("Test message with parameter {0}", new object[] { 1 });
            SqlLog.Debug(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
            SqlLog.Debug("Test message", new object[] { 1 });
            SqlLog.Debug("Test message {0}", null);
            SqlLog.Debug(new Exception("Some exeption"));
            SqlLog.Debug(null, new object[] { 1 });

            SqlLog.Info("Test message", null);
            SqlLog.Info("Test message with parameter {0}", new object[] { 1 });
            SqlLog.Info(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
            SqlLog.Info("Test message", new object[] { 1 });
            SqlLog.Info("Test message {0}", null);
            SqlLog.Info(new Exception("Some exeption"));
            SqlLog.Info(null, new object[] { 1 });

            SqlLog.Warning("Test message", null);
            SqlLog.Warning("Test message with parameter {0}", new object[] { 1 });
            SqlLog.Warning(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
            SqlLog.Warning("Test message", new object[] { 1 });
            SqlLog.Warning("Test message {0}", null);
            SqlLog.Warning(new Exception("Some exeption"));
            SqlLog.Warning(null, new object[] { 1 });

            SqlLog.Error("Test message", null);
            SqlLog.Error("Test message with parameter {0}", new object[] { 1 });
            SqlLog.Error(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
            SqlLog.Error("Test message", new object[] { 1 });
            SqlLog.Error("Test message {0}", null);
            SqlLog.Error(new Exception("Some exeption"));
            SqlLog.Error(null, new object[] { 1 });

            SqlLog.FatalError("Test message", null);
            SqlLog.FatalError("Test message with parameter {0}", new object[] { 1 });
            SqlLog.FatalError(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
            SqlLog.FatalError("Test message", new object[] { 1 });
            SqlLog.FatalError("Test message {0}", null);
            SqlLog.FatalError(new Exception("Some exeption"));
            SqlLog.FatalError(null, new object[] { 1 });

            Assert.IsTrue(File.Exists(filePath));
            Assert.AreEqual(File.ReadAllLines(filePath).Count(), 35);
        }