Ejemplo n.º 1
0
        public void WriteDynamicTravelTest()
        {
            var bytes = _context.Pack(DataBlock.Filled());

            Assert.NotNull(bytes);
            Assert.True(bytes.Length > 0);
            var hex = "0x" + string.Join("", bytes.Select(b => b.ToString("X")));

            Assert.NotNull(hex);
            var expected = BinarySerializationTestContext.GetFilledDataBlockHexString();

            Assert.Equal(expected, hex);
        }
Ejemplo n.º 2
0
        public void ReadHardCodedTravelTest()
        {
            var bytes   = BinarySerializationTestContext.GetFilledDataBlockBlob();
            var stream  = new MemoryStream(bytes);
            var visitor = new PackedDataReadVisitor(stream);

            var traveller = DataBlockHardCodedTraveller.Create();

            var graph = new DataBlock();

            traveller.Travel(visitor, graph);

            var expected = DataBlock.Filled();

            graph.AssertEqualTo(expected);
        }
Ejemplo n.º 3
0
        public void ReadDynamicTravelTest()
        {
            var bytes   = BinarySerializationTestContext.GetFilledDataBlockBlob();
            var stream  = new MemoryStream(bytes);
            var visitor = new PackedDataReadVisitor(stream);

            var context   = new DynamicTravellerContext();
            var traveller = context.GetInstance <DataBlock>();

            var graph = new DataBlock();

            traveller.Travel(visitor, graph);

            var expected = DataBlock.Filled();

            graph.AssertEqualTo(expected);
        }