private static RazorMailMessageFactory GetRazorMailMessageFactory() { var culture = new CultureInfo("en-US"); var templateResolver = new DefaultTemplateResolver("Infrastructure", "TemplateMailMessages"); var translations = new List<Translation> { new Translation("KindRegards", "Kind regards", culture), new Translation("DearSirOrMadam", "Dear sir or madam", culture), new Translation("ResetPasswordMailMessage", "ResetPasswordMailMessage", culture), new Translation("ResetPassword", "Reset password", culture) }; var translationService = new TranslationService(translations, culture); var applicationSettingsMock = new Mock<IApplicationSettings>(); applicationSettingsMock.Setup(x => x.DefaultCulture).Returns(culture); Func<Type, Object> dependencyResolver = t => { if (t == typeof (ITranslationService)) { return translationService; } if (t == typeof (IApplicationSettings)) { return applicationSettingsMock.Object; } return null; }; var factory = new RazorMailMessageFactory(templateResolver, typeof (ViewBaseClass<>), dependencyResolver); return factory; }
public void CanResolveTemplateWithSpecificAssemblyNameAndSpecificNameSpace() { var templateResolver = new DefaultTemplateResolver("RazorMailMessage.Tests", "TestTemplates"); var template = templateResolver.ResolveTemplate("TestTemplate.cshtml", false); var textTemplate = templateResolver.ResolveTemplate("TestTemplate.cshtml", true); var layout = templateResolver.ResolveLayout("TestLayout.cshtml"); Assert.AreEqual("<b>This is a test</b>", template); Assert.AreEqual("This is a test", textTemplate); Assert.AreEqual("Start layout @RenderBody End layout", layout); }
public void CanResolveTemplateWithDefaultAssemblyAndDefaultNameSpace() { var templateResolver = new DefaultTemplateResolver(); var template = templateResolver.ResolveTemplate("TestTemplates.TestTemplate.cshtml", false); var textTemplate = templateResolver.ResolveTemplate("TestTemplates.TestTemplate.cshtml", true); var layout = templateResolver.ResolveLayout("TestTemplates.TestLayout.cshtml"); Assert.AreEqual("<b>This is a test</b>", template); Assert.AreEqual("This is a test", textTemplate); Assert.AreEqual("Start layout @RenderBody End layout", layout); }