Esempio n. 1
0
        public void SerDeserSubarray_OneSimplePersonWithByteArray_Small()
        {
            var row1 = new SimplePersonWithByteArrayRow
            {
                Age    = 123,
                Bool1  = true,
                ID     = new GDID(12, 234),
                Name   = "Jacques Mudakes",
                Salary = 143098,
                Str1   = "Night Flower",
                Date   = new DateTime(1980, 08, 12, 13, 45, 11),
                Buffer = new byte[] { 1, 7, 9 }
            };

            var data = ArowSerializer.SerializeToSubarray(row1);


            var row2 = new SimplePersonWithByteArrayRow();

            ArowSerializer.Deserialize(row2, data.Array, 0);

            Aver.AreEqual(row1.ID, row2.ID);
            Aver.AreEqual(row1.Bool1, row2.Bool1);
            Aver.AreEqual(row1.Name, row2.Name);
            Aver.AreEqual(row1.Age, row2.Age);
            Aver.AreEqual(row1.Salary, row2.Salary);
            Aver.AreEqual(row1.Str1, row2.Str1);
            Aver.AreEqual(row1.Date, row2.Date);
            Aver.AreArraysEquivalent(row1.Buffer, row2.Buffer);
        }
Esempio n. 2
0
        public void SerDeserSubarray_OneSimplePersonWithByteArray_Large()
        {
            var row1 = new SimplePersonWithByteArrayRow
            {
                Age    = 123,
                Bool1  = true,
                ID     = new GDID(12, 234),
                Name   = "Jacques Marazmos",
                Salary = 143098,
                Str1   = "Drunk Clowns on a hill",
                Date   = new DateTime(1980, 08, 12, 13, 45, 11),
                Buffer = new byte[1024 * 1024] //large buffer which will out-grow buffer cache
            };

            var data = ArowSerializer.SerializeToSubarray(row1);


            var row2 = new SimplePersonWithByteArrayRow();

            ArowSerializer.Deserialize(row2, data.Array, 0);

            Aver.AreEqual(row1.ID, row2.ID);
            Aver.AreEqual(row1.Bool1, row2.Bool1);
            Aver.AreEqual(row1.Name, row2.Name);
            Aver.AreEqual(row1.Age, row2.Age);
            Aver.AreEqual(row1.Salary, row2.Salary);
            Aver.AreEqual(row1.Str1, row2.Str1);
            Aver.AreEqual(row1.Date, row2.Date);
            Aver.AreArraysEquivalent(row1.Buffer, row2.Buffer);

            //================== Try to reuse the serializer cache with smaller payload

            var row1_2 = new SimplePersonWithByteArrayRow
            {
                Age    = 321,
                Bool1  = true,
                ID     = new GDID(112, 243234),
                Name   = "Ghabar Singh!",
                Salary = 13498,
                Str1   = "Hungry Moon",
                Date   = new DateTime(1990, 08, 12, 13, 45, 11),
                Buffer = new byte[] { 21, 7, 9 }
            };

            var data_2 = ArowSerializer.SerializeToSubarray(row1_2);


            var row2_2 = new SimplePersonWithByteArrayRow();

            ArowSerializer.Deserialize(row2_2, data.Array, 0);

            Aver.AreEqual(row1_2.ID, row2_2.ID);
            Aver.AreEqual(row1_2.Bool1, row2_2.Bool1);
            Aver.AreEqual(row1_2.Name, row2_2.Name);
            Aver.AreEqual(row1_2.Age, row2_2.Age);
            Aver.AreEqual(row1_2.Salary, row2_2.Salary);
            Aver.AreEqual(row1_2.Str1, row2_2.Str1);
            Aver.AreEqual(row1_2.Date, row2_2.Date);
            Aver.AreArraysEquivalent(row1_2.Buffer, row2_2.Buffer);
        }