public void create_proxy_patch() { Type proxyType = _proxyFactory.Create <Entity>(); Entity entity = (Entity)Activator.CreateInstance(proxyType); entity.Name = "newName"; IPatch entityChanges = (IPatch)entity; Assert.True(entityChanges.IsSet("Name")); Assert.False(entityChanges.IsSet("Date")); entityChanges.Reset(); Assert.False(entityChanges.IsSet("Name")); Assert.False(entityChanges.IsSet("Date")); }
public void deserialize_as_patch() { JsonSerializerOptions jsonOptions = new JsonSerializerOptions(); jsonOptions.Converters.Add(new PatchJsonConverterFactory(Options.Create(new ModelOptions()))); jsonOptions.IgnoreReadOnlyProperties = true; string json = @" { 'Id': 1, 'Name': 'test name' }"; Entity entity = JsonSerializer.Deserialize <Entity>(json.Replace("'", "\""), jsonOptions); IPatch changeTracking = (IPatch)entity; Assert.True(changeTracking.IsSet("Name")); Assert.True(changeTracking.IsSet("Id")); Assert.False(changeTracking.IsSet("Date")); }