public void IfMatchHandlesNullValuesForNonNullable() { // Arrange JsonPatchDocument doc = new JsonPatchDocument(); doc.Add("/Created", null); BugReportPatchVisitor callback = new BugReportPatchVisitor(); // Act + Assert AssertThrows <JsonPatchParserException>(() => doc.Apply(callback)); }
public void DefaultPatchVisitorFailsOnUnknownPaths() { // Arrange JsonPatchDocument doc = new JsonPatchDocument(); doc.Add("/XxxUnknown", 10); EmptyPatchVisitor callback = new EmptyPatchVisitor(); // Act + Assert AssertThrows <JsonPatchParserException>(() => doc.Apply(callback)); }
public void CanUseIfMatchInVisitor() { // Arrange JsonPatchDocument doc = new JsonPatchDocument(); doc.Add("/Id", 10); BugReportPatchVisitor callback = new BugReportPatchVisitor(); // Act doc.Apply(callback); // Assert Assert.AreEqual("/Id => 10|", callback.Result); }
public void IfMatchHandlesNullValuesForNullable() { // Arrange JsonPatchDocument doc = new JsonPatchDocument(); doc.Add("/Responsible", null); doc.Add("/Title", null); doc.Add("/LastModified", null); BugReportPatchVisitor callback = new BugReportPatchVisitor(); // Act doc.Apply(callback); // Assert Assert.AreEqual("/Responsible => |/Title => |/LastModified => |", callback.Result); }
public void CanApplyPatchDocument() { // Arrange JsonPatchDocument doc = new JsonPatchDocument(); doc.Add("/A", 1); doc.Remove("/A"); doc.Replace("/A", 2); doc.Move("/A", "/B"); doc.Copy("/A", "/B"); doc.Test("/A", 3); PatchVisitor callback = new PatchVisitor(); // Act doc.Apply(callback); // Assert Assert.AreEqual(doc.ToString(), callback.newDoc.ToString()); Assert.IsTrue(callback.IsComplete, "Apply() method must call Complete."); }