예제 #1
0
        // ReSharper disable once IdentifierTypo
        public void Should_Hydrate_Poco_In_PascalCase_Whatever_The_Case_In_Json()
        {
            var jsonData   = Encoding.UTF8.GetBytes("{ \"SomeProperty\": \"SOME\", \"someIntProperty\": 12345, \"haspAscalCASE\": true }");
            var transcoder = new JsonTranscoder();
            var hydrated   = transcoder.DeserializeAsJson <Pascal>(jsonData.AsMemory());

            Assert.Equal("SOME", hydrated.SomeProperty);
            Assert.Equal(12345, hydrated.SomeIntProperty);
            Assert.True(hydrated.HasPascalCase);
        }
예제 #2
0
        public void Test_Json_Deserialize_Int()
        {
            var transcoder = new JsonTranscoder();
            int value      = 42;

            using var stream = new MemoryStream();
            transcoder.SerializeAsJson(stream, value);
            var actual = transcoder.DeserializeAsJson <int>(stream.ToArray());

            Assert.Equal(value, actual);
        }