예제 #1
0
        public void AppendTest()
        {
            var myPath = $"{typeof(YamlLoggerTest).Namespace}.{nameof(AppendTest)}.yaml";

            try
            {
                var testedFileLogger = new YamlFileLogger(myPath);
                var expectedError1   = new Exception("test1");
                var expectedError2   = "test2";
                var expectedWarning  = "test3";
                var expectedinfo     = "test4";
                testedFileLogger.LogError(expectedError1);
                testedFileLogger.LogError(expectedError2);
                testedFileLogger.LogWarning(expectedWarning);
                testedFileLogger.LogInfo(expectedinfo);
                var received = File.ReadAllText(myPath);
                Assert.True(File.Exists(myPath));
                Assert.Contains(expectedError1.Message, received);
                Assert.Contains(expectedError2, received);
                Assert.Contains(expectedWarning, received);
                Assert.Contains(expectedinfo, received);
                Assert.Contains(MessageSeverity.Error.ToString(), received);
                Assert.Contains(MessageSeverity.Information.ToString(), received);
                Assert.Contains(MessageSeverity.Warning.ToString(), received);
            }
            finally
            {
                File.Delete(myPath);
            }
        }
예제 #2
0
        public void YamlCreate()
        {
            var myPath = $"{typeof(YamlLoggerTest).Namespace}.{nameof(YamlCreate)}.yaml";

            try
            {
                var tested = new YamlFileLogger();

                var testedFileLogger = new YamlFileLogger(myPath);
                testedFileLogger.LogInfo("test70113");
                Assert.True(File.Exists(myPath));
                Assert.Equal(".yaml", Path.GetExtension(testedFileLogger.OutputFile.Name));
            }
            finally
            {
                File.Delete(myPath);
            }
        }
예제 #3
0
        public void LogInfo()
        {
            var myPath = $"{typeof(YamlLoggerTest).Namespace}.{nameof(LogInfo)}.yaml";

            try
            {
                var testedFileLogger = new YamlFileLogger(myPath);
                var expected         = "test";
                testedFileLogger.LogInfo(expected);
                var received = File.ReadAllText(myPath);
                Assert.True(File.Exists(myPath));
                Assert.Contains(expected, received);
                Assert.Contains(MessageSeverity.Information.ToString(), received);
            }
            finally
            {
                File.Delete(myPath);
            }
        }