public void DefaultFormatter() { DefaultLogFormatter formatter = new DefaultLogFormatter(); Converts.Repository .Add(typeof(ExceptionModel), typeof(string), new ExceptionModelConverter()); string message; DateTime now = DateTime.Now; message = formatter.Format("Application", LogLevel.Debug, "M1"); Assert.AreEqual(String.Format("{0} Application(DEBUG){1}{1}M1{1}", now, Environment.NewLine), message); message = formatter.Format("Application", LogLevel.Info, new ExceptionModel("M2", Ensure.Exception.NotImplemented())); Assert.AreEqual(String.Format("{0} Application(INFO){1}{1}M2{1}System.NotImplementedException: The method or operation is not implemented.{1}{1}", now, Environment.NewLine), message); }
public async void Append(string scopeName, LogLevel level, object model) { // TODO: Add support for paralel processing. Last = logFormatter.Format(scopeName, level, model); await Task.Delay(3000); Last = null; }
public void MustReturnRawTextForLogMessage() { var sut = new DefaultLogFormatter(); var entry = new LogText("Must return this text..."); var text = sut.Format(entry); Assert.AreEqual(entry.Text, text); }
public void MustCorrectlyFormatLogMessage() { var sut = new DefaultLogFormatter(); var date = new DateTime(2017, 10, 10, 15, 24, 38); var threadInfo = new ThreadInfo(1234, "ABC"); var entry = new LogMessage(date, LogLevel.Warning, "Here's a warning message...", threadInfo); var text = sut.Format(entry); Assert.AreEqual($"2017-10-10 15:24:38.000 [1234: ABC] - WARNING: Here's a warning message...", text); }
public void ShouldFormatWithNullInput() { ILogFormatter formatter; DateTime dateTime; formatter = new DefaultLogFormatter(); dateTime = DateTime.Now; Assert.AreEqual($"{dateTime} | Debug | 1 | Undefined | Undefined | Undefined", formatter.Format(new Log(dateTime, 1, null, null, LogLevels.Debug, null))); }
public void ShouldFormatWithValidInput() { ILogFormatter formatter; DateTime dateTime; formatter = new DefaultLogFormatter(); dateTime = DateTime.Now; Assert.AreEqual($"{dateTime} | Debug | 1 | Component | Method | Message", formatter.Format(new Log(dateTime, 1, "Component", "Method", LogLevels.Debug, "Message"))); }
public void MustReportNotYetImplementedLogContent() { var sut = new DefaultLogFormatter(); sut.Format(new NewLogContentType()); }