public void PatchWithNoKeyAsync() { var patchItem = new PatchItemString { Op = "add", Path = "/LastName", Value = "Doe" }; try { var result = _orchestrate.PatchAsync(CollectionName, string.Empty, patchItem).Result; } catch (AggregateException ex) { var inner = ex.InnerExceptions.First() as ArgumentNullException; Assert.IsTrue(inner?.ParamName == "key"); return; } Assert.Fail("No Exception Thrown"); }
public void PatchWithNoKey() { var patchItem = new PatchItemString { Op = "add", Path = "/LastName", Value = "Doe" }; try { _orchestrate.Patch(CollectionName, string.Empty, patchItem); } catch (ArgumentNullException ex) { Assert.IsTrue(ex.ParamName == "key"); return; } Assert.Fail("No Exception Thrown"); }
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 PatchIfMatchWithNoCollectionName() { var match = _orchestrate.Get(CollectionName, "1"); var patchItem = new PatchItemString { Op = "add", Path = "/LastName", Value = "Doe" }; try { _orchestrate.PatchIfMatch(string.Empty, "2", patchItem, match.Path.Ref); } catch (ArgumentNullException ex) { Assert.IsTrue(ex.ParamName == "collectionName"); return; } Assert.Fail("No Exception Thrown"); }
public void PatchIfMatchFailAsync() { var match = _orchestrate.Get(CollectionName, "1"); var item = new PatchItemString { Op = "replace", Path = "Valie", Value = "New and improved value!" }; try { var result = _orchestrate.PatchIfMatchAsync(CollectionName, "2", item, match.Path.Ref).Result; } catch (Exception ex) { Assert.IsTrue(ex.Message.Contains("412")); } }
public void PatchIfMatchAsyncSuccess() { var match = _orchestrate.Get(CollectionName, "1"); var item = new PatchItemString { Op = "replace", Path = "Valie", Value = "New and improved value!" }; var result = _orchestrate.PatchIfMatchAsync(CollectionName, "1", item, match.Path.Ref).Result; Assert.IsTrue(result.Value == null || result.Value.ToString() == string.Empty); }