Beispiel #1
0
        public void Test_Writing_An_Instance_Of_A_Tree_With_A_Node_At_A_Large_Offset()
        {
            long      originalPosition = (long)uint.MaxValue + 1;
            IDataNode rootNode         = TreeWithNodeAtOffset.Build();

            TreeWithNodeAtOffset.Class value = new TreeWithNodeAtOffset.Class
            {
                ValueAtOffset = "offset too large",
                ValueInline   = 7
            };
            Action action = () => treeWriter.Write(binaryWriter, value, rootNode);

            binaryWriter.GetPosition().Returns(originalPosition);

            action.Should()
            .ThrowExactly <ArgumentException>()
            .WithMessage($"Offset 0x{originalPosition:X} is larger than {sizeof(uint)} bytes.");

            binaryWriter.DidNotReceive().WriteUInt32(Arg.Any <uint>());
        }
Beispiel #2
0
        public void Test_Reading_An_Instance_Of_A_Tree_With_A_Node_At_Offset()
        {
            uint      originalPosition = 27, offset = 15;
            IDataNode rootNode = TreeWithNodeAtOffset.Build();

            TreeWithNodeAtOffset.Class expected = new TreeWithNodeAtOffset.Class
            {
                ValueAtOffset = "value",
                ValueInline   = 54
            };

            binaryReader.GetPosition().Returns(originalPosition);

            SetupTreeWithNodeAtOffset(rootNode, expected, offset);

            object result = treeReader.Read(binaryReader, rootNode);

            Received.InOrder(() => VerifyReadTreeWithNodeAtOffset(rootNode, originalPosition, offset));

            result.Should().BeEquivalentTo(expected);
        }
Beispiel #3
0
        public void Test_Writing_An_Instance_Of_A_Tree_With_A_Node_At_Offset()
        {
            uint      originalPosition = 43, offset = 15;
            IDataNode rootNode = TreeWithNodeAtOffset.Build();

            TreeWithNodeAtOffset.Class value = new TreeWithNodeAtOffset.Class
            {
                ValueAtOffset = "value",
                ValueInline   = 54
            };

            binaryWriter.GetPosition().Returns(originalPosition);

            (rootNode.Edges[0].ChildNode as IOffsetNode)
            .Write(binaryWriter, Arg.Any <object>())
            .Returns(offset);

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

            Received.InOrder(() => VerifyWriteTreeWithNodeAtOffset(rootNode, value, originalPosition, offset));
        }