public void DictionaryDeserializeNested() { var decoded = LightWeight.Deserialize <Dictionary <UInt32, Dictionary <UInt32, String> > >(new Byte[] { 0x03, // HEADER Count=2 0x01, // 1= 0x03, // HEADER Count=2 0x02, // 2= 0x05, (Byte)'c', (Byte)'a', (Byte)'k', (Byte)'e', // cake 0x03, // 3= 0x05, (Byte)'f', (Byte)'o', (Byte)'o', (Byte)'d', // food 0x02, // 2= 0x03, // HEADER Count=2 0x04, // 4= 0x05, (Byte)'f', (Byte)'o', (Byte)'r', (Byte)'k', // fork 0x05, // 5= 0x05, (Byte)'f', (Byte)'o', (Byte)'o', (Byte)'d', // food }); Assert.Equal(new Dictionary <UInt32, Dictionary <UInt32, String> > { { 1, new Dictionary <UInt32, String> { { 2, "cake" }, { 3, "food" } } }, { 2, new Dictionary <UInt32, String> { { 4, "fork" }, { 5, "food" } } } }, decoded); }
public void ArrayDeserializeNull1() { var result = LightWeight.Deserialize <Boolean[]>(new Byte[] { 0x00 // HEADER NULL }); Assert.Null(result); }
public void ClassDeserializeNull() { var decoded = LightWeight.Deserialize <One>(new Byte[] { 0x00 // HEADER NULL }); Assert.Null(decoded); }
public void ArrayDeserializeEmpty() { var result = LightWeight.Deserialize <Int32[]>(new Byte[] { 0x01 // HEADER Count=0 }); Assert.Equal(new Int32[] { }, result); }
public void DictionaryDeserializeEmpty() { var decoded = LightWeight.Deserialize <Dictionary <Int32, String> >(new Byte[] { 0x01 // HEADER Count=0 }); Assert.Equal(new Dictionary <Int32, String>(), decoded); }
public void DictionaryDeserializeNull() { var decoded = LightWeight.Deserialize <Dictionary <Int32, String> >(new Byte[] { 0x00 // HEADER NULL }); Assert.Null(decoded); }
public void ListDeserializeNull() { var result = LightWeight.Deserialize <List <Int32> >(new Byte[] { 0x00 // HEADER Null }); Assert.Null(result); }
public void ListDeserializeEmpty() { var result = LightWeight.Deserialize <List <Int32> >(new Byte[] { 0x01 // HEADER Count=0 }); Assert.Equal(new List <Int32> { }, result); }
public void ArrayDeserializeNull2() { var result = LightWeight.Deserialize <ArrayNullClass>(new Byte[] { 0x02, // HEADER Length=1 0x00 // HEADER NULL }); Assert.Null(result.B); }
public void ClassDeserializeEmpty() { var encoded = LightWeight.Deserialize <NoIndexs>(new Byte[] { 0x01 // HEADER Length=0 }); Assert.Equal((UInt32)0, encoded.A); Assert.Equal((UInt32)0, encoded.B); Assert.Equal((UInt32)0, encoded.C); }
public void FloorDeserializeUnsupported() { Assert.Throws <UnsupportedDataTypeException>(() => { LightWeight.Deserialize <Unsupported>(new Byte[] { 0x02, // HEADER Length=1 0x01, // [Value]=6 }); }); }
public void ArrayDeserializeSInt32() { var result = LightWeight.Deserialize <UInt32[]>(new Byte[] { 0x04, // HEADER Count=3 0x01, // [0]=1 0x02, // [1]=2 0xE8, 0x06 // [3]=1000 }); Assert.Equal(new UInt32[] { 1, 2, 1000 }, result); }
public void ArrayDeserializeBoolean() { var result = LightWeight.Deserialize <Boolean[]>(new Byte[] { 0x04, // HEADER Count=3 0x01, // [0]=true 0x01, // [1]=true 0x00 // [2]=false }); Assert.Equal(new[] { true, true, false }, result); }
public void ListDeserializeInt32() { var result = LightWeight.Deserialize <List <UInt32> >(new Byte[] { 0x04, // HEADER Count=3 0x01, // [0]=1, 0x02, // [1]=2, 0xE8, 0x06 // [2]=1000 }); Assert.Equal(new List <UInt32> { 1, 2, 1000 }, result); }
public void ClassDeserializeBasic() { var encoded = LightWeight.Deserialize <One>(new Byte[] { 0x05, // HEADER Length=4 0x09, // [A]=9 0x01, // [B]=1 0xE8, 0x06, // [C]=1000 }); Assert.Equal((UInt32)1, encoded.A); Assert.Equal((UInt32)1, encoded.A); Assert.Equal((UInt32)9, encoded.B); Assert.Equal((UInt32)1000, encoded.C); }
public void DictionaryDeserializeUInt32String() { var encoded = LightWeight.Deserialize <Dictionary <UInt32, String> >(new Byte[] { 0x03, // HEADER Count=2 0x01, // 1= 0x02, (Byte)'a', // "a" 0x02, // 2= 0x02, (Byte)'b' }); Assert.Equal(new Dictionary <UInt32, String>() { { 1, "a" }, { 2, "b" } }, encoded); }
public void ClassDeserializeNested() { var encoded = LightWeight.Deserialize <Two>(new Byte[] { 11, // HEADER Length=10 5, (Byte)'t', (Byte)'e', (Byte)'s', (Byte)'t', // [A]=test 5, // HEADER Length=4 0x09, // [A]=9 0x01, // [B]=1 0xE8, 0x06 // [C]=1000 }); Assert.Equal("test", encoded.Y); Assert.Equal((UInt32)1, encoded.Z.A); Assert.Equal((UInt32)1, encoded.Z.A); Assert.Equal((UInt32)9, encoded.Z.B); Assert.Equal((UInt32)1000, encoded.Z.C); }
public void FloorDeserializeMin() { var decoded = LightWeight.Deserialize <One>(new Byte[] { 0x09, // HEADER Length=8 0x00, // [U8]=5 0x00, // [U16]=5 0x00, // [U32]=5 0x00, // [U64]=5 0x00, // [S8]=5 0x00, // [S16]=5 0x00, // [S32]=5 0x00, // [S64]=5 }); Assert.Equal((Byte)5, decoded.U8); Assert.Equal((UInt16)5, decoded.U16); Assert.Equal((UInt32)5, decoded.U32); Assert.Equal((UInt64)5, decoded.U64); Assert.Equal((SByte)5, decoded.S8); Assert.Equal((Int16)5, decoded.S16); Assert.Equal((Int32)5, decoded.S32); Assert.Equal((Int64)5, decoded.S64); }
public void FloorDeserializeMinPlus1() { var decoded = LightWeight.Deserialize <One>(new Byte[] { 0x09, // HEADER Length=8 0x01, // [U8]=6 0x01, // [U16]=6 0x01, // [U32]=6 0x01, // [U64]=6 0x01, // [S8]=6 TODO: need to check this value is correct 0x02, // [S16]=6 0x02, // [S32]=6 0x02, // [S64]=6 }); Assert.Equal((Byte)6, decoded.U8); Assert.Equal((UInt16)6, decoded.U16); Assert.Equal((UInt32)6, decoded.U32); Assert.Equal((UInt64)6, decoded.U64); Assert.Equal((SByte)6, decoded.S8); Assert.Equal((Int16)6, decoded.S16); Assert.Equal((Int32)6, decoded.S32); Assert.Equal((Int64)6, decoded.S64); }
public void SingleDeserializeMax() { Assert.Equal(Single.MaxValue, LightWeight.Deserialize <Single>(BitConverter.GetBytes(Single.MaxValue))); }
public void UInt32DeserializeEnum() { Assert.Equal(TestEnum.B, LightWeight.Deserialize <TestEnum>(UnsignedVlq.Encode((UInt32)TestEnum.B).ToArray())); }
public void UInt32DeserializeMax() { Assert.Equal(UInt32.MaxValue, LightWeight.Deserialize <UInt32>(UnsignedVlq.Encode(UInt32.MaxValue).ToArray())); }
public void SInt64DeserializeEnum() { Assert.Equal(TestEnum.B, LightWeight.Deserialize <TestEnum>(SignedVlq.Encode((Int64)TestEnum.B).ToArray())); }
public void SInt64DeserializeMax() { Assert.Equal(SignedVlq.MaxValue, LightWeight.Deserialize <Int64>(SignedVlq.Encode(SignedVlq.MaxValue).ToArray())); }
public void SInt64Deserialize10() { Assert.Equal((Int64)10, LightWeight.Deserialize <Int64>(SignedVlq.Encode(10).ToArray())); }
public void BooleanDeserializeFalse() { Assert.False(LightWeight.Deserialize <Boolean>(UnsignedVlq.Encode(0).ToArray())); }
public void BooleanDeserializeTrue() { Assert.True(LightWeight.Deserialize <Boolean>(UnsignedVlq.Encode(1).ToArray())); }
public void UInt64DeserializeMin() { Assert.Equal(UnsignedVlq.MinValue, LightWeight.Deserialize <UInt64>(UnsignedVlq.Encode(UnsignedVlq.MinValue).ToArray())); }
public void SInt16DeserializeZero() { Assert.Equal((Int16)0, LightWeight.Deserialize <Int16>(SignedVlq.Encode(0).ToArray())); }
public void SInt16DeserializeMin() { Assert.Equal(Int16.MinValue, LightWeight.Deserialize <Int16>(SignedVlq.Encode(Int16.MinValue).ToArray())); }