Exemplo n.º 1
0
        public void Test_Writing_An_Object()
        {
            uint offset = 0xFFEEDDCC;

            binaryWriter.Position.Returns(offset);
            binaryWriter.WriteUInt32(Arg.Do <uint>(_ => binaryWriter.Position.Returns(0)));

            uint result = offsetNode.Write(binaryWriter, "value");

            result.Should().Be(offset);

            binaryWriter.Received().WriteUInt32(0); // offset placeholder
        }
Exemplo n.º 2
0
        public void Test_Writing_An_Instance_Of_A_Tree_With_Nested_Empty_Lists()
        {
            uint      originalPosition1 = 28, originalPosition2 = 39;
            uint      offsetPosition1 = 20, offsetPosition2 = 30;
            IDataNode rootNode = TreeWithNestedLists.Build();

            TreeWithNestedLists.Class value = new TreeWithNestedLists.Class
            {
                List1 = new List <TreeWithHeight1.Class>
                {
                },
                List2 = new List <TreeWithHeight2.Class>
                {
                }
            };

            IOffsetNode list1ChildNode = rootNode.Edges[0].ChildNode as IOffsetNode;

            list1ChildNode
            .Write(binaryWriter, Arg.Any <object>())
            .Returns(offsetPosition1);

            IOffsetNode list2ChildNode = rootNode.Edges[1].ChildNode as IOffsetNode;

            list2ChildNode
            .Write(binaryWriter, Arg.Any <object>())
            .Returns(offsetPosition2);

            binaryWriter.GetPosition().Returns(originalPosition1, originalPosition2);

            treeWriter.Write(binaryWriter, value, rootNode)
            .Should()
            .Equal(offsetPosition1, offsetPosition2);

            list1ChildNode.ChildNode.DidNotReceive().Write(binaryWriter, Arg.Any <object>());
            list2ChildNode.ChildNode.DidNotReceive().Write(binaryWriter, Arg.Any <object>());

            Received.InOrder(() => VerifyWriteTreeWithNestedLists(rootNode, value, originalPosition1, originalPosition2, offsetPosition1, offsetPosition2));
        }
Exemplo n.º 3
0
        private void ProcessOffsetNode(IBinaryWriter binaryWriter, IOffsetNode node, object value)
        {
            uint offsetPosition = node.Write(binaryWriter, value);

            Enqueue(node.ChildNode, value, offsetPosition);
        }