public void Email_filter_should_filter_addresses() { var emailSender = new DummyEmailSender(); var filterInterceptor = new FilterEmailInterceptor("*@saritasa.com; *@saritasa-hosting.com"); emailSender.AddInterceptor(filterInterceptor); var countEmailsInterceptor = new CountEmailsInterceptor(); emailSender.AddInterceptor(countEmailsInterceptor); emailSender.SendAsync(new MailMessage("*****@*****.**", "*****@*****.**")).Wait(); Assert.Equal(0, countEmailsInterceptor.SentCallCount); emailSender.SendAsync(new MailMessage("*****@*****.**", "*****@*****.**")).Wait(); Assert.Equal(1, countEmailsInterceptor.SentCallCount); emailSender.SendAsync(new MailMessage("*****@*****.**", "*****@*****.**")).Wait(); Assert.Equal(2, countEmailsInterceptor.SentCallCount); filterInterceptor.SetApprovedEmails("*"); emailSender.SendAsync(new MailMessage("*****@*****.**", "*****@*****.**")).Wait(); Assert.Equal(3, countEmailsInterceptor.SentCallCount); }
public void Test_that_interceptor_executes() { var emailSender = new DummyEmailSender(); var countEmailsInterceptor = new CountEmailsInterceptor(); emailSender.AddInterceptor(countEmailsInterceptor); emailSender.SendAsync(new MailMessage()).Wait(); emailSender.SendAsync(new MailMessage()).Wait(); emailSender.SendAsync(new MailMessage()).Wait(); Assert.Equal(3, countEmailsInterceptor.SendingCallCount); Assert.Equal(3, countEmailsInterceptor.SentCallCount); }