public void TestApplyTextFormat() { LogEntry entry = new CustomLogEntry(); string actual = FormatEntry("{timestamp}: {title} - {message}", entry); string expected = entry.TimestampString + ": " + entry.Title + " - " + entry.Message; Assert.AreEqual(expected, actual); }
public void GetSetTimeStampString() { LogEntry entry = new CustomLogEntry(); string expected = DateTime.Parse("12/31/9999 11:59:59 PM", CultureInfo.InvariantCulture).ToString(); entry.Timestamp = DateTime.MaxValue; Assert.AreEqual(expected, entry.TimestampString); }
public void TestApplyTextFormat() { LogEntry entry = new CustomLogEntry(); string actual = FormatEntry("{timestamp}: {title} - {message}", entry); string expected = entry.TimestampString + ": " + entry.Title + " - " + entry.Message; Assert.AreEqual(expected, actual); }
public void TestCreation() { LogEntry entry = new CustomLogEntry(); Assert.AreEqual(entry.EventId, 1, "Not equal"); Assert.AreEqual(entry.Message, "Foo", "Not equal"); Assert.AreEqual(entry.Severity, TraceEventType.Error, "Not equal"); Assert.AreEqual(entry.Title, "FooTitle", "Not equal"); Assert.AreEqual(entry.TimestampString, entry.Timestamp.ToString(CultureInfo.CurrentCulture), "Not equal"); }
public void TestCreation() { LogEntry entry = new CustomLogEntry(); Assert.AreEqual(entry.EventId, 1, "Not equal"); Assert.AreEqual(entry.Message, "Foo", "Not equal"); Assert.AreEqual(entry.Severity, TraceEventType.Error, "Not equal"); Assert.AreEqual(entry.Title, "FooTitle", "Not equal"); Assert.AreEqual(entry.TimestampString, entry.Timestamp.ToString(CultureInfo.CurrentCulture), "Not equal"); }
public void TimeStampTokenUtcTime() { LogEntry entry = new CustomLogEntry(); entry.Timestamp = DateTime.MaxValue; ILogFormatter formatter = new TextFormatter("TimeStamp: {timestamp}"); string actual = formatter.Format(entry); string expected = string.Concat("TimeStamp: " + DateTime.MaxValue.ToString()); Assert.AreEqual(expected, actual); }
public void TestApplyTextXmlFormat() { LogEntry entry = new CustomLogEntry(); entry.Timestamp = DateTime.MaxValue; string template = "<Log><message>{message}</message><timestamp>{timestamp}</timestamp><title>{title}</title></Log>"; string actual = FormatEntry(template, entry); string expected = "<Log><message>Foo</message><timestamp>" + DateTime.Parse("12/31/9999 11:59:59 PM", CultureInfo.InvariantCulture).ToString() + "</timestamp><title>FooTitle</title></Log>"; Assert.AreEqual(expected, actual); }
public void TimeStampTokenUtcTime() { LogEntry entry = new CustomLogEntry(); entry.Timestamp = DateTime.MaxValue; ILogFormatter formatter = new TextFormatter("TimeStamp: {timestamp}"); string actual = formatter.Format(entry); string expected = string.Concat("TimeStamp: " + DateTime.MaxValue.ToString()); Assert.AreEqual(expected, actual); }
public void TestApplyTextXmlFormat() { LogEntry entry = new CustomLogEntry(); entry.Timestamp = DateTime.MaxValue; string template = "<Log><message>{message}</message><timestamp>{timestamp}</timestamp><title>{title}</title></Log>"; string actual = FormatEntry(template, entry); string expected = "<Log><message>Foo</message><timestamp>" + DateTime.Parse("12/31/9999 11:59:59 PM", CultureInfo.InvariantCulture).ToString() + "</timestamp><title>FooTitle</title></Log>"; Assert.AreEqual(expected, actual); }
public void TestFormat() { ILogFormatter formatter = new TextFormatter(); LogEntry entry = new CustomLogEntry(); string message = formatter.Format(entry); Assert.AreNotEqual(message, string.Empty, "Empty log"); Assert.AreNotEqual(message.IndexOf("Message: Foo"), 0, "Message not present"); Assert.AreNotEqual(message.IndexOf("EventId: 1"), 0, "EventId not present"); Assert.AreNotEqual(message.IndexOf("Severity: Error"), 0, "Severity not present"); Assert.AreNotEqual(message.IndexOf("Title:FooTitle"), 0, "Title not present"); Assert.AreNotEqual(message.IndexOf(string.Format("Timestamp: {0}", entry.TimestampString)), -1, "Timestamp not present"); Assert.AreNotEqual(message.IndexOf(string.Format("Message: {0}", entry.Message)), 0, "Message not present"); Assert.AreNotEqual(message.IndexOf(string.Format("EventId: {0}", entry.EventId)), 0, "EventId not present"); Assert.AreNotEqual(message.IndexOf(string.Format("Severity: {0}", entry.Severity)), 0, "Severity not present"); Assert.AreNotEqual(message.IndexOf(string.Format("Title: {0}", entry.Title)), 0, "Title not present"); }
public void TestFormat() { ILogFormatter formatter = new TextFormatter(); LogEntry entry = new CustomLogEntry(); string message = formatter.Format(entry); Assert.AreNotEqual(message, string.Empty, "Empty log"); Assert.AreNotEqual(message.IndexOf("Message: Foo"), 0, "Message not present"); Assert.AreNotEqual(message.IndexOf("EventId: 1"), 0, "EventId not present"); Assert.AreNotEqual(message.IndexOf("Severity: Error"), 0, "Severity not present"); Assert.AreNotEqual(message.IndexOf("Title:FooTitle"), 0, "Title not present"); Assert.AreNotEqual(message.IndexOf(string.Format("Timestamp: {0}", entry.TimestampString)), -1, "Timestamp not present"); Assert.AreNotEqual(message.IndexOf(string.Format("Message: {0}", entry.Message)), 0, "Message not present"); Assert.AreNotEqual(message.IndexOf(string.Format("EventId: {0}", entry.EventId)), 0, "EventId not present"); Assert.AreNotEqual(message.IndexOf(string.Format("Severity: {0}", entry.Severity)), 0, "Severity not present"); Assert.AreNotEqual(message.IndexOf(string.Format("Title: {0}", entry.Title)), 0, "Title not present"); }
public void TestGetSetProperties() { LogEntry entry = new CustomLogEntry(); string stringVal = "my test string"; int counter = 0; entry.EventId = counter; Assert.AreEqual(counter, entry.EventId); entry.EventId = -1234; Assert.AreEqual(-1234, entry.EventId); entry.Message = stringVal + counter; Assert.AreEqual(stringVal + counter, entry.Message); counter++; entry.Message = ""; Assert.AreEqual("", entry.Message); entry.Severity = TraceEventType.Warning; Assert.AreEqual(TraceEventType.Warning, entry.Severity); counter++; entry.Severity = TraceEventType.Information; Assert.AreEqual(TraceEventType.Information, entry.Severity); entry.Timestamp = DateTime.MinValue; Assert.AreEqual(DateTime.MinValue, entry.Timestamp); counter++; entry.Timestamp = DateTime.MaxValue; Assert.AreEqual(DateTime.MaxValue, entry.Timestamp); entry.Title = stringVal + counter; Assert.AreEqual(stringVal + counter, entry.Title); counter++; entry.Title = ""; Assert.AreEqual("", entry.Title); }
public void TestGetSetProperties() { LogEntry entry = new CustomLogEntry(); string stringVal = "my test string"; int counter = 0; entry.EventId = counter; Assert.AreEqual(counter, entry.EventId); entry.EventId = -1234; Assert.AreEqual(-1234, entry.EventId); entry.Message = stringVal + counter; Assert.AreEqual(stringVal + counter, entry.Message); counter++; entry.Message = ""; Assert.AreEqual("", entry.Message); entry.Severity = TraceEventType.Warning; Assert.AreEqual(TraceEventType.Warning, entry.Severity); counter++; entry.Severity = TraceEventType.Information; Assert.AreEqual(TraceEventType.Information, entry.Severity); entry.Timestamp = DateTime.MinValue; Assert.AreEqual(DateTime.MinValue, entry.Timestamp); counter++; entry.Timestamp = DateTime.MaxValue; Assert.AreEqual(DateTime.MaxValue, entry.Timestamp); entry.Title = stringVal + counter; Assert.AreEqual(stringVal + counter, entry.Title); counter++; entry.Title = ""; Assert.AreEqual("", entry.Title); }
public void ConfirmSeverityValuesCanBeReadAsStrings() { LogEntry entry = new CustomLogEntry(); Assert.AreEqual("Error", entry.LoggedSeverity); }
public void GetSetTimeStampString() { LogEntry entry = new CustomLogEntry(); string expected = DateTime.Parse("12/31/9999 11:59:59 PM", CultureInfo.InvariantCulture).ToString(); entry.Timestamp = DateTime.MaxValue; Assert.AreEqual(expected, entry.TimestampString); }
public void ConfirmSeverityValuesCanBeReadAsStrings() { LogEntry entry = new CustomLogEntry(); Assert.AreEqual("Error", entry.LoggedSeverity); }