public async Task DeliverSimpleEmail_Test() { var sender = new EmailNotificationContact("*****@*****.**", "Joe Bloggs"); var content = new StringNotificationContent("Hi Joe,\nYou have a thing due on 20/4/2018."); var notification = new Notification(sender, content); var notificationDelivery = new EmailNotificationDelivery(DateTimeOffset.Now, 3); notificationDelivery.Recipients.Add(new EmailNotificationContact("*****@*****.**", "Mary Jones")); var emailServiceMock = new Mock <IEmailService>(); emailServiceMock .Setup(m => m.DeliverAsync(It.IsAny <EmailNotificationContact>(), It.IsAny <EmailNotificationContact[]>(), It.IsAny <EmailNotificationContact[]>(), It.IsAny <EmailNotificationContact[]>(), It.IsAny <Stream>(), It.IsAny <NotificationAttachment[]>())) .Returns(() => { return(Task.FromResult(new EmailDeliveryResult { NotificationDeliveryResult = NotificationDeliveryResult.Delivered, ResultMessage = "OK" })); }); var emailDeliveryService = new EmailDeliveryService(emailServiceMock.Object); var attempt = await emailDeliveryService.DeliverAsync(notification, notificationDelivery); }
static void Main(string[] args) { using (EmailDeliveryService eds = new EmailDeliveryService()) { Console.WriteLine("EmailDeliveryService!"); System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite); } Console.ReadKey(); }
static void Main(string[] args) { while (true) { Console.WriteLine("Welcome to our delivery service program."); Console.WriteLine("Please choose one of the following delivery options."); Console.WriteLine("1 - Console Delivery"); Console.WriteLine("2 - File Delivery"); Console.WriteLine("3 - Email Delivery"); Console.WriteLine("4 - SMS Delivery"); Console.WriteLine(); string choice = CLIHelper.GetString("Make a choice > "); IDeliveryService ds = null; switch (choice) { case "1": ds = new ConsoleDeliveryService(); break; case "2": ds = new FileDeliveryService(); break; case "3": ds = new EmailDeliveryService(); break; case "4": ds = new SMSDeliveryService(); break; } CLI cli = new CLI(ds); cli.Run(); string sendAgain = CLIHelper.GetString("Type Y to send another message >"); if (sendAgain != "Y") { return; } } }