Ejemplo n.º 1
0
        public void Find_FromMiddle()
        {
            using (var collectorEnv = new FindCollectorEnv(m_vc,
                                                           Cache.DomainDataByFlid, m_para1.Owner.Hvo, (int)StTextFrags.kfrText,
                                                           m_pattern, null))
            {
                // Start in the middle
                SelLevInfo[] levInfo = new SelLevInfo[1];
                levInfo[0].hvo = m_para2.Hvo;
                levInfo[0].tag = StTextTags.kflidParagraphs;
                m_sel          = new CollectorEnv.LocationInfo(levInfo, StTxtParaTags.kflidContents, 5);

                VerifyFindNext(collectorEnv, m_para2.Hvo, 20, 21);
                VerifyFindNext(collectorEnv, m_para2.Hvo, 27, 28);
                VerifyFindNext(collectorEnv, m_para2.Hvo, 44, 45);
                VerifyFindNext(collectorEnv, m_para2.Hvo, 52, 53);
                VerifyFindNext(collectorEnv, m_para2.Hvo, 64, 65);
                Assert.IsNull(collectorEnv.FindNext(m_sel));

                // Make sure nothing got replaced by accident.
                Assert.AreEqual("This is some text so that we can test the find functionality.",
                                m_para1.Contents.Text);
                Assert.AreEqual("Some more text so that we can test the find and replace functionality.",
                                m_para2.Contents.Text);
                Assert.AreEqual("This purugruph doesn't contuin the first letter of the ulphubet.",
                                m_para3.Contents.Text);
            }
        }
Ejemplo n.º 2
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Verifies the find next.
 /// </summary>
 /// <param name="collectorEnv">The collector env.</param>
 /// <param name="hvoExpected">The hvo expected.</param>
 /// <param name="ichMinExpected">The ich min expected.</param>
 /// <param name="ichLimExpected">The ich lim expected.</param>
 /// ------------------------------------------------------------------------------------
 private void VerifyFindNext(FindCollectorEnv collectorEnv, int hvoExpected,
                             int ichMinExpected, int ichLimExpected)
 {
     CollectorEnv.LocationInfo foundLocation = collectorEnv.FindNext(m_sel);
     Assert.IsNotNull(foundLocation);
     Assert.AreEqual(1, foundLocation.m_location.Length);
     Assert.AreEqual(hvoExpected, foundLocation.TopLevelHvo);
     Assert.AreEqual(StTextTags.kflidParagraphs, foundLocation.m_location[0].tag);
     Assert.AreEqual(StTxtParaTags.kflidContents, foundLocation.m_tag);
     Assert.AreEqual(ichMinExpected, foundLocation.m_ichMin);
     Assert.AreEqual(ichLimExpected, foundLocation.m_ichLim);
     m_sel = foundLocation;
 }