public void ItHasMailTemplatesWritableProperty() { var expected = new MailTemplateConfig[1]; _config.MailTemplates = expected; Assert.Equal(expected, _config.MailTemplates); }
/// <summary> /// Load email templates and bind to a list. /// </summary> /// <param name="systemEmail"></param> /// <param name="config"></param> public virtual void LoadEmail(string systemEmail, MailTemplateConfig config) { // Configuration is not valid. if (config == null) { return; } // Path hasn't been specified. var pathInfo = config.Path; if (pathInfo == null) { return; } var absoluteUrl = pathInfo.Url; if (!pathInfo.IsAbsolute) { absoluteUrl = HttpContext.Current.Server.MapPath(absoluteUrl); } // File doesn't exist. if (string.IsNullOrEmpty(absoluteUrl) || !File.Exists(absoluteUrl)) { return; } // Key already defined. if (MailTemplates.ContainsKey(systemEmail)) { return; } // Read all text in absolute path. try { var info = File.ReadAllText(absoluteUrl); // Initiate mail template. var mailTemplate = new MailTemplate(); mailTemplate.Subject = config.Subject; mailTemplate.Content = info; mailTemplate.IsHtml = config.IsHtml; // Add to mail templates collection. MailTemplates.Add(systemEmail, mailTemplate); } catch { // Suppress error. } }
public void GivenFileMailTemplateThenTemplateOptionSeted() { MailTemplateConfig fileTemplate = new MailTemplateConfig() { Name = "file", IsBodyHtml = true, Path = "path" }; _configuration.Template.MailTemplates = new[] { fileTemplate }; var result = _converter.Convert(_configuration); Assert.True(result.Template.GetPrototype("file").IsBodyHtml); Assert.NotNull(result.Template.GetPrototype("file")); }
public void GivenMailTemplateThenTemplateOptionSeted() { MailTemplateConfig template = new MailTemplateConfig() { Name = "template", IsBodyHtml = true, Subject = "subject", Body = "body" }; _configuration.Template.MailTemplates = new[] { template }; var result = _converter.Convert(_configuration); Assert.True(result.Template.GetPrototype("template").IsBodyHtml); Assert.Equal("body", result.Template.GetPrototype("template").Body); Assert.Equal("subject", result.Template.GetPrototype("template").Subject); }
public void ItExistst() { MailTemplateConfig template = new MailTemplateConfig(); }