public void SectionNameTest() { const string kExSectionName = "TestSection"; Config c = new Config(); c.SectionName = kExSectionName; Assert.AreEqual(kExSectionName, c.SectionName); }
public void SectionNameNullAssignTest() { Config c = new Config(); try { c.SectionName = null; } catch(ArgumentNullException) { return; } Assert.Fail(); }
public void AddSubsection(Config child_section) { childlen_.Add(child_section.SectionName, child_section); child_section.parent_section_ = this; }
public void SetGetValueTest() { const string kKey1 = "Key1"; const string kExValue1 = "Value1"; const string kKey2 = "Key2"; const string kExValue2 = "Value2"; const string kKey3 = "key3"; Config c = new Config(); c.Set(kKey1, kExValue1); c.Set(kKey2, kExValue2); string actValue; Assert.IsTrue(c.TryGetValue(kKey1, out actValue)); Assert.AreEqual(kExValue1, actValue); Assert.IsTrue(c.TryGetValue(kKey2, out actValue)); Assert.AreEqual(kExValue2, actValue); Assert.IsFalse(c.TryGetValue(kKey3, out actValue)); Assert.AreEqual(null, actValue); }
public void InstantiationWithSectionNameTest() { Config c = new Config("Section"); Assert.AreEqual("Section", c.SectionName); Assert.IsNull(c.Supersection); }
public void GetSubsectionTest() { Config c = new Config(); Config sc = c.GetSubsection("Undefined"); Assert.IsNull(sc); c.GetSubsection("subsection"); sc = c.GetSubsection("Undefined"); Assert.IsNull(sc); }
public void AddSubsectionTest() { Config c = new Config(); Config sc1 = new Config("Section1"); Config sc2 = new Config("Section2"); c.AddSubsection(sc1); c.AddSubsection(sc2); Config sc1r = c.GetSubsection("Section1"); Assert.AreEqual(sc1, sc1r); Assert.AreEqual(c, sc1r.Supersection); Config sc2r = c.GetSubsection("Section2"); Assert.AreEqual(sc2, sc2r); Assert.AreEqual(c, sc2r.Supersection); }
public void UpdateValueTest() { const string kKey1 = "Key1"; const string kExValue1 = "Value1"; const string kExValue2 = "Value2"; string actValue; Config c = new Config(); c.Set(kKey1, kExValue1); Assert.IsTrue(c.TryGetValue(kKey1, out actValue)); Assert.AreEqual(kExValue1, actValue); c.Set(kKey1, kExValue2); Assert.IsTrue(c.TryGetValue(kKey1, out actValue)); Assert.AreEqual(kExValue2, actValue); }