public void JsonObjectAddTest() { const string jsonStringToAdd = "{\"NewProperty\":1}"; var jsonObj = new JsonObject(JsonTest); var initialLength = jsonObj.Serialize().Length; var objToAdd = new JsonObject(jsonStringToAdd); Assert.IsFalse(jsonObj.AddAt(objToAdd, @"nonexisting"), "Can't add at unknown location"); Assert.IsTrue(jsonObj.AddAt(objToAdd, "$"), "Adding succeeded"); var serializedObj = jsonObj.Serialize(); Assert.IsTrue(serializedObj.Length > initialLength, "Length has changed"); Assert.IsTrue(serializedObj.Contains("NewProperty"), "Object contains new property"); Assert.AreEqual(initialLength + jsonStringToAdd.Length - 1, serializedObj.Length, "Size OK"); Debug.Print(jsonObj.Serialize()); }
public void JsonObjectAddArrayTest() { var jsonObj = new JsonObject(JsonTest2); Assert.AreEqual(" too", jsonObj.GetProperty("Test[1][1]"), "Too doesn't get trimmed if flag is off"); var objToAdd = new JsonObject("[ \"a\", 1 ]"); Assert.IsTrue(jsonObj.AddAt(objToAdd, "")); Assert.AreEqual("[\"a\",1]", jsonObj.GetProperty("_")); Assert.AreEqual("Integer", jsonObj.GetPropertyType("_[1]")); }