public void CopyIsSerializedCorrectly() { JsonPatchDocument document = new JsonPatchDocument(); document.AppendCopy("/a/b/c", "/a/b/d"); Assert.AreEqual(document.ToString(), "[{\"op\":\"copy\",\"from\":\"/a/b/c\",\"path\":\"/a/b/d\"}]"); }
public void CanAppendOperationsToExistingEmptyArray() { JsonPatchDocument document = new JsonPatchDocument(Encoding.UTF8.GetBytes("[]")); document.AppendCopy("/a/b/c", "/a/b/d"); Assert.AreEqual(document.ToString(), "[{\"op\":\"copy\",\"from\":\"/a/b/c\",\"path\":\"/a/b/d\"}]"); }
public void MultipleOperationsSerializedInOrder() { JsonPatchDocument document = new JsonPatchDocument(); document.AppendTest("/a/b/c", "\"foo\""); document.AppendAdd("/a/b/c", "42"); document.AppendReplace("/a/b/c", "[ \"foo\", \"bar\" ]"); document.AppendRemove("/a/b/c"); document.AppendMove("/a/b/c", "/a/b/d"); document.AppendCopy("/a/b/c", "/a/b/d"); Assert.AreEqual(document.ToString(), "[" + "{\"op\":\"test\",\"path\":\"/a/b/c\",\"value\":\"foo\"}," + "{\"op\":\"add\",\"path\":\"/a/b/c\",\"value\":42}," + "{\"op\":\"replace\",\"path\":\"/a/b/c\",\"value\":[\"foo\",\"bar\"]}," + "{\"op\":\"remove\",\"path\":\"/a/b/c\"}," + "{\"op\":\"move\",\"from\":\"/a/b/c\",\"path\":\"/a/b/d\"}," + "{\"op\":\"copy\",\"from\":\"/a/b/c\",\"path\":\"/a/b/d\"}" + "]"); }