Example #1
0
        public void Check_node_exists()
        {
            rootNode.AppendChild(doc.CreateElement("article"));

            dynamic config = new DynamicConfigSection(rootNode);
            Assert.IsNotNull(config.Article);
        }
Example #2
0
 public void Constcuts() 
 {                                  
     dynamic config = null;            
     Assert.DoesNotThrow(() => { 
         config = new DynamicConfigSection(rootNode);
     });
     Assert.IsNotNull(config);
 }
Example #3
0
        public void Throws_attribute_not_found_exception_when_no_matching_attribute_exists()
        {
            rootNode.AppendChild(doc.CreateElement("article"));

            dynamic config = new DynamicConfigSection(rootNode);
            Assert.Throws<AttributeNotFoundException>(() => {
                var attr = config.Article.title;
            });
        }
Example #4
0
 public void Does_not_throw_argument_not_found_exception_when_attribute_exists()
 {
     var articleNode = doc.CreateElement("article");
     articleNode.Attributes.Append(doc.CreateAttribute("title"));
     rootNode.AppendChild(articleNode);
     
     dynamic config = new DynamicConfigSection(rootNode);
     Assert.DoesNotThrow(() =>
     {
         var attr = config.Article.title;
     });
 }
 public DynamicConfiguration(string sectionName, Assembly configuringAssembly) 
 {
     config = ConfigurationManager.GetSection(sectionName) as DynamicConfigSection;
     config.SetAssemblyWithConfigTypes(configuringAssembly);
 }