public void Standard() { var o = new SimpleIntKeyData() { Prop1 = 100, Prop2 = ByteEnum.C, Prop3 = "abcde", Prop4 = new SimlpeStringKeyData { Prop1 = 99999, Prop2 = ByteEnum.E, Prop3 = 3 }, Prop5 = new SimpleStructIntKeyData { X = 100, Y = 300, BytesSpecial = new byte[] { 9, 99, 122 } }, Prop6 = new SimpleStructStringKeyData { X = 9999, Y = new[] { 1, 10, 100 } }, BytesSpecial = new byte[] { 1, 4, 6 } }; var bytes = MessagePackSerializer.Serialize(o); var ms = new MemoryStream(bytes); MessagePackBinary.ReadArrayHeader(ms).Is(7); MessagePackBinary.ReadInt32(ms).Is(100); MessagePackBinary.ReadByte(ms).Is((byte)ByteEnum.C); MessagePackBinary.ReadString(ms).Is("abcde"); MessagePackBinary.ReadMapHeader(ms).Is(3); MessagePackBinary.ReadString(ms).Is("Prop1"); MessagePackBinary.ReadInt32(ms).Is(99999); MessagePackBinary.ReadString(ms).Is("Prop2"); MessagePackBinary.ReadByte(ms).Is((byte)ByteEnum.E); MessagePackBinary.ReadString(ms).Is("Prop3"); MessagePackBinary.ReadInt32(ms).Is(3); MessagePackBinary.ReadArrayHeader(ms).Is(3); MessagePackBinary.ReadInt32(ms).Is(100); MessagePackBinary.ReadInt32(ms).Is(300); MessagePackBinary.ReadBytes(ms).Is(new byte[] { 9, 99, 122 }); MessagePackBinary.ReadMapHeader(ms).Is(2); MessagePackBinary.ReadString(ms).Is("key-X"); MessagePackBinary.ReadInt32(ms).Is(9999); MessagePackBinary.ReadString(ms).Is("key-Y"); MessagePackBinary.ReadArrayHeader(ms).Is(3); MessagePackBinary.ReadInt32(ms).Is(1); MessagePackBinary.ReadInt32(ms).Is(10); MessagePackBinary.ReadInt32(ms).Is(100); MessagePackBinary.ReadBytes(ms).Is(new byte[] { 1, 4, 6 }); }
public void Standard() { var o = new SimpleIntKeyData() { Prop1 = 100, Prop2 = ByteEnum.C, Prop3 = "abcde", Prop4 = new SimlpeStringKeyData { Prop1 = 99999, Prop2 = ByteEnum.E, Prop3 = 3 }, Prop5 = new SimpleStructIntKeyData { X = 100, Y = 300, BytesSpecial = new byte[] { 9, 99, 122 } }, Prop6 = new SimpleStructStringKeyData { X = 9999, Y = new[] { 1, 10, 100 } }, BytesSpecial = new byte[] { 1, 4, 6 } }; Convert(o).IsStructuralEqual(o); }
public void NullString() { var o = new SimpleIntKeyData(); var result = Convert(o); result.Prop1.Is(0); result.Prop3.IsNull(); result.Prop4.IsNull(); result.BytesSpecial.IsNull(); }
public void Standard() { try { var o = new SimpleIntKeyData() { Prop1 = 100, Prop2 = ByteEnum.C, Prop3 = "abcde", Prop4 = new SimpleStringKeyData { Prop1 = 99999, Prop2 = ByteEnum.E, Prop3 = 3 }, Prop5 = new SimpleStructIntKeyData { X = 100, Y = 300, BytesSpecial = new byte[] { 9, 99, 122 } }, Prop6 = new SimpleStructStringKeyData { X = 9999, Y = new[] { 1, 10, 100 } }, BytesSpecial = new byte[] { 1, 4, 6 } }; MessagePackSerializer.Serialize(o); //var c = Convert(o); //c.Prop1.Is(o.Prop1); //c.Prop2.Is(o.Prop2); //c.Prop3.Is(o.Prop3); //c.Prop4.Prop1.Is(o.Prop4.Prop1); //c.Prop4.Prop2.Is(o.Prop4.Prop2); //c.Prop4.Prop3.Is(o.Prop4.Prop3); //c.Prop5.X.Is(o.Prop5.X); //c.Prop5.Y.Is(o.Prop5.Y); //c.Prop5.BytesSpecial.SequenceEqual(o.Prop5.BytesSpecial).IsTrue(); //c.Prop6.X.Is(o.Prop6.X); //c.Prop6.Y.SequenceEqual(o.Prop6.Y).IsTrue(); //c.BytesSpecial.SequenceEqual(o.BytesSpecial).IsTrue(); } catch (Exception ex) { UnityEngine.Debug.LogException(ex); } }
public void Null() { SimpleIntKeyData n = null; var bytes = JsonSerializer.Serialize(n); new JsonReader(bytes).ReadIsNull().IsTrue(); JsonSerializer.Deserialize <SimpleIntKeyData>(bytes).IsNull(); // deserialize from nil Xunit.Assert.Throws <InvalidOperationException>(() => { JsonSerializer.Deserialize <SimpleStructIntKeyData>(bytes); }); }
public void Null() { SimpleIntKeyData n = null; var bytes = MessagePackSerializer.Serialize(n); MessagePackBinary.IsNil(bytes, 0).IsTrue(); bytes.Length.Is(1); MessagePackSerializer.Deserialize <SimpleIntKeyData>(bytes).IsNull(); // deserialize from nil Xunit.Assert.Throws <InvalidOperationException>(() => { MessagePackSerializer.Deserialize <SimpleStructIntKeyData>(bytes); }); }
public void Null() { SimpleIntKeyData n = null; var bytes = serializer.Serialize(n); new MessagePackReader(bytes).IsNil.IsTrue(); bytes.Length.Is(1); serializer.Deserialize <SimpleIntKeyData>(bytes).IsNull(); // deserialize from nil Assert.Throws <InvalidOperationException>(() => { serializer.Deserialize <SimpleStructIntKeyData>(bytes); }); }
public void Null() { SimpleIntKeyData n = null; var bytes = MessagePackSerializer.Serialize(n); var reader = new MessagePackReader(bytes); reader.IsNil.IsTrue(); bytes.Length.Is(1); MessagePackSerializer.Deserialize <SimpleIntKeyData>(bytes).IsNull(); // deserialize from nil Xunit.Assert.Throws <MessagePackSerializationException>(() => { MessagePackSerializer.Deserialize <SimpleStructIntKeyData>(bytes); }); }
public void Standard() { var o = new SimpleIntKeyData() { Prop1 = 100, Prop2 = ByteEnum.C, Prop3 = "abcde", Prop4 = new SimlpeStringKeyData { Prop1 = 99999, Prop2 = ByteEnum.E, Prop3 = 3 }, Prop5 = new SimpleStructIntKeyData { X = 100, Y = 300, BytesSpecial = new byte[] { 9, 99, 122 } }, Prop6 = new SimpleStructStringKeyData { X = 9999, Y = new[] { 1, 10, 100 } }, BytesSpecial = new byte[] { 1, 4, 6 } }; var c = Convert(o); c.Prop1.Is(o.Prop1); c.Prop2.Is(o.Prop2); c.Prop3.Is(o.Prop3); c.Prop4.Prop1.Is(o.Prop4.Prop1); c.Prop4.Prop2.Is(o.Prop4.Prop2); c.Prop4.Prop3.Is(o.Prop4.Prop3); c.Prop5.X.Is(o.Prop5.X); c.Prop5.Y.Is(o.Prop5.Y); c.Prop5.BytesSpecial.SequenceEqual(o.Prop5.BytesSpecial).IsTrue(); c.Prop6.X.Is(o.Prop6.X); c.Prop6.Y.SequenceEqual(o.Prop6.Y).IsTrue(); c.BytesSpecial.SequenceEqual(o.BytesSpecial).IsTrue(); }