public void SplitAtColisions_ColisisionStartSingleTest()
        {
            var vNode = new VNode("a", "", 0, 10,
                                  new VNode[] { new VNode("b", "0123456789", 0, 10) },
                                  new VNode[]
            {
                new VNode("c", "", 5, 5)
            });

            VNodeColisionResolver.SplitAtColisions(vNode);

            Assert.AreEqual(2, vNode.VLayers.Count);
            var l0VNodes = vNode.VLayers[0].Content;

            Assert.AreEqual(2, l0VNodes.Count);

            Assert.AreEqual("b", l0VNodes[0].Tag);
            Assert.AreEqual(0, l0VNodes[0].Index);
            Assert.AreEqual(5, l0VNodes[0].Length);
            Assert.AreEqual("01234", l0VNodes[0].Text);

            Assert.AreEqual("b", l0VNodes[1].Tag);
            Assert.AreEqual(5, l0VNodes[1].Index);
            Assert.AreEqual(5, l0VNodes[1].Length);
            Assert.AreEqual("56789", l0VNodes[1].Text);
        }
        public void SplitAtColisions_ColisionStartEndMultipleTest()
        {
            var vNode = new VNode("a", "", 0, 14,
                                  new VNode[] {
                new VNode("b", "0123456", 0, 7),
                new VNode("b", "0123456", 7, 7)
            },
                                  new VNode[]
            {
                new VNode("c", "", 4, 6),
            }
                                  );

            VNodeColisionResolver.SplitAtColisions(vNode);

            Assert.AreEqual(2, vNode.VLayers.Count);
            var l0VNodes = vNode.VLayers[0].Content;
            var l1VNodes = vNode.VLayers[1].Content;

            Assert.AreEqual(4, l0VNodes.Count);
            var b0 = l0VNodes[0];
            var b1 = l0VNodes[1];
            var b2 = l0VNodes[2];
            var b3 = l0VNodes[3];

            Assert.AreEqual("b", b0.Tag);
            Assert.AreEqual(0, b0.Index);
            Assert.AreEqual(4, b0.Length);
            Assert.AreEqual("0123", b0.Text);

            Assert.AreEqual("b", b1.Tag);
            Assert.AreEqual(4, b1.Index);
            Assert.AreEqual(3, b1.Length);
            Assert.AreEqual("456", b1.Text);

            Assert.AreEqual("b", b2.Tag);
            Assert.AreEqual(7, b2.Index);
            Assert.AreEqual(3, b2.Length);
            Assert.AreEqual("012", b2.Text);

            Assert.AreEqual("b", b3.Tag);
            Assert.AreEqual(10, b3.Index);
            Assert.AreEqual(4, b3.Length);
            Assert.AreEqual("3456", b3.Text);

            Assert.AreEqual(1, l1VNodes.Count);
            var c0 = l1VNodes[0];

            Assert.AreEqual("c", c0.Tag);
            Assert.AreEqual(4, c0.Index);
            Assert.AreEqual(6, c0.Length);
            Assert.AreEqual("", c0.Text);
        }
        public void SplitAtColisions_Recusive2Test()
        {
            var vNode = new VNode("a", "", 0, 9,
                                  new VNode("b", "", 0, 9,
                                            new VNode[] {
                new VNode("c", "0123245678", 0, 9),
            },
                                            new VNode[]
            {
                new VNode("d", "", 3, 3),
            }
                                            ),
                                  new VNode("b", "", 9, 9,
                                            new VNode[] {
                new VNode("c", "0123245678", 0, 9),
            },
                                            new VNode[]
            {
                new VNode("d", "", 3, 3),
            }
                                            )
                                  );

            VNodeColisionResolver.SplitAtColisions(vNode);

            var aLayers = vNode.VLayers;

            Assert.AreEqual(1, aLayers.Count);

            var bNodes = aLayers[0].Content;

            Assert.AreEqual(2, bNodes.Count);

            var b0 = bNodes[0];

            Assert.AreEqual("b", b0.Tag);
            Assert.AreEqual(0, b0.Index);
            Assert.AreEqual(9, b0.Length);
            Assert.AreEqual("", b0.Text);
            Assert.AreEqual(3, b0.VLayers[0].Content.Count);

            var b1 = bNodes[1];

            Assert.AreEqual("b", b1.Tag);
            Assert.AreEqual(9, b1.Index);
            Assert.AreEqual(9, b1.Length);
            Assert.AreEqual("", b1.Text);
            Assert.AreEqual(3, b1.VLayers[0].Content.Count);
        }
        public void SplitAtColisions_Recusive1Test()
        {
            var vNode = new VNode("a", "", 0, 15,
                                  new VNode("b", "", 0, 10,
                                            new VNode[] {
                new VNode("c", "01232456789", 0, 10),
            },
                                            new VNode[]
            {
                new VNode("d", "", 0, 5),
            }
                                            ),
                                  new VNode("b", "01234", 10, 5)
                                  );

            VNodeColisionResolver.SplitAtColisions(vNode);

            var aLayers = vNode.VLayers;

            Assert.AreEqual(1, aLayers.Count);

            var bNodes = aLayers[0].Content;

            Assert.AreEqual(2, bNodes.Count);

            // Untouched
            var b0 = bNodes[0];

            Assert.AreEqual("b", b0.Tag);
            Assert.AreEqual(0, b0.Index);
            Assert.AreEqual(10, b0.Length);
            Assert.AreEqual("", b0.Text);

            var b0Layers = b0.VLayers;

            Assert.AreEqual(2, b0Layers.Count);

            var b0L0 = b0Layers[0];

            Assert.AreEqual(2, b0L0.Content.Count);

            var b1 = bNodes[1];

            Assert.AreEqual("b", b1.Tag);
            Assert.AreEqual(10, b1.Index);
            Assert.AreEqual(5, b1.Length);
            Assert.AreEqual("01234", b1.Text);
        }
        public void SplitAtColisions_Cake1Test()
        {
            var vNode = new VNode("a", "", 0, 16,
                                  new VNode[] { new VNode("b", new string('x', 16), 0, 16), },
                                  new VNode[] { new VNode("c", "", 4, 8), },
                                  new VNode[] { new VNode("d", "", 6, 4), }
                                  );

            VNodeColisionResolver.SplitAtColisions(vNode);

            var layers = vNode.VLayers;

            Assert.AreEqual(3, layers.Count);
            AssertLayerNodeRanges(layers[2], (6, 10));
            AssertLayerNodeRanges(layers[1], (4, 6), (6, 10), (10, 12));
            AssertLayerNodeRanges(layers[0], (0, 4), (4, 6), (6, 10), (10, 12), (12, 16));
        }
        public void SplitAtColisions_ColisisionStartEndSingleTest()
        {
            var vNode = new VNode("a", "", 0, 15,
                                  new VNode[] { new VNode("b", "0123456789abcde", 0, 15) },
                                  new VNode[]
            {
                new VNode("c", "", 5, 5)
            });

            VNodeColisionResolver.SplitAtColisions(vNode);

            Assert.AreEqual(2, vNode.VLayers.Count);
            var l0VNodes = vNode.VLayers[0].Content;
            var l1VNodes = vNode.VLayers[1].Content;

            Assert.AreEqual(3, l0VNodes.Count);
            var b0 = l0VNodes[0];
            var b1 = l0VNodes[1];
            var b2 = l0VNodes[2];

            Assert.AreEqual("b", b0.Tag);
            Assert.AreEqual(0, b0.Index);
            Assert.AreEqual(5, b0.Length);
            Assert.AreEqual("01234", b0.Text);

            Assert.AreEqual("b", b1.Tag);
            Assert.AreEqual(5, b1.Index);
            Assert.AreEqual(5, b1.Length);
            Assert.AreEqual("56789", b1.Text);

            Assert.AreEqual("b", b2.Tag);
            Assert.AreEqual(10, b2.Index);
            Assert.AreEqual(5, b2.Length);
            Assert.AreEqual("abcde", b2.Text);

            Assert.AreEqual(1, l1VNodes.Count);
            var c0 = l1VNodes[0];

            Assert.AreEqual("c", c0.Tag);
            Assert.AreEqual(5, c0.Index);
            Assert.AreEqual(5, c0.Length);
            Assert.AreEqual("", c0.Text);
        }
        public void SplitAtColisions_Cake2Test()
        {
            var vNode = new VNode("a", "", 0, 16,
                                  new VNode[] { new VNode("b", new string('x', 16), 0, 16), },
                                  new VNode[] { new VNode("c", "", 2, 5), new VNode("c", "", 9, 5) },
                                  new VNode[] { new VNode("d", "", 4, 8), },
                                  new VNode[] { new VNode("d", "", 7, 2), }
                                  );

            VNodeColisionResolver.SplitAtColisions(vNode);

            var layers = vNode.VLayers;

            Assert.AreEqual(4, layers.Count);
            AssertLayerNodeRanges(layers[3], (7, 9));
            AssertLayerNodeRanges(layers[2], (4, 7), (7, 9), (9, 12));
            AssertLayerNodeRanges(layers[1], (2, 4), (4, 7), (9, 12), (12, 14));
            AssertLayerNodeRanges(layers[0], (0, 2), (2, 4), (4, 7), (7, 9), (9, 12), (12, 14), (14, 16));
        }