Example #1
0
        public void ReplaceButtonTest()
        {
            CheckDisposed();

            DummyFwFindReplaceDlg dlg = new DummyFwFindReplaceDlg();

            m_testTeApp.FindReplaceDialog = dlg;
            m_testTeApp.ShowFindReplaceDialog(true, m_firstDraftView);

            dlg.MatchNotFound += new FwFindReplaceDlg.MatchNotFoundHandler(FindDlgMatchNotFound);
            dlg.FindText       = MakeTSS("the");
            dlg.ReplaceText    = MakeTSS("da");

            // Initial replace finds the first occurrence of "the"
            dlg.DoReplace();
            // Second replace actually replaces it and finds the following occurrence

            dlg.DoReplace();
            Assert.AreEqual(0, m_firstDraftView.TeEditingHelper.BookIndex);
            Assert.AreEqual(3, m_firstDraftView.TeEditingHelper.SectionIndex);
            Assert.AreEqual(0, m_firstDraftView.ParagraphIndex);
            Assert.AreEqual(42, m_firstDraftView.SelectionAnchorIndex);
            // Selection is 4 chars long because it's an accented "é"
            Assert.AreEqual(46, m_firstDraftView.SelectionEndIndex);

            // Now make sure first replacement happened.
            // Set IP Back to the top of the view
            m_firstDraftView.SetInsertionPoint(0, 0, 0, 0, true);
            dlg.FindText = MakeTSS("dao");             // The original word was Théo
            dlg.FindNext();
            Assert.AreEqual(0, m_firstDraftView.TeEditingHelper.BookIndex);
            Assert.AreEqual(2, m_firstDraftView.TeEditingHelper.SectionIndex);
            Assert.AreEqual(1, m_firstDraftView.ParagraphIndex);
            Assert.AreEqual(138, m_firstDraftView.SelectionAnchorIndex);
            Assert.AreEqual(141, m_firstDraftView.SelectionEndIndex);
        }
Example #2
0
        public void ReplaceButtonInitiallyJustDoesAFind()
        {
            CheckDisposed();

            DummyFwFindReplaceDlg dlg = new DummyFwFindReplaceDlg();

            m_testTeApp.FindReplaceDialog = dlg;
            m_testTeApp.ShowFindReplaceDialog(true, m_firstDraftView);

            dlg.MatchNotFound += new FwFindReplaceDlg.MatchNotFoundHandler(FindDlgMatchNotFound);
            dlg.FindText       = MakeTSS("the");
            dlg.ReplaceText    = MakeTSS("da");

            // make sure the initial replace finds the first occurrence of "the"
            dlg.DoReplace();
            Assert.AreEqual(0, m_firstDraftView.TeEditingHelper.BookIndex);
            Assert.AreEqual(2, m_firstDraftView.TeEditingHelper.SectionIndex);
            Assert.AreEqual(1, m_firstDraftView.ParagraphIndex);
            Assert.AreEqual(138, m_firstDraftView.SelectionAnchorIndex);
            // Selection is 4 chars long because it's an accented "é"
            Assert.AreEqual(142, m_firstDraftView.SelectionEndIndex);
        }
Example #3
0
		public void ReplaceButtonTest()
		{
			CheckDisposed();

			DummyFwFindReplaceDlg dlg = new DummyFwFindReplaceDlg();
			m_testTeApp.FindReplaceDialog = dlg;
			m_testTeApp.ShowFindReplaceDialog(true, m_firstDraftView);

			dlg.MatchNotFound += new FwFindReplaceDlg.MatchNotFoundHandler(FindDlgMatchNotFound);
			dlg.FindText = MakeTSS("the");
			dlg.ReplaceText = MakeTSS("da");

			// Initial replace finds the first occurrence of "the"
			dlg.DoReplace();
			// Second replace actually replaces it and finds the following occurrence

			dlg.DoReplace();
			Assert.AreEqual(0, m_firstDraftView.TeEditingHelper.BookIndex);
			Assert.AreEqual(3, m_firstDraftView.TeEditingHelper.SectionIndex);
			Assert.AreEqual(0, m_firstDraftView.ParagraphIndex);
			Assert.AreEqual(42, m_firstDraftView.SelectionAnchorIndex);
			// Selection is 4 chars long because it's an accented "é"
			Assert.AreEqual(46, m_firstDraftView.SelectionEndIndex);

			// Now make sure first replacement happened.
			// Set IP Back to the top of the view
			m_firstDraftView.SetInsertionPoint(0, 0, 0, 0, true);
			dlg.FindText = MakeTSS("dao"); // The original word was Théo
			dlg.FindNext();
			Assert.AreEqual(0, m_firstDraftView.TeEditingHelper.BookIndex);
			Assert.AreEqual(2, m_firstDraftView.TeEditingHelper.SectionIndex);
			Assert.AreEqual(1, m_firstDraftView.ParagraphIndex);
			Assert.AreEqual(138, m_firstDraftView.SelectionAnchorIndex);
			Assert.AreEqual(141, m_firstDraftView.SelectionEndIndex);
		}
Example #4
0
		public void ReplaceButtonInitiallyJustDoesAFind()
		{
			CheckDisposed();

			DummyFwFindReplaceDlg dlg = new DummyFwFindReplaceDlg();
			m_testTeApp.FindReplaceDialog = dlg;
			m_testTeApp.ShowFindReplaceDialog(true, m_firstDraftView);

			dlg.MatchNotFound += new FwFindReplaceDlg.MatchNotFoundHandler(FindDlgMatchNotFound);
			dlg.FindText = MakeTSS("the");
			dlg.ReplaceText = MakeTSS("da");

			// make sure the initial replace finds the first occurrence of "the"
			dlg.DoReplace();
			Assert.AreEqual(0, m_firstDraftView.TeEditingHelper.BookIndex);
			Assert.AreEqual(2, m_firstDraftView.TeEditingHelper.SectionIndex);
			Assert.AreEqual(1, m_firstDraftView.ParagraphIndex);
			Assert.AreEqual(138, m_firstDraftView.SelectionAnchorIndex);
			// Selection is 4 chars long because it's an accented "é"
			Assert.AreEqual(142, m_firstDraftView.SelectionEndIndex);
		}