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); } }
public void LogWarning() { var myPath = $"{typeof(YamlLoggerTest).Namespace}.{nameof(LogWarning)}.yaml"; try { var testedFileLogger = new YamlFileLogger(myPath); var expected = "test"; testedFileLogger.LogWarning(expected); var received = File.ReadAllText(myPath); Assert.True(File.Exists(myPath)); Assert.Contains(expected, received); Assert.Contains(MessageSeverity.Warning.ToString(), received); } finally { File.Delete(myPath); } }