public void Given_an_email_formatter_after_compiling_templates_for_workorder_reports_model_it_should_be_able_to_format_an_email_using_that_model() { _emailTemplateInitializer.CompileTemplatesForTypesInSameNamespaceAs <SimpleEmailModel>(); using (new LanguageScope("en-AU")) { var email = _emailFormatter.BuildTemplatedEmailFrom( new SimpleEmailModel { RecipientFirstName = "Michael", ReferenceNumber = "REF123456", Message = "Hello World!", Url = "http://google.com" }); email.Should().NotBeNull(); email.Subject.Should().NotBeBlank(); email.PlainTextBody.Should().NotBeBlank(); email.HtmlBody.Should().NotBeBlank(); } }
public static IEmailFormatter AnInitializedEmailFormatter() { if (initializedEmailFormatter == null) { var templateService = new TemplateService(); var embeddedEmailResourceProvider = new EmbeddedEmailResourceProvider( typeof(SimpleEmailModel).Assembly, "Email.RazorTemplates", "Email.Images", "en-AU"); var emailTemplateInitializer = new RazorEmailTemplateInitializer(embeddedEmailResourceProvider, templateService); emailTemplateInitializer.CompileTemplatesForTypesInSameNamespaceAs <SimpleEmailModel>(); initializedEmailFormatter = new RazorEmailFormatter(templateService, emailTemplateInitializer); } return(initializedEmailFormatter); }
public static IEmailFormatter AnInitializedEmailFormatter() { if (initializedEmailFormatter == null) { var templateService = new TemplateService(); var embeddedEmailResourceProvider = new EmbeddedEmailResourceProvider( typeof(SimpleEmailModel).Assembly, "Email.RazorTemplates", "Email.Images", "en-AU"); var emailTemplateInitializer = new RazorEmailTemplateInitializer(embeddedEmailResourceProvider, templateService); emailTemplateInitializer.CompileTemplatesForTypesInSameNamespaceAs<SimpleEmailModel>(); initializedEmailFormatter = new RazorEmailFormatter(templateService, emailTemplateInitializer); } return initializedEmailFormatter; }