Exemplo n.º 1
0
        public void OptionFlipping()
        {
            RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel();

            model.Query = new Query("some more");
            model.FindOptions.IgnoreWhitespaceCharacters = false;
            List <Run> runs = new List <Run>();

            runs.Add(new Run("some more"));
            Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer container = new Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer(runs);

            model.FindText(container);
            model.SelectNextMatch();
            Assert.AreEqual(model.CurrentMatch.AbsoluteEnd, 9);
            Assert.AreEqual(model.CurrentMatch.AbsoluteStart, 0);



            model.FindOptions.IgnoreWhitespaceCharacters = true;
            model.FindOptions.IgnoreWhitespaceCharacters = false;

            model.Query.QueryText = "some more ";
            model.FindText(container);
            model.SelectNextMatch();


            model.Query.QueryText = "some more";
            model.FindText(container);
            model.SelectNextMatch();
            Assert.AreEqual(model.CurrentMatch.AbsoluteEnd, 9);
            Assert.AreEqual(model.CurrentMatch.AbsoluteStart, 0);
        }
Exemplo n.º 2
0
        public void Match_Wildcard_Replace2()
        {
            List <Run> runs = new List <Run>();

            runs.Add(new Run("TextBox search word"));
            runs.Add(new Run("TextBox"));
            runs.Add(new Run("TextBox"));
            runs.Add(new Run("Hello"));
            runs.Add(new Run("here is some more"));
            runs.Add(new Run("and some more"));

            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("r*");
            model.FindText(container);


            model.SelectNextMatch();
            Assert.AreEqual("r", model.CurrentMatch.Text);
            Assert.AreEqual(runs[0], model.CurrentMatch.Run);
            //model.ReplaceMatch("   ");
            model.ReplaceAllMatches("   ");

            Assert.AreEqual("TextBox sea   ch wo   d", runs[0].Text);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public void Match_ReplaceAll()
        {
            List <Run> runs = new List <Run>();

            runs.Add(new Run("aa aa aa"));

            RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel();

            Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer container = new Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer(runs);
            container.IterationStartIndex = 3;// runs[0].Text.Length - 1;
            model.Query = new Query("aa");
            model.FindText(container /*, new Query("33([0-9])3")*/);

            model.ReplaceAllMatches("bb");


            Assert.AreEqual("bb bb bb", runs[0].Text);
        }
Exemplo n.º 5
0
        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
        }
Exemplo n.º 6
0
        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
        }
Exemplo n.º 7
0
        public void OptionFlipping()
        {
            RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel();
            model.Query = new Query("some more");
            model.FindOptions.IgnoreWhitespaceCharacters = false;
            List<Run> runs = new List<Run>();
            runs.Add(new Run("some more"));
            Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer container = new Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer(runs);

            model.FindText(container);
            model.SelectNextMatch();
            Assert.AreEqual(model.CurrentMatch.AbsoluteEnd, 9);
            Assert.AreEqual(model.CurrentMatch.AbsoluteStart, 0);



            model.FindOptions.IgnoreWhitespaceCharacters = true;
            model.FindOptions.IgnoreWhitespaceCharacters = false;

            model.Query.QueryText = "some more ";
            model.FindText(container);
            model.SelectNextMatch();


            model.Query.QueryText = "some more";
            model.FindText(container);
            model.SelectNextMatch();
            Assert.AreEqual(model.CurrentMatch.AbsoluteEnd, 9);
            Assert.AreEqual(model.CurrentMatch.AbsoluteStart, 0);

        }
Exemplo n.º 8
0
        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
        }
Exemplo n.º 9
0
        public void Match_Wildcard_Replace2()
        {
            List<Run> runs = new List<Run>();
            runs.Add(new Run("TextBox search word"));
            runs.Add(new Run("TextBox"));
            runs.Add(new Run("TextBox"));
            runs.Add(new Run("Hello"));
            runs.Add(new Run("here is some more"));
            runs.Add(new Run("and some more"));

            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("r*");
            model.FindText(container);


            model.SelectNextMatch();
            Assert.AreEqual("r", model.CurrentMatch.Text);
            Assert.AreEqual(runs[0], model.CurrentMatch.Run);
            //model.ReplaceMatch("   ");
            model.ReplaceAllMatches("   ");

            Assert.AreEqual("TextBox sea   ch wo   d", runs[0].Text);


           


        }
Exemplo n.º 10
0
        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);

            
        }
Exemplo n.º 11
0
        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
        }
Exemplo n.º 12
0
        public void Match_ReplaceAll()
        {
            List<Run> runs = new List<Run>();
            runs.Add(new Run("aa aa aa"));

            RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel();
            Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer container = new Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer(runs);
            container.IterationStartIndex = 3;// runs[0].Text.Length - 1;
            model.Query = new Query("aa");
            model.FindText(container/*, new Query("33([0-9])3")*/);

            model.ReplaceAllMatches("bb");


            Assert.AreEqual("bb bb bb", runs[0].Text);
        }