public void PermittedDomainTargets(string target, string[] allowedDomains)
        {
            var mailHelper = new MailConstraints(allowedDomains);
            var recipients = MailHelper.CreateAddressCollection(target);

            mailHelper.ValidateEmailAddresses(recipients);
        }
        public void ProhobitedDomainTargets(string targets, string[] allowedDomains)
        {
            var mailHelper = new MailConstraints(allowedDomains);
            var recipients = MailHelper.CreateAddressCollection(targets);

            Assert.Throws <ProhibitedEmailRecipientException>(() => { mailHelper.ValidateEmailAddresses(recipients); });
        }
        public void MultipleDomainErrorMessage(string targets, string[] allowedDomains)
        {
            string message    = null;
            var    mailHelper = new MailConstraints(allowedDomains);

            try
            {
                var recipients = MailHelper.CreateAddressCollection(targets);
                mailHelper.ValidateEmailAddresses(recipients);
            }
            catch (ProhibitedEmailRecipientException e)
            {
                message = e.Message;
            }

            Assert.Equal("You may only send emails to email addresses addressed to users matching @mailinator.com, or @contoso.com", message);
        }
 public void ValidateAddresses(MailConstraints constraints)
 {
     constraints.ValidateEmailAddresses(this.Addresses);
 }