public void SyslogLogger_TwoLoggers_WillNotInterefereWithEachOther() { var watcher = new SyslogWatcher(FakeAppName, SyslogFileToWatch); var logger1 = new SyslogLogger(FakeAppName + "1"); var logger2 = new SyslogLogger(FakeAppName + "2"); watcher.StartWatching(); string[] messages = { "First log message", "Second log message", "Third log message", "Fourth log message", "Fifth log message" }; foreach (string s in messages) { logger1.Error(s); logger2.Error(s); } string[] data = watcher.WaitForData(10).ToArray(); watcher.StopWatching(); for (int i = 0; i < messages.Length; i++) { // Expect messages perfectly interleaved, logger1 followed by logger2 all five times string expectedAppName = FakeAppName + (i % 2 == 0 ? "1" : "2"); Assert.That(data[i], Is.StringContaining(expectedAppName)); Assert.That(data[i], Is.StringContaining(messages[i / 2])); } }
public void SyslogLogger_TwoLoggers_WillNotInterefereWithEachOther() { var watcher = new SyslogWatcher(FakeAppName, SyslogFileToWatch); var logger1 = new SyslogLogger(FakeAppName + "1"); var logger2 = new SyslogLogger(FakeAppName + "2"); watcher.StartWatching(); string[] messages = { "First log message", "Second log message", "Third log message", "Fourth log message", "Fifth log message" }; foreach (string s in messages) { logger1.Error(s); logger2.Error(s); } string[] data = watcher.WaitForData(10).ToArray(); watcher.StopWatching(); for (int i = 0; i < messages.Length; i++) { // Expect messages perfectly interleaved, logger1 followed by logger2 all five times string expectedAppName = FakeAppName + (i % 2 == 0 ? "1" : "2"); Assert.That(data[i], Is.StringContaining(expectedAppName)); Assert.That(data[i], Is.StringContaining(messages[i / 2])); } }
public void SyslogLogger_WritesOneLine() { var watcher = new SyslogWatcher(FakeAppName, SyslogFileToWatch); var logger = new SyslogLogger(FakeAppName); watcher.StartWatching(); logger.Error("This string should be in the results"); IEnumerable<string> data = watcher.WaitForData(); watcher.StopWatching(); Assert.That(data, Has.Some.StringContaining("This string should be in the results")); }
public void SyslogLogger_WritesOneLine() { var watcher = new SyslogWatcher(FakeAppName, SyslogFileToWatch); var logger = new SyslogLogger(FakeAppName); watcher.StartWatching(); logger.Error("This string should be in the results"); IEnumerable <string> data = watcher.WaitForData(); watcher.StopWatching(); Assert.That(data, Has.Some.StringContaining("This string should be in the results")); }