public void Load_should_not_throw_ConfigurationErrorsException_when_section_is_not_found_and_shouldThrowExceptionIfSectionNotFound_is_false() { Bar bar = ConfigurationSectionDeserializer.Load <Bar>("Barx", shouldThrowExceptionIfSectionNotFound: false); Assert.IsNull(bar); }
public void Load_should_throw_ConfigurationErrorsException_when_section_contains_XML_error() { AssertExceptionThrown .OfType <ConfigurationErrorsException>() .WithMessageContaining("Error loading from the \"Foo2\" section of the .config file:" + " An error occurred creating the configuration section handler for Foo2: There is an error in XML document") .WhenExecuting(() => ConfigurationSectionDeserializer.Load <Bar>("Foo2")); }
public void Load_should_throw_ConfigurationErrorsException_when_section_type_does_not_exist() { AssertExceptionThrown .OfType <ConfigurationErrorsException>() .WithMessageContaining("Error loading from the \"Bar5\" section of the .config file:" + " \"SparkyTools.XmlConfig.Fx.UnitTests.TestClasses.Bark, SparkyTools.XmlConfig.Fx.UnitTests\" is not a recognized type name.") .WhenExecuting(() => ConfigurationSectionDeserializer.Load <Bar>("Bar5")); }
public void Load_should_throw_ConfigurationErrorsException_when_section_type_cannot_be_cast() { AssertExceptionThrown .OfType <ConfigurationErrorsException>() .WithMessageContaining("Error loading from the \"Bar4\" section of the .config file:" + " Unable to cast object of type 'SparkyTools.XmlConfig.Fx.UnitTests.TestClasses.Foo' to type 'SparkyTools.XmlConfig.Fx.UnitTests.TestClasses.Bar'.") .WhenExecuting(() => ConfigurationSectionDeserializer.Load <Bar>("Bar4")); }
public void Load_should_throw_ConfigurationErrorsException_when_section_type_attribute_is_missing() { AssertExceptionThrown .OfType <ConfigurationErrorsException>() .WithMessageContaining("Error loading from the \"Bar3\" section of the .config file:" + " The \"type\" attribute is not present.") .WhenExecuting(() => ConfigurationSectionDeserializer.Load <Bar>("Bar3")); }
public void Load_should_throw_ConfigurationErrorsException_when_section_is_not_found_and_shouldThrowExceptionIfSectionNotFound_is_true() { AssertExceptionThrown .OfType <ConfigurationErrorsException>() .WithMessage("Error loading from the \"Barx\" section of the .config file:" + " Section not found.") .WhenExecuting(() => ConfigurationSectionDeserializer.Load <Bar>("Barx", shouldThrowExceptionIfSectionNotFound: true)); }
public void Load_should_work_when_section_name_doesnt_match_type_name() { Bar bar = ConfigurationSectionDeserializer.Load <Bar>("Bar2"); AssertBarProperties(bar); }
public void Load_of_hierarchial_type_should_work() { Foo foo = ConfigurationSectionDeserializer.Load <Foo>("Foo"); AssertFooProperties(foo); }
public void Load_should_work() { Bar bar = ConfigurationSectionDeserializer.Load <Bar>("Bar"); AssertBarProperties(bar); }