public void BuildMailMessageSubject_SubjectFormatStringWithDateFormatItem_ReturnsDate() { string subjectFormatString = "{4}"; DateTime currentTime = new DateTime(2009, 11, 30, 18, 27, 12); var entryToFormat = new LogEntry(LoggingEventType.Debug, "Some message", null, null); // Act string subject = MailLoggingProvider.BuildMailMessageSubject(subjectFormatString, entryToFormat, currentTime); Assert.AreEqual("11/30/2009 18:27:12", subject); }
public void BuildMailMessageSubject_EntryWithLongMessage_TruncatesMessageAccordingly() { string subjectFormatString = "{1}"; string message = string.Join(",", Enumerable.Repeat("123456789_", 20).ToArray()); DateTime currentTime = new DateTime(2009, 11, 30, 18, 27, 12); var entryToFormat = new LogEntry(LoggingEventType.Debug, message, null, null); // Act string subject = MailLoggingProvider.BuildMailMessageSubject(subjectFormatString, entryToFormat, currentTime); Assert.IsFalse(subject.Contains(message)); Assert.IsTrue(subject.Contains(message.Substring(0, 100))); }
public void BuildMailMessageSubject_SubjectFormatStringWithSourceFormatItem_ReturnsSource() { // Arrange string subjectFormatString = "{2}"; var expectedSource = "Expected source"; var entry = new LogEntry(LoggingEventType.Debug, "Some message", expectedSource, null); // Act string subject = MailLoggingProvider.BuildMailMessageSubject(subjectFormatString, entry, DateTime.MaxValue); // Assert Assert.AreEqual(expectedSource, subject); }
public void BuildMailMessageSubject_SubjectFormatStringWithExeptionTypeFormatItem_ReturnsExceptionType() { // Arrange string subjectFormatString = "{3}"; var expectedException = new InvalidOperationException(); var entry = new LogEntry(LoggingEventType.Debug, "Some message", null, expectedException); // Act string subject = MailLoggingProvider.BuildMailMessageSubject(subjectFormatString, entry, DateTime.MaxValue); // Assert Assert.AreEqual(expectedException.GetType().Name, subject); }
public void BuildMailMessageSubject_SubjectFormatStringWithSeverityFormatItem_ReturnsSeverity() { // Arrange string subjectFormatString = "{0}"; var expectedSeverity = LoggingEventType.Critical; var entry = new LogEntry(expectedSeverity, "Some message", null, null); // Act string subject = MailLoggingProvider.BuildMailMessageSubject(subjectFormatString, entry, DateTime.MaxValue); // Assert Assert.AreEqual(expectedSeverity.ToString(), subject); }