public void JObjectSetPath_Test() { var path = new JObjectPath(x => x["field"]); var obj = JObject.FromObject(new { field = "name" }); path.Set(obj, new[] { "field" }, "other"); ((string)obj["field"]).Should().Be("other"); }
public void JObjectSetPath_PlainArray_Test() { var path = new JObjectPath(x => x["field"]["other"]); var obj = JObject.FromObject(new { field = new[] { "name" } }); path.Set(obj, new[] { "field" }, new[] { "name1" }); ((string)obj["field"][0]).Should().Be("name1"); }
public void JObjectSetPath_WithArray_Test() { var path = new JObjectPath(x => x["field"].ScanArr); var obj = JObject.FromObject(new { field = new[] { "name", "name1" } }); path.Set(obj, new object[] { "field", 1 }, "other"); ((string)obj["field"][0]).Should().Be("name"); ((string)obj["field"][1]).Should().Be("other"); }