Exemple #1
0
        public void UserPromptForSectionHeadWithEmptyPara()
        {
            // Set up section head with an empty paragraph
            IScrSection section = AddSectionToMockedBook(m_book);
            IStTxtPara  para    = AddSectionHeadParaToSection(section, "",
                                                              ScrStyleNames.SectionHead);

            Options.ShowEmptyParagraphPromptsSetting = true;
            int         defVernWs = Cache.DefaultVernWs;
            DummyTeStVc stVc      = new DummyTeStVc(Cache, defVernWs);

            CreateExpectedUserPrompt(stVc, para.Hvo,
                                     ScrSectionTags.kflidHeading, StTxtParaTags.kflidContents);

            bool fTextAdded = stVc.CallInsertUserPrompt(m_vwenvMock, para);

            Assert.IsTrue(fTextAdded, "User prompt not added");
            ITsString text = stVc.DisplayVariant(m_vwenvMock, SimpleRootSite.kTagUserPrompt,
                                                 ScrSectionTags.kflidHeading);

            string difference;
            bool   fEqual = TsStringHelper.TsStringsAreEqual(
                ExpectedUserPrompt("Type section head here", defVernWs),
                text, out difference);

            Assert.IsTrue(fEqual, difference);
            m_vwenvMock.VerifyAllExpectations();
        }
Exemple #2
0
        public void UpdateUserPrompt_Vern_Typing()
        {
            // Set up section head with an empty paragraph
            IScrSection section = AddSectionToMockedBook(m_book);
            IStTxtPara  para    = AddSectionHeadParaToSection(section, "",
                                                              ScrStyleNames.SectionHead);

            IVwRootBox   rootb;
            IVwSelection vwsel;
            IVwRootSite  rootsite;

            SetUpResultsForUpdateUserPromptTests(4, "t", out rootb, out vwsel, out rootsite);

            int defVernWs = Cache.DefaultVernWs;

            DummyTeStVc   stVc    = new DummyTeStVc(Cache, defVernWs, rootb);
            ITsIncStrBldr strBdlr = TsIncStrBldrClass.Create();

            strBdlr.SetIntPropValues(SimpleRootSite.ktptUserPrompt, (int)FwTextPropVar.ktpvDefault, 1);
            strBdlr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, Cache.DefaultUserWs);
            strBdlr.Append("t");
            ITsString tssTyped    = strBdlr.GetString();
            ITsString tssExpected = TsStringUtils.MakeTss("t", defVernWs);

            // Now simulate the user typing over the user prompt
            stVc.UpdateProp(vwsel, para.Hvo, SimpleRootSite.kTagUserPrompt, 0, tssTyped);

            // verify that the text is in the paragraph and that there is no longer a user prompt.
            string diff;

            Assert.IsTrue(TsStringHelper.TsStringsAreEqual(tssExpected, para.Contents, out diff), diff);

            m_vwenvMock.VerifyAllExpectations();
            VerifyArgsSentToRequestSelectionAtEndOfUow(rootsite, rootb, 0, 4, StTxtParaTags.kflidContents, "t");
        }
Exemple #3
0
        public void UserPromptForSectionHeadWithEmptyPara()
        {
            CheckDisposed();

            // Set up section head with an empty paragraph
            IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
            StTxtPara   para    = m_inMemoryCache.AddSectionHeadParaToSection(section.Hvo, "",
                                                                              ScrStyleNames.SectionHead);

            section.AdjustReferences();
            Options.ShowEmptyParagraphPromptsSetting = true;

            DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultVernWs);

            CreateExpectedUserPrompt(stVc, para.Hvo,
                                     (int)ScrSection.ScrSectionTags.kflidHeading, (int)StTxtPara.StTxtParaTags.kflidContents);

            IVwEnv vwEnv      = (IVwEnv)m_vwenvMock.MockInstance;
            bool   fTextAdded = stVc.CallInsertUserPrompt(vwEnv, para.Hvo);

            Assert.IsTrue(fTextAdded, "User prompt not added");
            ITsString text = stVc.DisplayVariant(vwEnv, SimpleRootSite.kTagUserPrompt, null,
                                                 (int)ScrSection.ScrSectionTags.kflidHeading);

            string difference;
            bool   fEqual = TsStringHelper.TsStringsAreEqual(
                ExpectedUserPrompt("Type section head here", m_inMemoryCache.Cache.DefaultVernWs),
                text, out difference);

            Assert.IsTrue(fEqual, difference);
            m_vwenvMock.Verify();
        }
