Ejemplo n.º 1
0
 public void AnchorsSurviveDeletion()
 {
     document.Text = new string(' ', 10);
     TextAnchor[] a1 = new TextAnchor[11];
     TextAnchor[] a2 = new TextAnchor[11];
     for (int i = 0; i < 11; i++)
     {
         //Console.WriteLine("Insert first at i = " + i);
         a1[i] = document.CreateAnchor(i);
         a1[i].SurviveDeletion = true;
         //Console.WriteLine(document.GetTextAnchorTreeAsString());
         //Console.WriteLine("Insert second at i = " + i);
         a2[i] = document.CreateAnchor(i);
         a2[i].SurviveDeletion = false;
         //Console.WriteLine(document.GetTextAnchorTreeAsString());
     }
     for (int i = 0; i < 11; i++)
     {
         Assert.AreEqual(i, a1[i].Offset);
         Assert.AreEqual(i, a2[i].Offset);
     }
     document.Remove(1, 8);
     for (int i = 0; i < 11; i++)
     {
         if (i <= 1)
         {
             Assert.IsFalse(a1[i].IsDeleted);
             Assert.IsFalse(a2[i].IsDeleted);
             Assert.AreEqual(i, a1[i].Offset);
             Assert.AreEqual(i, a2[i].Offset);
         }
         else if (i <= 8)
         {
             Assert.IsFalse(a1[i].IsDeleted);
             Assert.IsTrue(a2[i].IsDeleted);
             Assert.AreEqual(1, a1[i].Offset);
         }
         else
         {
             Assert.IsFalse(a1[i].IsDeleted);
             Assert.IsFalse(a2[i].IsDeleted);
             Assert.AreEqual(i - 8, a1[i].Offset);
             Assert.AreEqual(i - 8, a2[i].Offset);
         }
     }
 }
Ejemplo n.º 2
0
        public void RemoveInCollapsedSection()
        {
            CollapsedLineSection sec1 = heightTree.CollapseText(document.GetLineByNumber(3), document.GetLineByNumber(7));
            int line4Offset           = document.GetLineByNumber(4).Offset;
            int line6Offset           = document.GetLineByNumber(6).Offset;

            document.Remove(line4Offset, line6Offset - line4Offset);
            for (int i = 1; i < 3; i++)
            {
                Assert.IsFalse(heightTree.GetIsCollapsed(i));
            }
            for (int i = 3; i <= 5; i++)
            {
                Assert.IsTrue(heightTree.GetIsCollapsed(i));
            }
            for (int i = 6; i <= 8; i++)
            {
                Assert.IsFalse(heightTree.GetIsCollapsed(i));
            }
            CheckHeights();
        }
Ejemplo n.º 3
0
 public void TestLinesRemoved()
 {
     document.Remove(5, 4);
     CheckHeights();
 }
Ejemplo n.º 4
0
        public void LineIndexOfTest()
        {
            DocumentLine line = document.GetLineByNumber(1);

            Assert.AreEqual(0, document.Lines.IndexOf(line));
            DocumentLine lineFromOtherDocument = new TextDocument().GetLineByNumber(1);

            Assert.AreEqual(-1, document.Lines.IndexOf(lineFromOtherDocument));
            document.Text = "a\nb\nc";
            DocumentLine middleLine = document.GetLineByNumber(2);

            Assert.AreEqual(1, document.Lines.IndexOf(middleLine));
            document.Remove(1, 3);
            Assert.IsTrue(middleLine.IsDeleted);
            Assert.AreEqual(-1, document.Lines.IndexOf(middleLine));
        }