public void Remove_OnApplyFromJson_RespectsJsonPropertyNameOnJsonDocument() { var doc = new JsonPropertyObject() { Name = "InitialValue" }; // serialization should serialize to "AnotherName" var serialized = "[{\"path\":\"/AnotherName\",\"op\":\"remove\"}]"; var deserialized = JsonConvert.DeserializeObject <JsonPatchDocument <JsonPropertyObject> >(serialized); deserialized.ApplyTo(doc); Assert.Null(doc.Name); }
public void Add_WithExpression_RespectsJsonPropertyName_WhenApplyingToSameTypedClassWithMatchingJsonPropertyName() { var patchDocToSerialize = new JsonPatchDocument <JsonPropertyObject>(); patchDocToSerialize.Add(p => p.Name, "John"); // the patchdoc will deserialize to "anothername". As JsonPropertyDTO has // a JsonProperty signifying that "Name" should be deseriallized from "AnotherName", // we should be able to apply the patchDoc. var doc = new JsonPropertyObject() { Name = "InitialValue" }; var serialized = JsonConvert.SerializeObject(patchDocToSerialize); var deserialized = JsonConvert.DeserializeObject <JsonPatchDocument <JsonPropertyObject> > (serialized); deserialized.ApplyTo(doc); Assert.Equal("John", doc.Name); }