示例#1
0
        public async Task Send_email_should_not_throw_any_exceptions()
        {
            //Arrange
            var emailService = new EmailService();

            var email = new MailMessage()
            {
                From = new MailAddress("*****@*****.**","Miam admin"),
                To = { new MailAddress("*****@*****.**","Linda Champagne") },
                Subject = "Le sujet",
                Body = "Le message"

            };

            //Action
            await emailService.SendMessage(email);
        }
示例#2
0
        public void Send_email_without_from_address_should_throw_an_exception()
        {
            //Arrange
            var emailService = new EmailService();

            var email = new MailMessage()
            {
                From = new MailAddress("", "Miam admin"),
                To = { new MailAddress("*****@*****.**", "Linda Champagne") },
                Subject = "Le sujet",
                Body = "Le message"

            };

            //Action
            var asyncEmail = emailService.SendMessage(email);

        }
示例#3
0
        public virtual async Task<ActionResult> SendConfirmed()
        {
            //Todo: La classe ne devrait pas dépendre du service de EmailService, mais d'une interface injectée au constructeur.

            var emailService = new EmailService();

            var email = new MailMessage()
            {
                From = new MailAddress("*****@*****.**", "Miam admin"),
                To = { new MailAddress("*****@*****.**", "Linda Champagne") },
                Subject = "Le sujet",
                Body = "Le message"

            };

            //Todo: Gérer les exceptions et envoyer un message à l'utlisateur si erreur lors de l'envoi.

             await emailService.SendMessage(email);

            //Todo: une confirmation que le message a été envoyé devrait être ajouté

            return RedirectToAction("Send");
        }