public void UsingExtendedFilters()
 {
     var email = new Email
     {
         Sender = "*****@*****.**",
         Content = "I really like this campany !",
         Attachments = new[] { "apple.png" }
     };
     var blocker = new SpamBlocker();
     blocker.AddSpamHandler(new AttachmentHandler());
     Assert.AreEqual(true, blocker.ShouldBlock(email));
 }
        public void UsingBaseFilters()
        {
            var email = new Email
                            {
                                Sender = "*****@*****.**",
                                Content = "I really like this campany !",
                                Attachments = new[] { "apple.png" }
                            };
            var blocker = new SpamBlocker();
            Assert.AreEqual(false, blocker.ShouldBlock(email));

            email.Sender = "*****@*****.**";
            Assert.AreEqual(true, blocker.ShouldBlock(email));
        }
Exemplo n.º 3
0
 /// <summary>
 /// The chain of responsibility is used here.
 /// </summary>
 public bool ShouldBlock(Email email)
 {
     return _handlers.Any(handler => handler.ShouldBlock(email));
 }
Exemplo n.º 4
0
 public bool ShouldBlock(Email email)
 {
     return email.Attachments.Any(attachment => attachment.Contains("apple.png"));
 }
 public bool ShouldBlock(Email email)
 {
     return(email.Attachments.Any(attachment => attachment.Contains("apple.png")));
 }