コード例 #1
0
        public async Task IgnoreCharsBeforeAndAfter()
        {
            Mocks.StringPipe stringPipe = new Mocks.StringPipe();
            stringPipe.BufferInputString("abc{ \"stringprop\": \"test\", \"booleanprop\": true, \"numberprop\": 456 }123");
            JsonBlockPipe reader = new JsonBlockPipe(stringPipe);
            SimpleObject  result = await reader.ReadBlockAsync <SimpleObject>();

            Assert.Equal("test", result.StringProp);
            Assert.True(result.BooleanProp);
            Assert.Equal((long)456, result.NumberProp);
        }
コード例 #2
0
        public async Task ReadSubclassRelationship()
        {
            Mocks.StringPipe stringPipe = new Mocks.StringPipe();
            stringPipe.BufferInputString("{ \"stringprop\": \"test\", \"booleanprop\": true, \"numberprop\": 456, \"id\": 12345 }");
            JsonBlockPipe reader = new JsonBlockPipe(stringPipe);
            SubObject     result = await reader.ReadBlockAsync <SubObject>();

            Assert.Equal("test", result.StringProp);
            Assert.True(result.BooleanProp);
            Assert.Equal((long)456, result.NumberProp);
            Assert.Equal((long)12345, result.Id);
        }
コード例 #3
0
        public async Task ReadParentChildRelationship()
        {
            Mocks.StringPipe stringPipe = new Mocks.StringPipe();
            stringPipe.BufferInputString("{ \"parentprop\": \"parent\", \"child\": { \"stringprop\": \"test\", \"booleanprop\": true, \"numberprop\": 456 } }");
            JsonBlockPipe     reader = new JsonBlockPipe(stringPipe);
            ParentChildObject result = await reader.ReadBlockAsync <ParentChildObject>();

            Assert.Equal("parent", result.ParentProp);
            Assert.Equal("test", result.Child.StringProp);
            Assert.True(result.Child.BooleanProp);
            Assert.Equal((long)456, result.Child.NumberProp);
        }