public void DisallowsDuplicateProperties() { var sentence = SectionFactory.CreateSection("foo", Grammar.DefaultDelimiters); var section = new IniSection(sentence, new IniFile(sentence, new IniSettings { DuplicatePropertyHandling = DuplicatePropertyHandling.Disallow })); section.AddProperty("bar", "baz"); section.AddProperty("bar", "qux"); }
public void KeepsLastDuplicateProperty() { var sentence = SectionFactory.CreateSection("foo", Grammar.DefaultDelimiters); var section = new IniSection(sentence, new IniFile(sentence, new IniSettings { DuplicatePropertyHandling = DuplicatePropertyHandling.KeepLast })); section.AddProperty("bar", "baz"); section.AddProperty("bar", "qux"); Assert.IsTrue(section.Properties.Count() == 1); Assert.AreEqual("qux", section["bar"].Value); }
public void AllowsDuplicateProperties() { var sentence = SectionFactory.CreateSection("foo", Grammar.DefaultDelimiters); var section = new IniSection(sentence, new IniFile(sentence, new IniSettings { DuplicatePropertyHandling = DuplicatePropertyHandling.Allow })); section.AddProperty("bar", "baz"); section.AddProperty("bar", "qux"); Assert.IsTrue(section.Properties.Count() == 2); Assert.IsTrue(section.Properties.Count(x => x.Name.Equals("bar", StringComparison.OrdinalIgnoreCase)) == 2); }
public void KeepsFirstDuplicateProperty() { var sentence = SectionFactory.CreateSection("foo", Grammar.DefaultDelimiters); var section = new IniSection(sentence, new IniFile(sentence, new IniSettings { DuplicatePropertyHandling = DuplicatePropertyHandling.KeepFirst })); section.AddProperty("bar", "baz"); section.AddProperty("bar", "qux"); Assert.IsTrue(section.Properties.Count() == 1); Assert.AreEqual("baz", section["bar"].Value); }
public void IniFile_Section_Modify_03() { var section = new IniSection("Test"); section.AddProperty("PN", "PV"); Assert.AreEqual(1, section.Properties.Count); Assert.AreEqual("PN", section.Properties[0].Name); Assert.AreEqual("PV", section.Properties[0].Value); }
public void WriteToFile() { IniConfig config = new IniConfig(); IniSection section = config.AddSection("TestSection"); section.Comments.AddRange(new string[] { "Test1", "Comment2" }); IniProperty property = section.AddProperty("name", "Test", new string[] { "Property1", "TestProperty" }, new string[] { "Test1", "Test2" }); string content = IniWriter.WriteToString(config); File.WriteAllText(@"D:\ini-config.txt", content); }