Ejemplo n.º 1
0
        public void TestFilterEmailInterceptor()
        {
            EmailSender emailSender       = new Dummy.DummyEmailSender();
            var         filterInterceptor = new FilterEmailInterceptor();

            filterInterceptor.AddApprovedEmails("*@saritasa.com");
            emailSender.AddInterceptor(filterInterceptor);
            var testInterceptor = new TestInterceptor();

            emailSender.AddInterceptor(testInterceptor);

            emailSender.Send(new MailMessage("*****@*****.**", "*****@*****.**")).Wait();
            Assert.Equal(0, testInterceptor.SentCallCount);

            emailSender.Send(new MailMessage("*****@*****.**", "*****@*****.**")).Wait();
            Assert.Equal(1, testInterceptor.SentCallCount);
        }
Ejemplo n.º 2
0
        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);
        }