public void PatchAsStringAsync() { var item = new PatchTestData { Id = 3, FirstName = "John", Phone = "404-555-1212", NickName = "Big John", WorkPhone = "404-555-8989", LogIns = 1 }; var key = Guid.NewGuid(); _orchestrate.Put(CollectionName, key.ToString(), item); var patchItems = new object[7]; patchItems[0] = new PatchItemString { Op = "add", Path = "/LastName", Value = "Doe" }; patchItems[1] = new PatchItemString { Op = "remove", Path = "/Phone" }; patchItems[2] = new PatchItemString { Op = "replace", Path = "/FirstName", Value = "Jane" }; patchItems[3] = new PatchItemString { Op = "move", From = "/WorkPhone", Path = "/Phone" }; patchItems[4] = new PatchItemString { Op = "copy", From = "/NickName", Path = "/LastName" }; patchItems[5] = new PatchItemInt { Op = "test", Path = "/LogIns", Value = 1 }; patchItems[6] = new PatchItemInt { Op = "inc", Path = "/LogIns", Value = -10 }; var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; var json = JsonConvert.SerializeObject(item, settings); var result = _orchestrate.PatchAsync(CollectionName, key.ToString(), json).Result; Assert.IsTrue(result.Path.Ref.Length > 0); }
public void PatchAsObject() { var item = new PatchTestData { Id = 3, FirstName = "John", Phone = "404-555-1212", NickName = "Big John", WorkPhone = "404-555-8989", LogIns = 1 }; var key = Guid.NewGuid(); _orchestrate.Put(CollectionName, key.ToString(), item); var patchItems = new object[] { new PatchItemString {Op = "add", Path = "/LastName", Value = "Doe"}, new PatchItemString {Op = "remove", Path = "/Phone"}, new PatchItemString {Op = "replace", Path = "/FirstName", Value = "Jane"}, new PatchItemString {Op = "move", From = "/WorkPhone", Path = "/Phone"}, new PatchItemString {Op = "copy", From = "/NickName", Path = "/LastName"}, new PatchItemInt {Op = "test", Path = "/LogIns", Value = 1}, new PatchItemInt {Op = "inc", Path = "/LogIns", Value = -10} }; var result = _orchestrate.Patch(CollectionName, key.ToString(), patchItems); Assert.IsTrue(result.Path.Ref.Length > 0); }