public void NodeBuilderAddsNodesWithoutConfigurationSourceAsReadWrite() { AppSettingsSection appSettingsSection = new AppSettingsSection(); appSettingsSection.Settings.Add("key", "value"); AppSettingsNodeBuilder builder = new AppSettingsNodeBuilder(ServiceProvider, appSettingsSection); AppSettingsNode appSettingsNode = builder.Build(); Assert.AreEqual(1, appSettingsNode.Nodes.Count); Assert.AreEqual(typeof(AppSettingNode), appSettingsNode.Nodes[0].GetType()); }
public void NodeBuilderAddsChildNodesForEverySettingInAppSettings() { AppSettingsSection appSettingsSection = new AppSettingsSection(); appSettingsSection.Settings.Add("key1", "value1"); appSettingsSection.Settings.Add("key2", "value2"); appSettingsSection.Settings.Add("key3", "value3"); AppSettingsNodeBuilder builder = new AppSettingsNodeBuilder(ServiceProvider, appSettingsSection); AppSettingsNode appSettingsNode = builder.Build(); Assert.AreEqual(3, appSettingsNode.Nodes.Count); }
public void SettingsFromConfigSectionAreAddedAsReadWriteNodes() { ExeConfigurationFileMap filemap = new ExeConfigurationFileMap(); filemap.ExeConfigFilename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AppSettingsWithConfigSource.config"); System.Configuration.Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(filemap, ConfigurationUserLevel.None); AppSettingsNodeBuilder builder = new AppSettingsNodeBuilder(ServiceProvider, configuration.GetSection("appSettings") as AppSettingsSection); AppSettingsNode appSettingsNode = builder.Build(); Assert.IsNotNull(appSettingsNode); Assert.AreEqual(1, appSettingsNode.Nodes.Count); Assert.AreEqual(typeof(AppSettingNode), appSettingsNode.Nodes[0].GetType()); }