コード例 #1
0
        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);
        }
コード例 #2
0
    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.");
    }
コード例 #3
0
 public void Send(Email email)
 {
     // ... sending...
     logger.Log(email);
 }