Exemple #4
0
        public void UserPromptForBookTitleWithEmptyPara()
        {
            // Set up title with an empty paragraph
            IStText title = AddTitleToMockedBook(m_book, string.Empty, Cache.DefaultVernWs);

            Options.ShowEmptyParagraphPromptsSetting = true;

            int         defVernWs = Cache.DefaultVernWs;
            DummyTeStVc stVc      = new DummyTeStVc(Cache, defVernWs);

            CreateExpectedUserPrompt(stVc, title.ParagraphsOS[0].Hvo,
                                     ScrBookTags.kflidTitle, StTxtParaTags.kflidContents);

            m_vwenvMock.Stub(x => x.CurrentObject()).Return(title.ParagraphsOS[0].Hvo);
            bool fTextAdded = stVc.CallInsertUserPrompt(m_vwenvMock, title[0]);

            Assert.IsTrue(fTextAdded, "User prompt not added");
            ITsString text = stVc.DisplayVariant(m_vwenvMock, SimpleRootSite.kTagUserPrompt,
                                                 ScrBookTags.kflidTitle);

            string difference;
            bool   fEqual = TsStringHelper.TsStringsAreEqual(
                ExpectedUserPrompt("Type book title for Philemon here", defVernWs),
                text, out difference);

            Assert.IsTrue(fEqual, difference);
            m_vwenvMock.VerifyAllExpectations();
        }
Exemple #5
0
        public void UserPromptForBookTitleWithEmptyPara()
        {
            CheckDisposed();

            // Set up title with an empty paragraph
            StText title = m_inMemoryCache.AddTitleToMockedBook(m_book.Hvo, m_emptyTsString,
                                                                StyleUtils.ParaStyleTextProps(ScrStyleNames.MainBookTitle));

            Options.ShowEmptyParagraphPromptsSetting = true;

            DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultVernWs);

            CreateExpectedUserPrompt(stVc, title.ParagraphsOS.FirstItem.Hvo,
                                     (int)ScrBook.ScrBookTags.kflidTitle, (int)StTxtPara.StTxtParaTags.kflidContents);

            m_vwenvMock.ExpectAndReturn("CurrentObject", title.ParagraphsOS.FirstItem.Hvo);
            IVwEnv vwEnv      = (IVwEnv)m_vwenvMock.MockInstance;
            bool   fTextAdded = stVc.CallInsertUserPrompt(vwEnv,
                                                          title.ParagraphsOS.FirstItem.Hvo);

            Assert.IsTrue(fTextAdded, "User prompt not added");
            ITsString text = stVc.DisplayVariant(vwEnv, SimpleRootSite.kTagUserPrompt, null,
                                                 (int)ScrBook.ScrBookTags.kflidTitle);

            string difference;
            bool   fEqual = TsStringHelper.TsStringsAreEqual(
                ExpectedUserPrompt("Type book title for Philemon here", m_inMemoryCache.Cache.DefaultVernWs),
                text, out difference);

            Assert.IsTrue(fEqual, difference);
            m_vwenvMock.Verify();
        }
Exemple #6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Compares the given footnote with the values in m_footnote.
        /// </summary>
        /// <param name="footnote">The footnote to compare</param>
        /// ------------------------------------------------------------------------------------
        private void CompareFootnote(IStFootnote footnote)
        {
            Assert.AreEqual(m_footnote.MarkerType, footnote.MarkerType);
            if (footnote.MarkerType == FootnoteMarkerTypes.SymbolicFootnoteMarker)
            {
                AssertEx.AreTsStringsEqual(m_footnote.FootnoteMarker, footnote.FootnoteMarker);
            }
            Assert.AreEqual(m_footnote.ParagraphsOS.Count, footnote.ParagraphsOS.Count,
                            "Footnote paragraph count did not match");

            string diff = string.Empty;

            for (int i = 0; i < m_footnote.ParagraphsOS.Count; i++)
            {
                IStTxtPara expectedPara = (IStTxtPara)m_footnote.ParagraphsOS[i];
                IStTxtPara actualPara   = (IStTxtPara)footnote.ParagraphsOS[i];
                bool       result       = TsTextPropsHelper.PropsAreEqual(expectedPara.StyleRules,
                                                                          actualPara.StyleRules, out diff);
                Assert.IsTrue(result, "paragraph " + i + " stylerules differed in: " + diff);

                result = TsStringHelper.TsStringsAreEqual(expectedPara.Contents,
                                                          actualPara.Contents, out diff);
                Assert.IsTrue(result, "paragraph " + i + " differed in: " + diff);

                CompareFootnoteTrans(expectedPara.GetBT(), actualPara);
            }
        }
