public void SendsMailWithLogs() { var mail = new FakeEmailSender(); var sut = new EmailLogger(mail); sut.Log(ErrorLevel.Debug, "AAAA"); sut.Log(ErrorLevel.Info, "BBBB"); sut.Log(ErrorLevel.Error, "CCCC"); sut.ExecuteOnExit(true); Assert.NotNull(mail.LastSubject); Assert.NotNull(mail.LastBody); Assert.DoesNotContain("AAAA", mail.LastBody); Assert.Contains("BBBB", mail.LastBody); Assert.Contains("CCCC", mail.LastBody); }
static void Main(string[] args) { FileLogger fileLogger = new FileLogger(); fileLogger.Log("Message to Log in File."); WriteLine(); EmailLogger emailLogger = new EmailLogger(); emailLogger.Log("Message to Log via Email."); WriteLine(); DatabaseLogger databaseLogger = new DatabaseLogger(); databaseLogger.Log("Message to Log in DB."); }
public void Send(Email email) { // ... sending... logger.Log(email); }