public Copy ( string from, string path ) : |
||
from | string | source location |
path | string | target location |
return |
public void NonGenericPatchDocToGenericMustSerialize() { // Arrange var targetObject = new SimpleObject() { StringProperty = "A", AnotherStringProperty = "B" }; var patchDocument = new JsonPatchDocument(); patchDocument.Copy("StringProperty", "AnotherStringProperty"); var serialized = JsonConvert.SerializeObject(patchDocument); var deserialized = JsonConvert.DeserializeObject <JsonPatchDocument <SimpleObject> >(serialized); // Act deserialized.ApplyTo(targetObject); // Assert Assert.Equal("A", targetObject.AnotherStringProperty); }
public void CopyPropertyValue_ToDynamicTestObject_WithCustomNamingStrategy() { // Arrange var contractResolver = new DefaultContractResolver { NamingStrategy = new TestNamingStrategy() }; dynamic targetObject = new DynamicTestObject(); targetObject.customStringProperty = "A"; targetObject.customAnotherStringProperty = "B"; var patchDocument = new JsonPatchDocument(); patchDocument.Copy("StringProperty", "AnotherStringProperty"); patchDocument.ContractResolver = contractResolver; // Act patchDocument.ApplyTo(targetObject); // Assert Assert.Equal("A", targetObject.customAnotherStringProperty); }