예제 #1
0
        public void CanConvertToAndFromJsonWithNestedPatchRequests()
        {
            var patch = new PatchRequest
            {
                Name     = "Comments",
                Type     = PatchCommandType.Modify,
                Position = 0,
                Nested   = new[]
                {
                    new PatchRequest
                    {
                        Name  = "AuthorId",
                        Type  = PatchCommandType.Set,
                        Value = "authors/456"
                    },
                    new PatchRequest
                    {
                        Name  = "AuthorName",
                        Type  = PatchCommandType.Set,
                        Value = "Tolkien"
                    },
                }
            };

            var jsonPatch   = patch.ToJson();
            var backToPatch = PatchRequest.FromJson(jsonPatch);

            Assert.Equal(patch.Name, backToPatch.Name);
            Assert.Equal(patch.Nested.Length, backToPatch.Nested.Length);
        }
예제 #2
0
        public void CanConvertToAndFromJsonWithEmptyNestedPatchRequests()
        {
            var patch = new PatchRequest
            {
                Name     = "Comments",
                Type     = PatchCommandType.Modify,
                Position = 0,
                Nested   = new PatchRequest[] { }
            };

            var jsonPatch   = patch.ToJson();
            var backToPatch = PatchRequest.FromJson(jsonPatch);

            Assert.Equal(patch.Name, backToPatch.Name);
            Assert.Equal(patch.Nested.Length, backToPatch.Nested.Length);
        }