public void TextDecorationWithFileName(string sinkId) { string id = sinkId + (Utility.IsWindows ? string.Empty : TestUtility.LINUX); MemoryLogger logger = new MemoryLogger(null); MockEventSource <string> mockEventSource = CreateEventsource <string>("InitialPositionUnspecified"); MockEventSink sink = CreateEventSink(id, logger); mockEventSource.Subscribe(sink); string data = "some text"; DateTime timestamp = DateTime.UtcNow; string filePath = Path.Combine(TestUtility.GetTestHome(), "test.log"); long position = 11; long lineNumber = 1; mockEventSource.MockLogEvent(data, timestamp, data, filePath, position, lineNumber); Assert.Equal($"{ComputerOrHostName}:::{Path.GetFileName(filePath)}:::{position}:::{data}", sink.Records[0]); }
public void TestObjectDecorationWithFileName(string sinkId) { string id = sinkId + (Utility.IsWindows ? string.Empty : TestUtility.LINUX); MemoryLogger logger = new MemoryLogger(null); MockEventSource <IDictionary <string, string> > mockEventSource = CreateEventsource <IDictionary <string, string> >("InitialPositionUnspecified"); MockEventSink sink = CreateEventSink(id, logger); mockEventSource.Subscribe(sink); string text = "some text"; Dictionary <string, string> data = new Dictionary <string, string>() { { "data", text } }; DateTime timestamp = DateTime.UtcNow; string filePath = Path.Combine(TestUtility.GetTestHome(), "test.log"); long position = 11; long lineNumber = 1; mockEventSource.MockLogEvent(data, timestamp, text, filePath, position, lineNumber); string result = sink.Records[0]; Assert.Equal($"{{\"data\":\"{text}\",\"ComputerName\":\"{ComputerOrHostName}\",\"FileName\":\"{Path.GetFileName(filePath)}\",\"Position\":\"{position}\"}}", result); }