public void TestIsSerializedCorrectly()
        {
            JsonPatchDocument document = new JsonPatchDocument();

            document.AppendTest("/a/b/c", "[ \"foo\", \"bar\" ]");
            Assert.AreEqual(document.ToString(), "[{\"op\":\"test\",\"path\":\"/a/b/c\",\"value\":[\"foo\",\"bar\"]}]");
        }
Ejemplo n.º 2
0
        public void TestIsSerializedCorrectlyGeneric()
        {
            JsonPatchDocument document = new JsonPatchDocument();

            document.AppendTest("/a/b/c", new { a = 2 });
            Assert.AreEqual(document.ToString(), "[{\"op\":\"test\",\"path\":\"/a/b/c\",\"value\":{\"a\":2}}]");
        }
        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\"}" +
                            "]");
        }