Пример #1
0
        public void Serialize_RootEntry()
        {
            re1 = CommonEntryTest_TraverseTree.NewTestRootEntry(out de2a, out de2b, out de2c, out de3a, out de4a);

            var ms = new MemoryStream();

            Serializer.Serialize(ms, re1);
            var b = ms.ToArray();

            Console.WriteLine($"b.Length {b.Length}");
            Console.WriteLine($"b {ByteArrayHelper.ByteArrayToString(b)}");
            Assert.That(b.Length, Is.EqualTo(118));
        }
Пример #2
0
        public void Serialize_Deserialize_RootEntryMatches()
        {
            re1 = CommonEntryTest_TraverseTree.NewTestRootEntry(out de2a, out de2b, out de2c, out de3a, out de4a);

            var ms = new MemoryStream();

            Serializer.Serialize(ms, re1);
            var b = ms.ToArray();

            var newMS = new MemoryStream(b);
            var re2   = Serializer.Deserialize <RootEntry>(newMS);

            var same = re1.SameTree(re2);

            Assert.That(same, Is.True, TreeDuplicate.LastMessage);
        }
Пример #3
0
        public void DeSerialize_JustRootEntryThatHasTree()
        {
            re1 = CommonEntryTest_TraverseTree.NewTestRootEntry(out de2a, out de2b, out de2c, out de3a, out de4a);

            var ms = new MemoryStream();

            //Serializer.Serialize(ms, re1);
            Serializer.SerializeWithLengthPrefix(ms, re1, PrefixStyle.Base128, 1);
            Serializer.SerializeWithLengthPrefix(ms, re1, PrefixStyle.Base128, 1);

            var b = ms.ToArray();

            Console.WriteLine($"b.Length {b.Length}");
            Console.WriteLine($"b {ByteArrayHelper.ByteArrayToString(b)}");

            var newMS = new MemoryStream(b);

            // var test = Serializer.ListItemTag;
            var iter  = Serializer.DeserializeItems <RootEntry>(newMS, PrefixStyle.Base128, 1);
            var first = iter.FirstOrDefault();

            if (first != null)
            {
                Console.WriteLine("first.RootPath " + first.Path);
            }

            var second = iter.FirstOrDefault();

            if (second != null)
            {
                Console.WriteLine("second.RootPath " + second.Path);
            }
            var third = iter.FirstOrDefault();

            if (third != null)
            {
                Console.WriteLine("third.RootPath " + third.Path);
            }
            else
            {
                Console.WriteLine("third.RootPath doesnt exist.");
            }
        }