public void AddRandomTypesElements() { var list = new PropertyList(); var root = list.Root; Assert.IsNotNull(root); root.Add("Counter", 1); root.Add("Date", DateTime.Now); var array = root.AddNewArray("Achievements"); Assert.IsNotNull(array); array.Add("A1"); array.Add("A2"); array.Add("A3"); array.Add("A4"); Assert.AreEqual(root.Count, 3, "First level should contain 3 elements"); Assert.AreEqual(array.Length, 4, "Array should contain 4 elements"); Assert.IsTrue(root.Contains("Achievements")); Assert.AreEqual(array[1].StringValue, "A2"); StringBuilder result = new StringBuilder(); list.Write(result); Debug.WriteLine(result.ToString()); }
public void AddBinaryData() { var propertyList = new PropertyList(); byte[] data = new byte[] { 20, 25, 35, 45, 60, 1, 0, 99 }; propertyList.Add("new_element", data); var text = propertyList.ToString(); Assert.IsNotNull(text); var loadedList = PropertyList.Read(text); var loadedData = loadedList["new_element"].BinaryValue; Assert.AreEqual(loadedData.Length, data.Length); for (int i = 0; i < data.Length; i++) { Assert.AreEqual(data[i], loadedData[i]); } }
public void CreateEmpty() { var list = new PropertyList(); }
public void ClearItems() { var data = new PropertyList(); data.Add("A", 1); data.Add("B", 2); data.Add("C", 3); data.Add("D", 4); data.Add("E", 5); data.Add("F", 6); Assert.AreEqual(6, data.Count); data.Clear(); Assert.AreEqual(0, data.Count); Assert.IsFalse(data.Contains("A")); Assert.IsFalse(data.Contains("B")); Assert.IsFalse(data.Contains("C")); Assert.IsFalse(data.Contains("D")); Assert.IsFalse(data.Contains("E")); Assert.IsFalse(data.Contains("F")); }
public void RemoveItemByKeyFromArray() { var data = new PropertyList(); var array = data.AddNewArray("Array"); Assert.IsNotNull(array); array.Add("item1"); array.Add("item2"); array.Add(1); array.Add(2); Assert.AreEqual(4, array.Count); var item = array.Remove("xyz"); Assert.IsNull(item); }
public void RemoveItemByIndexFromDictionary() { var data = new PropertyList(); data.Add("XXX", "here!"); Assert.AreEqual("here!", data["XXX"].StringValue); Assert.AreEqual(1, data.Count); data.RemoveAt(0); Assert.AreEqual(0, data.Count); Assert.IsFalse(data.Contains("XXX")); }
public void RemoveItemByKeyFromDictionary() { var data = new PropertyList(); data.Add("A", 1); Assert.AreEqual(1, data.Count); data.Remove("A"); Assert.AreEqual(0, data.Count); Assert.AreEqual(-1, data["A", -1].Int32Value); }
public void OverwriteItemsWithTheSameName() { var data = new PropertyList(); data.Add("A", 100.1); data.Add("B", 1); data.Add("A", true); Assert.AreEqual(2, data.Count); Assert.AreEqual(true, data["A"].BooleanValue); Assert.AreNotEqual(100.1, data["A"].DoubleValue); }