コード例 #1
0
ファイル: TreeReaderTests.cs プロジェクト: Vraiment/SAGESharp
        public void Test_Reading_An_Instance_Of_A_Tree_With_Nested_Empty_Lists()
        {
            uint      offsetPosition1 = 20, offsetPosition2 = 30;
            IDataNode rootNode = TreeWithNestedLists.Build();

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

            SetupTreeWithNestedLists(rootNode, expected, offsetPosition1, offsetPosition2);

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

            binaryReader.DidNotReceive().GetPosition();

            Received.InOrder(() => VerifyReadTreeWithNestedLists(rootNode));

            result.Should().BeEquivalentTo(expected);
        }
コード例 #2
0
ファイル: TreeReaderTests.cs プロジェクト: Vraiment/SAGESharp
        public void Test_Reading_An_Instance_Of_A_Tree_With_Nested_Lists()
        {
            uint      originalPosition1 = 26, originalPosition2 = 38;
            uint      offsetPosition1 = 20, offsetPosition2 = 30;
            IDataNode rootNode = TreeWithNestedLists.Build();

            TreeWithNestedLists.Class expected = new TreeWithNestedLists.Class
            {
                List1 = new List <TreeWithHeight1.Class>
                {
                    new TreeWithHeight1.Class
                    {
                        Int   = 1,
                        Float = 2.4f,
                        Byte  = 3
                    },
                    new TreeWithHeight1.Class
                    {
                        Int   = 4,
                        Float = 5.5f,
                        Byte  = 6
                    }
                },
                List2 = new List <TreeWithHeight2.Class>
                {
                    new TreeWithHeight2.Class
                    {
                        Long  = 7,
                        Child = new TreeWithHeight1.Class
                        {
                            Int   = 8,
                            Float = 9.6f,
                            Byte  = 10
                        }
                    },
                    new TreeWithHeight2.Class
                    {
                        Long  = 11,
                        Child = new TreeWithHeight1.Class
                        {
                            Int   = 12,
                            Float = 13.7f,
                            Byte  = 14
                        }
                    }
                }
            };

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

            SetupTreeWithNestedLists(rootNode, expected, offsetPosition1, offsetPosition2);

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

            Received.InOrder(() => VerifyReadTreeWithNestedLists(rootNode, expected, originalPosition1, originalPosition2, offsetPosition1, offsetPosition2));

            result.Should().BeEquivalentTo(expected);
        }
コード例 #3
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));
        }
コード例 #4
0
        public void Test_Writing_An_Instance_Of_A_Tree_With_Nested_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>
                {
                    new TreeWithHeight1.Class
                    {
                        Int   = 1,
                        Float = 2.4f,
                        Byte  = 3
                    },
                    new TreeWithHeight1.Class
                    {
                        Int   = 4,
                        Float = 5.5f,
                        Byte  = 6
                    }
                },
                List2 = new List <TreeWithHeight2.Class>
                {
                    new TreeWithHeight2.Class
                    {
                        Long  = 7,
                        Child = new TreeWithHeight1.Class
                        {
                            Int   = 8,
                            Float = 9.6f,
                            Byte  = 10
                        }
                    },
                    new TreeWithHeight2.Class
                    {
                        Long  = 11,
                        Child = new TreeWithHeight1.Class
                        {
                            Int   = 12,
                            Float = 13.7f,
                            Byte  = 14
                        }
                    }
                }
            };

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

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

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

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

            Received.InOrder(() => VerifyWriteTreeWithNestedLists(rootNode, value, originalPosition1, originalPosition2, offsetPosition1, offsetPosition2));
        }