public void Serialize_ShouldNotWrite_GivenWriteOnlyProperty() { var instance = ReadWriteProperties.Random(); var context = new Context <ReadWriteProperties>( instance ); var expected = $"{{\"ReadOnlyProperty\":{instance.ReadOnlyProperty}}}"; var actual = context.Json; Assert.Equal(expected, actual); }
public void Serialize_ShouldNotRead_GivenReadOnlyProperty() { var instance = ReadWriteProperties.Random(); var context = new Context <ReadWriteProperties>( instance ); var expected = 0; var actual = context.Instance.ReadOnlyProperty; Assert.Equal(expected, actual); }
public void Serialize_ShouldRead_GivenWriteOnlyProperty() { var instance = ReadWriteProperties.Random(); var context = new Context <ReadWriteProperties>( instance ); var expected = instance.ReadOnlyProperty; var json = $"{{\"WriteOnlyProperty\":{expected}}}"; var actual = JsonSerializer.Deserialize <ReadWriteProperties>( json, context.Options ).GetWriteOnlyProperty(); Assert.Equal(expected, actual); }