public void DefaultsTest() { string configXml = CreateConfig(null, null, null, null, null); TestjQueryConfigurationSection configSection = TestjQueryConfigurationSection.GetWebHttpBehavior3Section(configXml); WebHttpElement3 element = configSection.WebHttpElement3; Assert.AreEqual(true, element.AutomaticFormatSelectionEnabled); Assert.AreEqual(typeof(WebHttpBehavior3), element.BehaviorType); Assert.AreEqual(WebMessageBodyStyle.Bare, element.DefaultBodyStyle); Assert.AreEqual(WebMessageFormat.Xml, element.DefaultOutgoingResponseFormat); Assert.AreEqual(false, element.FaultExceptionEnabled); Assert.AreEqual(true, element.HelpEnabled); }
internal static TestjQueryConfigurationSection GetWebHttpBehavior3Section(string configXml) { string configPath = Path.GetTempFileName(); File.WriteAllText(configPath, configXml); ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap(); fileMap.ExeConfigFilename = configPath; Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); TestjQueryConfigurationSection connectionInfoSection = (TestjQueryConfigurationSection)config.GetSection("jQueryConfigurationSection"); File.Delete(configPath); return(connectionInfoSection); }
public void ValuesTest() { bool anyBool1 = AnyInstance.AnyBool; bool anyBool2 = !AnyInstance.AnyBool; bool anyBool3 = AnyInstance.AnyBool; WebMessageBodyStyle anyBodyStyle = WebMessageBodyStyle.Bare; WebMessageFormat anyMessageFormat = WebMessageFormat.Xml; string configXml = CreateConfig(anyBool1, anyBodyStyle, anyMessageFormat, anyBool2, anyBool3); TestjQueryConfigurationSection configSection = TestjQueryConfigurationSection.GetWebHttpBehavior3Section(configXml); WebHttpElement3 element = configSection.WebHttpElement3; Assert.AreEqual(typeof(WebHttpBehavior3), element.BehaviorType); Assert.AreEqual(anyBool1, element.AutomaticFormatSelectionEnabled); Assert.AreEqual(anyBodyStyle, element.DefaultBodyStyle); Assert.AreEqual(anyMessageFormat, element.DefaultOutgoingResponseFormat); Assert.AreEqual(anyBool2, element.FaultExceptionEnabled); Assert.AreEqual(anyBool3, element.HelpEnabled); }
public void InvalidConfigTest() { string configXml = CreateConfig(null, WebMessageBodyStyle.Bare, null, null, null).Replace("'Bare'", "'notAStyle'"); ExceptionTestHelper.ExpectException <ConfigurationException>(delegate { var b = TestjQueryConfigurationSection.GetWebHttpBehavior3Section(configXml).WebHttpElement3.DefaultBodyStyle; }); configXml = CreateConfig(null, null, WebMessageFormat.Xml, null, null).Replace("'Xml'", "'notAFormat'"); ExceptionTestHelper.ExpectException <ConfigurationException>(delegate { var f = TestjQueryConfigurationSection.GetWebHttpBehavior3Section(configXml).WebHttpElement3.DefaultOutgoingResponseFormat; }); }