public void ReplaceNestedObjectWithSerialization() { // Arrange var doc = new SimpleDTOWithNestedDTO() { IntegerValue = 1 }; var newNested = new NestedDTO() { StringProperty = "B" }; // create patch var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>(); patchDoc.Replace<NestedDTO>(o => o.NestedDTO, newNested); var serialized = JsonConvert.SerializeObject(patchDoc); var deserialized = JsonConvert.DeserializeObject<JsonPatchDocument<SimpleDTOWithNestedDTO>>(serialized); // Act deserialized.ApplyTo(doc); // Assert Assert.Equal("B", doc.NestedDTO.StringProperty); }
public void ReplaceNestedObject() { // Arrange var doc = new SimpleDTOWithNestedDTO() { IntegerValue = 1 }; var newNested = new NestedDTO() { StringProperty = "B" }; // create patch var patchDoc = new JsonPatchDocument<SimpleDTOWithNestedDTO>(); patchDoc.Replace<NestedDTO>(o => o.NestedDTO, newNested); // Act patchDoc.ApplyTo(doc); // Assert Assert.Equal("B", doc.NestedDTO.StringProperty); }