public void ShouldMatchEvaluate() { var element = new EnvironmentElement("development"); element.Name.Should().Eq("development"); element.AddMatchers("machineName", System.Environment.MachineName); element.AddMatchers("processorCount", System.Environment.ProcessorCount.ToString()); element.AddMatchers("userName", System.Environment.UserName); element.Evaluate().Should().Eq(true); }
public void ShouldNotMatchEvaluate() { var element = new EnvironmentElement("test"); element.Name.Should().Eq("test"); element.AddMatchers("machineName", "non-existent"); element.AddMatchers("processorCount", "3"); element.AddMatchers("userName", "none"); element.Evaluate().Should().Eq(false); }
/// <summary> /// Create a <see cref="Anairam.EnvironmentDetectorConfiguration"/> from config file. /// </summary> /// <param name="parent"></param> /// <param name="configContext"></param> /// <param name="section">XmlNode read from config file</param> /// <returns>A <see cref="Anairam.EnvironmentDetectorConfiguration"/> filled with config data.</returns> public object Create(object parent, object configContext, XmlNode section) { Default = section.Attributes["default"].Value; Environments = new List<EnvironmentElement>(); foreach (XmlNode node in section.SelectNodes("//environment")) { var env = new EnvironmentElement(node.Attributes["name"].Value); foreach (XmlNode children in node.ChildNodes) { if (children.NodeType == XmlNodeType.Comment) continue; env.AddMatchers(children.Name, children.Attributes["value"].Value); } Environments.Add(env); } return this; }
public void ShouldCreateWithName() { var element = new EnvironmentElement("development"); element.Name.Should().Eq("development"); }