public void TestContext() { var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); const string name = "testsection"; // ensure not present if (config.GetSection(name) != null) { config.Sections.Remove(name); } var section = new TestContextSection(); // Can't access EvaluationContext .... try { section.TestContext(null); Assert.Fail("#1"); } catch (ConfigurationException) { ; } // ... until it's been added to a section. config.Sections.Add(name, section); section.TestContext("#2"); // Remove ... config.Sections.Remove(name); // ... and it doesn't lose its context section.TestContext(null); }
public void TestContext () { var config = ConfigurationManager.OpenExeConfiguration (ConfigurationUserLevel.None); const string name = "testsection"; // ensure not present if (config.GetSection (name) != null) config.Sections.Remove (name); var section = new TestContextSection (); // Can't access EvaluationContext .... try { section.TestContext (null); Assert.Fail ("#1"); } catch (ConfigurationException) { ; } // ... until it's been added to a section. config.Sections.Add (name, section); section.TestContext ("#2"); // Remove ... config.Sections.Remove (name); // ... and it doesn't lose its context section.TestContext (null); }