public void Match_Wildcard_Replace() { List<Run> runs = new List<Run>(); runs.Add(new Run("1aa1 2222 1aa1")); runs.Add(new Run("3333 4444")); runs.Add(new Run("5555 6666")); runs.Add(new Run("7777 8888")); runs.Add(new Run("9999 aaaa")); RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel(); model.FindOptions.UseWildcards = true; Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer container = new Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer(runs); model.Query = new Query("1*1"); model.FindText(container/*, new Query("33([0-9])3")*/); model.SelectNextMatch(); Assert.AreEqual("1aa1", model.CurrentMatch.Text); Assert.AreEqual(runs[0], model.CurrentMatch.Run); model.ReplaceMatch("abcdefg"); Assert.AreEqual("abcdefg 2222 1aa1", runs[0].Text); Assert.AreEqual(runs[0], model.CurrentMatch.Run); model.ReplaceMatch("abcdefg"); Assert.AreEqual("abcdefg 2222 abcdefg", runs[0].Text); }
public void Match_Standard_Replace() { List<Run> runs = GetTestRuns(); RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel(); Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer container = new Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer(runs); model.Query = new Query("1111"); model.FindText(container/*, new Query("33([0-9])3")*/); model.SelectNextMatch(); Assert.AreEqual(runs[0], model.CurrentMatch.Run); model.ReplaceMatch("1"); Assert.AreEqual("1 2222 1111", runs[0].Text); model.ReplaceMatch("1"); Assert.AreEqual("1 2222 1", runs[0].Text); //also need to fix single line tb when highlight goes outside of box width }
public void Match_Regex_Replace() { List<Run> runs = GetTestRuns(); RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel(); model.FindOptions.UseRegularExpressions = true; Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer container = new Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer(runs); model.Query = new Query("33([0-9])3"); model.FindText(container/*, new Query("33([0-9])3")*/); model.SelectNextMatch(); Assert.AreEqual(runs[1], model.CurrentMatch.Run); model.ReplaceMatch("xx$1"); Assert.AreEqual("xx3 4444", runs[1].Text); //also need to fix single line tb when highlight goes outside of box width }