public void CanFindFile() { var project = new LocationExpandingFileRazorProject(new[] { new DefaultLocationExpander() }, null, ApplicationHelper.GetMailViewPath(), ".cshtml"); Assert.IsTrue(project.GetItemAsync("Test").Result.Exists); }
public void DoesntThrowOnMissingFile() { var project = new LocationExpandingFileRazorProject(new[] { new DefaultLocationExpander() }, null, ApplicationHelper.GetMailViewPath(), ".cshtml"); Assert.IsFalse(project.GetItemAsync("Missing").Result.Exists); }
public void CanSendMailByModel() { var mailTransportMock = new Mock <IMailTransport>(); var project = new LocationExpandingFileRazorProject(new[] { new DefaultLocationExpander() }, null, ApplicationHelper.GetMailViewPath(), ".cshtml"); var engine = new RazorLightEngineBuilder() .UseProject(project) .UseMemoryCachingProvider() .Build(); var mailService = new TestMailKitSmtpMailService(MailKitSmtpMailServiceTest.GetTestMailServiceOptions(), mailTransportMock.Object); var templateService = new RazorLightTemplatingService(engine, new MailTemplateOptions(), null); var service = new TemplatingMailService(mailService, templateService); var model = new Test(); var body = templateService.Parse(model); service.SendMail(model, GlobalTestSettings.SmtpRecipientMail, GlobalTestSettings.SmtpRecipientName); mailTransportMock.VerifySendMail(GlobalTestSettings.SmtpServer, GlobalTestSettings.SmtpPort, GlobalTestSettings.SmtpSenderName, GlobalTestSettings.SmtpSenderMail, GlobalTestSettings.SmtpRecipientName, GlobalTestSettings.SmtpRecipientMail, GlobalTestSettings.MailSubject, body); }
public void ThrowsOnMissingDirectory() { var unused = new LocationExpandingFileRazorProject(new[] { new DefaultLocationExpander() }, null, string.Empty, ".cshtml"); }
public void ThrowsOnMissingExpanders() { var unused = new LocationExpandingFileRazorProject(null, null, ApplicationHelper.GetMailViewPath(), ".cshtml"); }