public void TestReadByAttribute() { const string hexBuffer = "A16249640C"; // {"Id":12} ObjectWithCallbacks obj = Helper.Read <ObjectWithCallbacks>(hexBuffer); Assert.NotNull(obj); Assert.True(obj.OnDeserializingCalled); Assert.True(obj.OnDeserializedCalled); Assert.False(obj.OnSerializingCalled); Assert.False(obj.OnSerializedCalled); }
public void TestReadByAttribute() { JsonSerializerOptions options = new JsonSerializerOptions(); options.SetupExtensions(); const string json = @"{""Id"":12}"; ObjectWithCallbacks obj = Helper.Read <ObjectWithCallbacks>(json, options); Assert.NotNull(obj); Assert.True(obj.OnDeserializingCalled); Assert.True(obj.OnDeserializedCalled); Assert.False(obj.OnSerializingCalled); Assert.False(obj.OnSerializedCalled); }
public void TestReadByApi() { CborOptions options = new CborOptions(); options.Registry.ObjectMappingRegistry.Register <ObjectWithCallbacks>(om => { om.MapMember(o => o.Id); om.SetOnDeserializingMethod(o => o.OnDeserializing()); om.SetOnDeserializedMethod(o => o.OnDeserialized()); }); const string hexBuffer = "A16249640C"; // {"Id":12} ObjectWithCallbacks obj = Helper.Read <ObjectWithCallbacks>(hexBuffer, options); Assert.NotNull(obj); Assert.True(obj.OnDeserializingCalled); Assert.True(obj.OnDeserializedCalled); Assert.False(obj.OnSerializingCalled); Assert.False(obj.OnSerializedCalled); }
public void TestReadByApi() { JsonSerializerOptions options = new JsonSerializerOptions(); options.SetupExtensions(); options.GetObjectMappingRegistry().Register <ObjectWithCallbacks>(om => { om.MapMember(o => o.Id); om.SetOnDeserializingMethod(o => o.OnDeserializing()); om.SetOnDeserializedMethod(o => o.OnDeserialized()); }); const string json = @"{""Id"":12}"; ObjectWithCallbacks obj = Helper.Read <ObjectWithCallbacks>(json, options); Assert.NotNull(obj); Assert.True(obj.OnDeserializingCalled); Assert.True(obj.OnDeserializedCalled); Assert.False(obj.OnSerializingCalled); Assert.False(obj.OnSerializedCalled); }