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); }
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); }
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"); }