コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }