Exemplo n.º 1
0
        public void TestThatInterceptorExecute()
        {
            EmailSender emailSender     = new Dummy.DummyEmailSender();
            var         testInterceptor = new TestInterceptor();

            emailSender.AddInterceptor(testInterceptor);

            emailSender.Send(new MailMessage()).Wait();
            emailSender.Send(new MailMessage()).Wait();
            emailSender.Send(new MailMessage()).Wait();

            Assert.Equal(3, testInterceptor.SendingCallCount);
            Assert.Equal(3, testInterceptor.SentCallCount);
        }
Exemplo n.º 2
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);
        }