public void Notify_Creates_Log_On_Failure()
        {
            // Arrange
            var logService = new Mock<ILogService>();
            var emailService = new Mock<IEmailService>();
            emailService.Setup(e => e.Send(It.IsAny<MailMessage>())).Throws(new SmtpException());
            var user = new Mock<User>();
            user.SetupProperty(u => u.Email, "[email protected]");
            var template = new Mock<INotificationTemplate>();
            template.Setup(t => t.Read()).Returns(new XElement("Email",
                new XElement("Subject"), new XElement("Body")));
            template.Setup(t => t.ContainingDirectory).Returns("");
            var templateObj = template.Object;

            var templateService = new Mock<ITemplateService>();
            templateService.Setup(t => t.ParseTemplate(It.IsAny<string>(),
                templateObj,
                It.IsAny<object>()))
                .Returns(new Dictionary<string, string>()
                    {
                        {"Subject", ""},
                        {"Body", ""}
                    });

            // Parent email template
            templateService.Setup(t => t.ParseTemplate(It.IsAny<string>(),
                It.Is<INotificationTemplate>(n => n != templateObj),
                It.IsAny<object>()))
                .Returns(new Dictionary<string, string>()
                    {
                        {"Message", ""}
                    });

            var service = new EmailNotificationService(logService.Object, emailService.Object,
                templateService.Object,
                "[email protected]", "Support");

            // Act
            service.Notify(user.Object, templateObj, null);

            // Assert
            logService.Verify(l => l.CreateLog(It.IsAny<Domain.Log>()), Times.Once());
        }
        static void Main(string[] args)
        {
            Console.WriteLine(@"
This a very simple demo of how the NonHttpRunTimeRazorSupport library 
might be used to send emails outside of the context of a running
web application.

This app is configured to drop .eml files in the C:\temp folder (see 
app.config). These files can be viewed in an email client, or on a
web site like http://www.encryptomatic.com/viewer/Default.aspx");
            var settings = new NotificationSettings(new Uri("http://www.facepack.com/"));
            var service = new EmailNotificationService(settings);
            do
            {
                var from = new MailAddress("[email protected]");
                var to = new MailAddress("[email protected]");
                var model = new WelcomeModel
                {
                    Name = "Dave"
                };
                service.Send(from, to, model);
                Console.WriteLine("Message sent. Press a key to resend, or q to exit");
            } while (Console.ReadKey().KeyChar != 'q');
        }