public void Real_validator_checks_for_whitespace_and_at()
        {
            MailingLogic.IsValidEmailAddress(null).Should().BeFalse();
            MailingLogic.IsValidEmailAddress(String.Empty).Should().BeFalse();
            MailingLogic.IsValidEmailAddress("\t\r\n").Should().BeFalse();
            MailingLogic.IsValidEmailAddress("This has no at sign, is not email").Should().BeFalse();

            MailingLogic.IsValidEmailAddress("@").Should().BeTrue();
        }
        public void We_can_read_email_addresses_as_lines_from_stream()
        {
            var contents =
                @"[email protected]
[email protected]";

            using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(contents)))
            {
                MailingLogic.LineBasedEmailAddresses(ms).ShouldBeEquivalentTo(new string[] { "*****@*****.**", "*****@*****.**" });
            }
        }
        public void Target_not_called_for_invalid_addresses()
        {
            var emailAddresses = new string[] { "*****@*****.**", "rubbish" };
            int count          = 0;

            MailingLogic.Process(emailAddresses,
                                 (em) => { return(em != "rubbish"); },
                                 em => em,
                                 (em, cnt) => { count++; });

            count.Should().Be(1);
        }
        public void Target_called_for_valid_addresses()
        {
            var emailAddresses = new string[] { "*****@*****.**", "*****@*****.**" };
            int count          = 0;

            MailingLogic.Process(emailAddresses,
                                 (em) => true,
                                 em => em,
                                 (em, cnt) => { count++; });

            count.Should().Be(2);
        }
        public void Putting_it_together()
        {
            var contents =
                @"bla bla 

[email protected]
[email protected]


oops new lines there";

            using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(contents)))
            {
                MailingLogic.Process(MailingLogic.LineBasedEmailAddresses(ms),
                                     MailingLogic.IsValidEmailAddress,
                                     MailingLogic.GetContentFor,
                                     MailingLogic.SendItReally);
            }
        }