public void ConfigurationSection_Get_ValueTypeTest() { var testOptions = new TestableConfigurationSection <ComplexTestOptions>(new ComplexTestOptions()); Assert.IsInstanceOfType(testOptions.Get <int>("TestValueType"), typeof(int)); Assert.AreEqual(42, testOptions.Get <int>("TestValueType")); }
public void ConfigurationSection_GetTest() { var testOptions = new TestableConfigurationSection <ComplexTestOptions>(new ComplexTestOptions()); Assert.IsInstanceOfType(testOptions.Get <string>("TestProperty"), typeof(string)); Assert.IsInstanceOfType(testOptions.Get <SimpleTestOptions>("TestOptions"), typeof(SimpleTestOptions)); }
public void ConfigurationSection_Get_WithDefaultsTest() { var testOptions = new TestableConfigurationSection <ComplexTestOptions>(new ComplexTestOptions()); var resultString1 = testOptions.Get <string>("TestProperty"); var resultString2 = testOptions.Get <string>("TestProperty2", "applied default value"); Assert.IsInstanceOfType(resultString1, typeof(string)); Assert.AreEqual("default value", resultString1); Assert.IsInstanceOfType(resultString2, typeof(string)); Assert.AreEqual("applied default value", resultString2); }
public void ConfigurationSection_Get_UnknownPropertyTest() { var testOptions = new TestableConfigurationSection <ComplexTestOptions>(new ComplexTestOptions()); Assert.IsNull(testOptions.Get <string>("TestProperty2")); }