Ejemplo n.º 1
0
        public void IfMatchHandlesNullValuesForNonNullable()
        {
            // Arrange
            JsonPatchDocument doc = new JsonPatchDocument();

            doc.Add("/Created", null);

            BugReportPatchVisitor callback = new BugReportPatchVisitor();

            // Act + Assert
            AssertThrows <JsonPatchParserException>(() => doc.Apply(callback));
        }
Ejemplo n.º 2
0
        public void DefaultPatchVisitorFailsOnUnknownPaths()
        {
            // Arrange
            JsonPatchDocument doc = new JsonPatchDocument();

            doc.Add("/XxxUnknown", 10);

            EmptyPatchVisitor callback = new EmptyPatchVisitor();

            // Act + Assert
            AssertThrows <JsonPatchParserException>(() => doc.Apply(callback));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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.");
        }