Ejemplo n.º 1
0
        public void Send(BirthdayEmail emailMessage)
        {
            var configuration = new EmailServiceConfiguration
            {
                Credentials = _credentials,
                Port        = 587,
                Smtp        = "smtp.gmail.com",
                Ssl         = true
            };

            _emailSender.Send(configuration, _from.Value, emailMessage.Recipient.Value, emailMessage.Message.ToString());
        }
        public void VerifyGmailServiceCreation()
        {
            string          fromEmailAddress = "*****@*****.**";
            var             emailToGreet     = "*****@*****.**";
            BirthdayMessage message          = new BirthdayMessage(new Name("Foo", "Bar"));
            BirthdayEmail   email            = new BirthdayEmail(EmailAddress.Of(emailToGreet), message);
            var             credentials      = new Credentials("foo", "bar");

            Mock <IEmailSender> serviceSpy = new Mock <IEmailSender>();

            new GmailBirthdaySender(EmailAddress.Of(fromEmailAddress), credentials, serviceSpy.Object).Send(email);

            var expectedConfiguration = new EmailServiceConfiguration
            {
                Ssl         = true,
                Smtp        = "smtp.gmail.com",
                Port        = 587,
                Credentials = credentials
            };

            serviceSpy.Verify(sender => sender.Send(expectedConfiguration, fromEmailAddress, emailToGreet, "Happy birthday dear Foo Bar"));
        }