public void RespectsRazorLightEmbeddedConfig() { var services = new ServiceCollection(); var builder = new ConfigurationBuilder() .AddInMemoryCollection(new[] { new KeyValuePair <string, string>("MailServiceOptions:SmtpServer", "smtp.test.com"), new KeyValuePair <string, string>("MailServiceOptions:FromMail", "*****@*****.**"), new KeyValuePair <string, string>("MailServiceOptions:FromName", "Mail"), new KeyValuePair <string, string>("MailServerCertificateValidationOptions:Validate", "false"), new KeyValuePair <string, string>("MailTemplateOptions:TemplateSource", "Embedded"), new KeyValuePair <string, string>("MailTemplateOptions:DefaultNamespace", "MailViewsEmbedded"), new KeyValuePair <string, string>("MailTemplateOptions:BaseDirectory", "MailViews"), new KeyValuePair <string, string>("MailTemplateOptions:Extension", ".cshtml") }); var config = builder.Build(); var manager = new ConsoleReportingConfigurationManager(config); var environment = new TestHostingEnvironment { ContentRootPath = ApplicationHelper.GetApplicationCodebase() }; services.AddLogging(); services.ConfigureMailServiceTemplated(environment, manager, typeof(GlobalTestSettings)); var s = services.BuildServiceProvider().GetRequiredService <RazorLightProject>(); Assert.IsTrue(s is EmbeddedRazorProject); Assert.IsTrue(s.GetItemAsync("Test").Result.Exists); }
public void AddsRazorLight() { var services = new ServiceCollection(); var builder = new ConfigurationBuilder() .AddInMemoryCollection(new[] { new KeyValuePair <string, string>("MailServiceOptions:SmtpServer", "smtp.test.com"), new KeyValuePair <string, string>("MailServiceOptions:FromMail", "*****@*****.**"), new KeyValuePair <string, string>("MailServiceOptions:FromName", "Mail"), new KeyValuePair <string, string>("MailServerCertificateValidationOptions:Validate", "false"), new KeyValuePair <string, string>("MailTemplateOptions:BaseDirectory", "MailViews"), new KeyValuePair <string, string>("MailTemplateOptions:Extension", ".cshtml") }); var config = builder.Build(); var manager = new ConsoleReportingConfigurationManager(config); var environment = new TestHostingEnvironment { ContentRootPath = ApplicationHelper.GetApplicationCodebase() }; services.AddLogging(); services.ConfigureMailServiceTemplated(environment, manager); var s = services.BuildServiceProvider().GetRequiredService <ITemplatingMailService>(); Assert.IsNotNull(s); }