public void info_by_object() { var l1 = new RecordingLogListener { IsInfoEnabled = false, IsDebugEnabled = true }; var l2 = new RecordingLogListener { IsDebugEnabled = false, IsInfoEnabled = true }; var l3 = new RecordingLogListener { IsInfoEnabled = true }; l1.ListensForTypes[typeof(Trace1)] = true; l2.ListensForTypes[typeof(Trace1)] = true; l3.ListensForTypes[typeof(Trace2)] = true; var logger = new Logger(SystemTime.Default(), new ILogListener[] { l1, l2, l3 }); var msg1 = new Trace1(); var msg2 = new Trace1(); logger.InfoMessage(msg1); logger.InfoMessage(() => msg2); l1.InfoMessages.Any().ShouldBeFalse(); // debugging is not enabled l2.InfoMessages.ShouldHaveTheSameElementsAs(msg1, msg2); l3.InfoMessages.Any().ShouldBeFalse(); // does not listen to Trace1 }
public void info_by_message_puts_a_time_stamp_on_it_2() { var l1 = new RecordingLogListener { IsInfoEnabled = true }; var l2 = new RecordingLogListener { IsInfoEnabled = false, IsDebugEnabled = true }; var l3 = new RecordingLogListener { IsInfoEnabled = true }; l1.ListensForTypes[typeof(StringMessage)] = true; l2.ListensForTypes[typeof(StringMessage)] = true; l3.ListensForTypes[typeof(StringMessage)] = true; var systemTime = SystemTime.AtLocalTime(DateTime.Today.AddHours(8)); var logger = new Logger(systemTime, new ILogListener[] { l1, l2, l3 }); var message = new StringMessage("something"); logger.InfoMessage(message); message.Time.ShouldEqual(systemTime.UtcNow()); }