public void WriteLineTest() { var logFilename = Path.Combine(_logFileDirectory, "logtest.txt"); using (var sw = new StreamWriter(logFilename)) { var log = new Log(sw); log.WriteLine(LogEntryType.Info, "info log entry"); log.WriteLine(LogEntryType.Warning, "warning log entry"); log.WriteLine(LogEntryType.Error, "error log entry"); } var logFileContents = File.ReadAllLines(logFilename); /* Log entries look like this: 2013-01-26T02:00:26.3637578Z - INF - Hello, world! 2013-01-26T02:00:26.3793828Z - WRN - Hello, world! 2013-01-26T02:00:26.3793828Z - ERR - Hello, world! */ Assert.IsTrue(this.DoesMatchLogEntryFormat(logFileContents[0], "INF", "info log entry"), logFileContents[0]); Assert.IsTrue(this.DoesMatchLogEntryFormat(logFileContents[1], "WRN", "warning log entry"), logFileContents[1]); Assert.IsTrue(this.DoesMatchLogEntryFormat(logFileContents[2], "ERR", "error log entry"), logFileContents[2]); }