Exemple #7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Compares the given footnote with the values in m_footnote.
        /// </summary>
        /// <param name="footnote">The footnote to compare</param>
        /// ------------------------------------------------------------------------------------
        private void CompareFootnote(StFootnote footnote)
        {
            Assert.AreEqual(m_footnote.DisplayFootnoteMarker, footnote.DisplayFootnoteMarker,
                            "Display footnote marker values did not match");
            Assert.AreEqual(m_footnote.DisplayFootnoteReference, footnote.DisplayFootnoteReference,
                            "Display footnote reference values did not match");
            Assert.AreEqual(m_footnote.FootnoteMarker.Text, footnote.FootnoteMarker.Text);
            Assert.AreEqual(m_footnote.ParagraphsOS.Count, footnote.ParagraphsOS.Count,
                            "Footnote paragraph count did not match");

            string diff = string.Empty;

            for (int i = 0; i < m_footnote.ParagraphsOS.Count; i++)
            {
                StTxtPara expectedPara = (StTxtPara)m_footnote.ParagraphsOS[i];
                StTxtPara actualPara   = (StTxtPara)footnote.ParagraphsOS[i];
                bool      result       = TsTextPropsHelper.PropsAreEqual(expectedPara.StyleRules,
                                                                         actualPara.StyleRules, out diff);
                Assert.IsTrue(result, "paragraph " + i + " stylerules differed in: " + diff);

                result = TsStringHelper.TsStringsAreEqual(expectedPara.Contents.UnderlyingTsString,
                                                          actualPara.Contents.UnderlyingTsString, out diff);
                Assert.IsTrue(result, "paragraph " + i + " differed in: " + diff);

                CompareFootnoteTrans((CmTranslation)expectedPara.GetBT(), (CmTranslation)actualPara.GetBT(),
                                     actualPara.Hvo);
            }
        }
Exemple #8
0
        public void PasteIntoMultiStringFieldDoesNotFlattenWsStyle()
        {
            var args = new FwPasteFixTssEventArgs(m_tss, new TextSelInfo((IVwSelection)null));

            // Veryify that we are testing  with a field of the correct type (if this fails the model changed)
            Assert.AreEqual((int)CellarPropertyType.MultiString, Cache.MetaDataCacheAccessor.GetFieldType(LexSenseTags.kflidGeneralNote));
            //SUT
            InnerLabeledMultiStringView.EliminateExtraStyleAndWsInfo(Cache.MetaDataCacheAccessor, args, LexSenseTags.kflidGeneralNote);
            string differences;

            Assert.True(TsStringHelper.TsStringsAreEqual(m_tss, args.TsString, out differences), differences);
        }
Exemple #9
0
        public void PasteIntoMultiUnicodeFieldFlattensWsStyle()
        {
            var args = new FwPasteFixTssEventArgs(m_tss, new TextSelInfo((IVwSelection)null));

            // Veryify that we are testing  with a field of the correct type (if this fails the model changed)
            Assert.AreEqual((int)CellarPropertyType.MultiUnicode, Cache.MetaDataCacheAccessor.GetFieldType(LexEntryTags.kflidCitationForm));
            //SUT
            InnerLabeledMultiStringView.EliminateExtraStyleAndWsInfo(Cache.MetaDataCacheAccessor, args, LexEntryTags.kflidCitationForm);
            string differences;

            Assert.False(TsStringHelper.TsStringsAreEqual(m_tss, args.TsString, out differences), differences);
            Assert.That(differences, Is.StringContaining("TsStrings have different number of runs"));
        }
