private Dictionary <string, SmtpNotificationChannelDefinition> CreateNotificationChannelDefinitions(XmlNode document) { Dictionary <string, SmtpNotificationChannelDefinition> definitions = new Dictionary <string, SmtpNotificationChannelDefinition>(); IEnumerable <XmlElement> auditNodes = document.SelectNodes("//audit")?.OfType <XmlElement>(); if (auditNodes == null) { return(definitions); } foreach (XmlElement node in auditNodes) { string key = this.GetNotificationChannelKey(node); if (key == null) { continue; } if (!definitions.ContainsKey(key)) { SmtpNotificationChannelDefinition definition = this.CreateNotificationChannelDefinition(node); definitions.Add(key, definition); } } return(definitions); }
public void SerializeSmtpNotificationChannelDefinition() { SmtpNotificationChannelDefinition s = new SmtpNotificationChannelDefinition(); s.DisplayName = TestContext.CurrentContext.Random.GetString(); s.Enabled = true; s.Mandatory = true; s.Id = TestContext.CurrentContext.Random.GetString(); s.TemplateFailure = TestContext.CurrentContext.Random.GetString(); s.TemplateSuccess = TestContext.CurrentContext.Random.GetString(); s.EmailAddresses.Add(TestContext.CurrentContext.Random.GetString()); SmtpNotificationChannelDefinition n = JsonConvert.DeserializeObject <SmtpNotificationChannelDefinition>(JsonConvert.SerializeObject(s)); Assert.AreEqual(s.DisplayName, n.DisplayName); Assert.AreEqual(s.Enabled, n.Enabled); Assert.AreEqual(s.Mandatory, n.Mandatory); Assert.AreEqual(s.Id, n.Id); Assert.AreEqual(s.TemplateFailure, n.TemplateFailure); Assert.AreEqual(s.TemplateSuccess, n.TemplateSuccess); CollectionAssert.AreEqual(s.EmailAddresses, n.EmailAddresses); }
private SmtpNotificationChannelDefinition CreateNotificationChannelDefinition(XmlNode node) { string addresses = node.SelectSingleNode("@emailAddresses")?.Value; string displayName = $"Send email to {addresses}"; SmtpNotificationChannelDefinition channel = new SmtpNotificationChannelDefinition { DisplayName = displayName, Enabled = true, Mandatory = false, EmailAddresses = addresses?.Split(',', ';', StringSplitOptions.RemoveEmptyEntries)?.ToList() ?? new List <string>(), TemplateSuccess = settings.SuccessTemplate, TemplateFailure = settings.FailureTemplate }; if (channel.EmailAddresses.Count > 0) { return(channel); } return(null); }