Exemple #1
0
        public void Test_Reading_An_Offset()
        {
            uint offset = 0xFFEEDDCC;

            binaryReader.ReadUInt32().Returns(offset);

            uint result = offsetNode.ReadOffset(binaryReader);

            binaryReader.Received().ReadUInt32();

            result.Should().Be(offset);
        }
Exemple #2
0
        private object ProcessOffsetNode(IBinaryReader binaryReader, IOffsetNode node)
        {
            uint offset = node.ReadOffset(binaryReader);

            object result = null;

            binaryReader.DoAtPosition(offset, () => result = ProcessDataNode(binaryReader, node.ChildNode));

            return(result);
        }
        private void VerifyReadTreeWithNodeAtOffset(IDataNode node, uint originalPosition, uint offsetPosition)
        {
            node.Read(binaryReader);

            IOffsetNode offsetNode = node.Edges[0].ChildNode as IOffsetNode;

            offsetNode.ReadOffset(binaryReader);
            binaryReader.VerifyDoAtPosition(originalPosition, offsetPosition, () => offsetNode.ChildNode.Read(binaryReader));

            (node.Edges[1].ChildNode as IDataNode).Read(binaryReader);
        }
        private void SetupTreeWithNodeAtOffset(IDataNode node, TreeWithNodeAtOffset.Class expected, uint offset)
        {
            node.Read(binaryReader).Returns(_ => new TreeWithNodeAtOffset.Class());

            IOffsetNode offsetNode = node.Edges[0].ChildNode as IOffsetNode;

            offsetNode.ReadOffset(binaryReader).Returns(offset);
            offsetNode.ChildNode.Read(binaryReader).Returns(expected.ValueAtOffset);

            (node.Edges[1].ChildNode as IDataNode).Read(binaryReader).Returns(expected.ValueInline);
        }