Exemplo n.º 1
0
        public void SizeOfSuperNodeWhenMixingContainingNodes()
        {
            var sn = SuperNodeTestFactory.CreateWithChildren(Count, f => new Node(f));

            sn.Nodes.Add(SuperNodeTestFactory.CreateWithChildren(Count, f => new Node(f)));
            Assert.Equal(Count + Count, sn.Size);
        }
Exemplo n.º 2
0
        public void InflatePartitionWithSuperNodes()
        {
            var p = CreatePartitionWithChildren(count, _ => SuperNodeTestFactory.CreateWithChildren(count, f => EntityHelper.CreateNode()));
            var n = p.Nodes;

            p.Inflate();

            Assert.NotSame(n, p.Nodes);
            Assert.Equal(count * count, p.Nodes.Count);
        }
Exemplo n.º 3
0
        public void InflatePartitionWithMixedNodes()
        {
            var p = CreatePartitionWithChildren(count, _ => SuperNodeTestFactory.CreateWithChildren(count, f => EntityHelper.CreateNode()));

            for (int i = 0; i < count; i++)
            {
                p.Nodes.Add(EntityHelper.CreateNode());
            }
            var n = p.Nodes;

            p.Inflate();

            Assert.Equal(count * count + count, p.Nodes.Count);
        }
Exemplo n.º 4
0
        public void PartitionWhenFirstNodeIsTooBig()
        {
            const int    nodeCount      = 75;
            const int    innerNodeCount = 50;
            List <INode> nodes          = new List <INode>();

            for (int i = 0; i < nodeCount - 1; i++)
            {
                nodes.Add(SuperNodeTestFactory.CreateWithChildren(innerNodeCount, f => EntityHelper.CreateNode()));
            }

            nodes.Insert(0, SuperNodeTestFactory.CreateWithChildren(150, _ => EntityHelper.CreateNode()));

            var ps = partitioner.Partition(nodes);

            Assert.NotEmpty(ps.First().Nodes);
        }
Exemplo n.º 5
0
        public void PartitionSuperNodes()
        {
            const int    nodeCount      = 75;
            const int    innerNodeCount = 50;
            List <INode> nodes          = new List <INode>();

            for (int i = 0; i < nodeCount; i++)
            {
                nodes.Add(SuperNodeTestFactory.CreateWithChildren(innerNodeCount, f => EntityHelper.CreateNode()));
            }

            var ps       = partitioner.Partition(nodes);
            var expected = (int)Math.Ceiling(nodes.Sum(n => ((SuperNode)n).Size) / (double)numberOfNodesInPartition);

            Assert.Equal(expected, ps.Count());
            Assert.True(ps.All(p => p.Nodes.Count == 2));
        }
Exemplo n.º 6
0
        public void SizeOfSuperNodeWhenContainingOtherSuperNodes()
        {
            var sn = SuperNodeTestFactory.CreateWithChildren(Count, _ => { return(SuperNodeTestFactory.CreateWithChildren(Count, a => new Node(a))); });

            Assert.Equal(Count * Count, sn.Size);
        }
Exemplo n.º 7
0
        public void SizeOfSuperNodeWithOnlyNormalNodes()
        {
            var sn = SuperNodeTestFactory.CreateWithChildren(Count, f => new Node(f));

            Assert.Equal(Count, sn.Size);
        }