コード例 #1
0
        public void BuildLogTest()
        {
            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }
            BuildLog.Debug("Test message", null);
            BuildLog.Debug("Test message with parameter {0}", new object[] { 1 });
            BuildLog.Debug(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
            BuildLog.Debug("Test message", new object[] { 1 });
            BuildLog.Debug("Test message {0}", null);
            BuildLog.Debug(new Exception("Some exeption"));
            BuildLog.Debug(null, new object[] { 1 });

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

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

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

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

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