Exemple #10
0
        public void UserPromptChangeWSWhenTyping()
        {
            CheckDisposed();

            // Set up section head with an empty paragraph
            IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
            StTxtPara   para    = m_inMemoryCache.AddSectionHeadParaToSection(section.Hvo, "",
                                                                              ScrStyleNames.SectionHead);

            section.AdjustReferences();

            Options.ShowEmptyParagraphPromptsSetting = true;
            DynamicMock rootb = new DynamicMock(typeof(IVwRootBox));

            rootb.SetupResult("IsCompositionInProgress", false);
            DynamicMock vwsel       = new DynamicMock(typeof(IVwSelection));
            IVwRootBox  mockRootbox = (IVwRootBox)rootb.MockInstance;

            vwsel.SetupResult("RootBox", mockRootbox);
            vwsel.SetupResult("CLevels", 4, typeof(bool));
            vwsel.Ignore("AllTextSelInfo");
#if DEBUG
            vwsel.SetupResult("IsValid", true);
#endif

            DummyTeStVc   stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultAnalWs, mockRootbox);
            ITsStrFactory tsf  = TsStrFactoryClass.Create();
            ITsString     tssVal;
            tssVal = tsf.MakeString("TEST", m_inMemoryCache.Cache.DefaultVernWs);

            // Now simulate the user typing over the user prompt
            stVc.UpdateProp((IVwSelection)vwsel.MockInstance, para.Hvo, SimpleRootSite.kTagUserPrompt, 0, tssVal);

            // verify that the text is in the paragraph and that there is no longer a user prompt.
            ITsPropsBldr ttpBldr = TsPropsBldrClass.Create();
            ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                     (int)FwTextPropVar.ktpvDefault, m_inMemoryCache.Cache.DefaultAnalWs);
            ITsStrBldr bldr = TsStrBldrClass.Create();
            bldr.Replace(0, 0, "TEST", ttpBldr.GetTextProps());
            string diff;
            Assert.IsTrue(TsStringHelper.TsStringsAreEqual(bldr.GetString(),
                                                           para.Contents.UnderlyingTsString, out diff), diff);

            m_vwenvMock.Verify();
        }
Exemple #11
0
        public void UserPromptForBackTranslation()
        {
            CheckDisposed();

            // Set up a section and paragraph with text
            IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
            StTxtPara   para    = m_inMemoryCache.AddParaToMockedSectionContent(section.Hvo,
                                                                                ScrStyleNames.NormalParagraph);

            section.AdjustReferences();

            m_inMemoryCache.AddRunToMockedPara(para, "Some paragraph text.", null);

            // Add an empty translation to the paragraph
            int            wsBT  = m_inMemoryCache.Cache.DefaultAnalWs;
            ICmTranslation trans = m_inMemoryCache.AddBtToMockedParagraph(para, wsBT);

            m_inMemoryCache.AddRunToMockedTrans(trans, wsBT, string.Empty, null);

            DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultAnalWs);

            CreateExpectedUserPrompt(stVc, trans.Hvo,
                                     (int)CmTranslation.CmTranslationTags.kflidTranslation,
                                     (int)CmTranslation.CmTranslationTags.kflidTranslation);

            // verify that the prompt gets added
            IVwEnv vwEnv      = (IVwEnv)m_vwenvMock.MockInstance;
            bool   fTextAdded = stVc.CallInsertBackTranslationUserPrompt(vwEnv, trans.Hvo);

            Assert.IsTrue(fTextAdded, "User prompt not added");

            // verify the contents of the prompt
            ITsString text = stVc.DisplayVariant(vwEnv, SimpleRootSite.kTagUserPrompt, null,
                                                 (int)CmTranslation.CmTranslationTags.kflidTranslation);
            string difference;
            bool   fEqual = TsStringHelper.TsStringsAreEqual(
                ExpectedUserPrompt("Type back translation here", m_inMemoryCache.Cache.DefaultAnalWs),
                text, out difference);

            Assert.IsTrue(fEqual, difference);

            // verify the mock - is this useful?
            m_vwenvMock.Verify();
        }
Exemple #12
0
        public void UserPromptForBackTranslation()
        {
            // Set up a section and paragraph with text
            IScrSection section = AddSectionToMockedBook(m_book);
            IStTxtPara  para    = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph);

            AddRunToMockedPara(para, "Some paragraph text.", null);

            // Add an empty translation to the paragraph
            int            wsBT  = Cache.DefaultAnalWs;
            ICmTranslation trans = AddBtToMockedParagraph(para, wsBT);

            AddRunToMockedTrans(trans, wsBT, string.Empty, null);

            DummyTeStVc stVc = new DummyTeStVc(Cache, wsBT);

            CreateExpectedUserPrompt(stVc, trans.Hvo, CmTranslationTags.kflidTranslation,
                                     CmTranslationTags.kflidTranslation);

            // verify that the prompt gets added
            bool fTextAdded = stVc.CallInsertBackTranslationUserPrompt(m_vwenvMock, trans);

            Assert.IsTrue(fTextAdded, "User prompt not added");

            // verify the contents of the prompt
            ITsString text = stVc.DisplayVariant(m_vwenvMock, SimpleRootSite.kTagUserPrompt,
                                                 CmTranslationTags.kflidTranslation);
            string difference;
            bool   fEqual = TsStringHelper.TsStringsAreEqual(
                ExpectedUserPrompt("Type back translation here", wsBT),
                text, out difference);

            Assert.IsTrue(fEqual, difference);

            // verify the mock - is this useful?
            m_vwenvMock.VerifyAllExpectations();
        }