Пример #1
0
        public void ToBufferTest3()
        {
            TestPackageBuffer package1 = new TestPackageBuffer();

            Serializer ser = new Regulus.Serialization.Serializer(new DescriberBuilder(typeof(int), typeof(string), typeof(char[]), typeof(byte), typeof(byte[]), typeof(byte[][]), typeof(char), typeof(Guid), typeof(TestPackageBuffer)).Describers);

            package1.Datas = new byte[0][];

            byte[] buffer = package1.ToBuffer(ser);

            TestPackageBuffer package2 = buffer.ToPackageData <TestPackageBuffer>(ser);


            Xunit.Assert.Equal(0, package2.Datas.Length);
        }
Пример #2
0
        public void ToBufferTest2()
        {
            int               p1       = 0;
            string            p2       = "234";
            Guid              p3       = Guid.NewGuid();
            TestPackageBuffer package1 = new TestPackageBuffer();
            Serializer        ser      = new Regulus.Serialization.Serializer(new DescriberBuilder(typeof(int), typeof(string), typeof(char[]), typeof(byte), typeof(byte[]), typeof(byte[][]), typeof(char), typeof(Guid), typeof(TestPackageBuffer)).Describers);


            package1.Datas = new[] { ser.ObjectToBuffer(p1), ser.ObjectToBuffer(p2), ser.ObjectToBuffer(p3) };

            byte[] buffer = package1.ToBuffer(ser);

            TestPackageBuffer package2 = buffer.ToPackageData <TestPackageBuffer>(ser);


            Xunit.Assert.Equal(p1, ser.BufferToObject(package2.Datas[0]));
            Xunit.Assert.Equal(p2, ser.BufferToObject(package2.Datas[1]));
            Xunit.Assert.Equal(p3, ser.BufferToObject(package2.Datas[2]));
        }