public async Task ReadMultipleObjects() { Mocks.StringPipe stringPipe = new Mocks.StringPipe(); stringPipe.BufferInputString("{ \"stringprop\": \"test\", \"booleanprop\": true, \"numberprop\": 456, \"id\": 12345 }garb"); stringPipe.BufferInputString("age{ \"stringprop\": \"test2\", \"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); result = await reader.ReadBlockAsync <SubObject>(); Assert.Equal("test2", result.StringProp); Assert.True(result.BooleanProp); Assert.Equal((long)456, result.NumberProp); Assert.Equal((long)12345, result.Id); }
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); }
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); }