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); }
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); }