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

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

            section.AdjustReferences();

            // 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);

            m_vwenvMock.ExpectNoCall("NoteDependency", new string[] { typeof(int[]).FullName,
                                                                      typeof(int[]).FullName, typeInt });
            m_vwenvMock.ExpectNoCall("AddProp", new string[] { typeInt,
                                                               typeof(IVwViewConstructor).FullName, typeInt });

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

            Assert.IsFalse(fTextAdded, "User prompt was added and should not have been");

            // verify the mock
            m_vwenvMock.Verify();
        }
Example #2
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();
        }
Example #3
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();
        }
Example #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();
        }
Example #5
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");
        }
Example #6
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();
        }
Example #7
0
        public void MakeDispPropOverrides_invalidValues_ReversedMinLim()
        {
            IStText text = AddTitleToMockedBook(m_book, "Title text");

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

            Assert.AreEqual(0, stVc.PropOverrides.Count);
            stVc.CallMakeDispPropOverrides((IScrTxtPara)text[0], 8, 2,
                                           delegate(ref DispPropOverride prop)
            {
                // Nothing to do
            });
        }
Example #8
0
        public void UserPromptChangeWSWhenPasting()
        {
            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);

            // set up the text to paste - will be TE2ST with vernacular WS
            int             ws       = m_inMemoryCache.Cache.DefaultVernWs;
            ITsPropsFactory propFact = TsPropsFactoryClass.Create();
            ITsTextProps    ttp      = propFact.MakeProps(null, ws, 0);
            ITsStrBldr      bldr     = TsStrBldrClass.Create();
            bldr.ReplaceRgch(0, 0, "TEST", 4, ttp);
            ttp = propFact.MakeProps(ScrStyleNames.VerseNumber, ws, 0);
            bldr.ReplaceRgch(2, 2, "2", 1, ttp);
            ITsString tssVal = bldr.GetString();

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

            // verify that the text is in the paragraph, that there is no longer a user
            // prompt, and that the ws changed but the character formatting survives.
            bldr = tssVal.GetBldr();
            bldr.SetIntPropValues(0, 5, (int)FwTextPropType.ktptWs,
                                  (int)FwTextPropVar.ktpvDefault, m_inMemoryCache.Cache.DefaultAnalWs);
            AssertEx.AreTsStringsEqual(bldr.GetString(), para.Contents.UnderlyingTsString);

            m_vwenvMock.Verify();
        }
Example #9
0
        public void UserPromptForSectionHeadWithEmptyPara_NoOption()
        {
            // Set up section head with an empty paragraph
            IScrSection section = AddSectionToMockedBook(m_book);
            IStTxtPara  para    = AddSectionHeadParaToSection(section, "", ScrStyleNames.SectionHead);

            Options.ShowEmptyParagraphPromptsSetting = false;

            DummyTeStVc stVc       = new DummyTeStVc(Cache, Cache.DefaultVernWs);
            bool        fTextAdded = stVc.CallInsertUserPrompt(m_vwenvMock, para);

            Assert.IsFalse(fTextAdded, "User prompt added");
            m_vwenvMock.VerifyAllExpectations();
        }
Example #10
0
        public void MakeDispPropOverrides_invalidValues_BeyondParaBounds2()
        {
            IStText text = AddTitleToMockedBook(m_book, "Title text");

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

            Assert.AreEqual(0, stVc.PropOverrides.Count);
            stVc.CallMakeDispPropOverrides((IScrTxtPara)text[0], 11, 11,
                                           delegate(ref DispPropOverride prop)
            {
                // Nothing to do
            });
            Assert.AreEqual(1, stVc.PropOverrides.Count);
            Assert.AreEqual(10, stVc.PropOverrides[0].ichMin);
            Assert.AreEqual(10, stVc.PropOverrides[0].ichLim);
        }
Example #11
0
        public void NoUserPromptForContentPara()
        {
            // Set up empty content paragraph
            IScrSection section = AddSectionToMockedBook(m_book);
            IStTxtPara  para    = AddParaToMockedSectionContent(section,
                                                                ScrStyleNames.NormalParagraph);

            DummyTeStVc stVc       = new DummyTeStVc(Cache, Cache.DefaultVernWs);
            bool        fTextAdded = stVc.CallInsertUserPrompt(m_vwenvMock, para);

            Assert.IsFalse(fTextAdded, "User prompt was added to empty content para");

            m_vwenvMock.AssertWasNotCalled(x => x.NoteDependency(Arg <int[]> .Is.Anything, Arg <int[]> .Is.Anything, Arg <int> .Is.Anything));
            m_vwenvMock.AssertWasNotCalled(x => x.AddProp(Arg <int> .Is.Anything, Arg <IVwViewConstructor> .Is.Anything, Arg <int> .Is.Anything));
            m_vwenvMock.VerifyAllExpectations();
        }
Example #12
0
        public void MakeDispPropOverrides_invalidValues_BeyondParaBounds()
        {
            IStText text = m_inMemoryCache.AddTitleToMockedBook(m_book.Hvo, "Title text");

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

            Assert.AreEqual(0, stVc.PropOverrides.Count);
            stVc.CallMakeDispPropOverrides((StTxtPara)text.ParagraphsOS[0], -1, 11,
                                           delegate(ref DispPropOverride prop)
            {
                // Nothing to do
            });
            Assert.AreEqual(1, stVc.PropOverrides.Count);
            Assert.AreEqual(0, stVc.PropOverrides[0].ichMin);
            Assert.AreEqual(10, stVc.PropOverrides[0].ichLim);
        }
Example #13
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();
        }
Example #14
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();
        }
Example #15
0
        public void UserPromptForSectionHeadWithEmptyPara_NoOption()
        {
            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 = false;

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

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

            Assert.IsFalse(fTextAdded, "User prompt added");
            m_vwenvMock.Verify();
        }
Example #16
0
        public void NoUserPromptForBTWithEmptyPara()
        {
            // Set up a section and empty paragraph
            IScrSection section = AddSectionToMockedBook(m_book);
            IStTxtPara  para    = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph);

            // 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);
            // verify that the prompt does not get added
            bool fTextAdded = stVc.CallInsertBackTranslationUserPrompt(m_vwenvMock, trans);

            Assert.IsFalse(fTextAdded, "User prompt was added and should not have been");

            m_vwenvMock.AssertWasNotCalled(x => x.NoteDependency(Arg <int[]> .Is.Anything, Arg <int[]> .Is.Anything, Arg <int> .Is.Anything));
            m_vwenvMock.AssertWasNotCalled(x => x.AddProp(Arg <int> .Is.Anything, Arg <IVwViewConstructor> .Is.Anything, Arg <int> .Is.Anything));
            m_vwenvMock.VerifyAllExpectations();
        }
Example #17
0
        public void NoUserPromptForContentPara()
        {
            CheckDisposed();

            // Set up empty content paragraph
            IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
            StTxtPara   para    = m_inMemoryCache.AddParaToMockedSectionContent(section.Hvo,
                                                                                ScrStyleNames.NormalParagraph);

            section.AdjustReferences();

            m_vwenvMock.ExpectNoCall("NoteDependency", new string[] { typeof(int[]).FullName,
                                                                      typeof(int[]).FullName, typeInt });
            m_vwenvMock.ExpectNoCall("AddProp", new string[] { typeInt,
                                                               typeof(IVwViewConstructor).FullName, typeInt });

            DummyTeStVc stVc       = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultVernWs);
            bool        fTextAdded = stVc.CallInsertUserPrompt((IVwEnv)m_vwenvMock.MockInstance,
                                                               para.Hvo);

            Assert.IsFalse(fTextAdded, "User prompt was added to empty content para");
            m_vwenvMock.Verify();
        }
Example #18
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();
        }
Example #19
0
        public void UpdateUserPrompt_NormalBT_Pasting()
        {
            // Set up section head with an empty paragraph
            IScrSection section = AddSectionToMockedBook(m_book);
            IStTxtPara  para    = AddSectionHeadParaToSection(section, "", ScrStyleNames.SectionHead);

            int          defAnalWs = Cache.DefaultAnalWs;
            IVwRootBox   rootb;
            IVwSelection vwsel;
            IVwRootSite  rootsite;

            SetUpResultsForUpdateUserPromptTests(5, "TE2ST", out rootb, out vwsel, out rootsite);

            DummyTeStVc stVc = new DummyTeStVc(Cache, defAnalWs, rootb);
            // set up the text to paste - will be TE2ST with vernacular WS
            ITsPropsFactory propFact = TsPropsFactoryClass.Create();
            ITsTextProps    ttp      = propFact.MakeProps(null, defAnalWs, 0);

            ITsStrBldr bldr = TsStrBldrClass.Create();

            bldr.ReplaceRgch(0, 0, "TEST", 4, ttp);
            ttp = propFact.MakeProps(ScrStyleNames.VerseNumber, defAnalWs, 0);
            bldr.ReplaceRgch(2, 2, "2", 1, ttp);
            ITsString tssPasted = bldr.GetString();

            // Now simulate the user pasting over the user prompt
            ICmTranslation bt = para.GetOrCreateBT();

            stVc.UpdateProp(vwsel, bt.Hvo, SimpleRootSite.kTagUserPrompt, CmTranslationTags.kflidTranslation, tssPasted);

            // Verify that the text is in the paragraph and that the character formatting survives.
            AssertEx.AreTsStringsEqual(tssPasted, bt.Translation.get_String(defAnalWs));

            m_vwenvMock.VerifyAllExpectations();
            VerifyArgsSentToRequestSelectionAtEndOfUow(rootsite, rootb, defAnalWs, 5, CmTranslationTags.kflidTranslation, "TE2ST");
        }
Example #20
0
        public void NoUserPromptForBTWithText()
        {
            // 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 a translation to the paragraph. The mock for the AltString provides text by default.
            int            wsBT  = Cache.DefaultAnalWs;
            ICmTranslation trans = AddBtToMockedParagraph(para, wsBT);

            AddRunToMockedTrans(trans, wsBT, "this is text in the BT", null);

            DummyTeStVc stVc = new DummyTeStVc(Cache, wsBT);
            // verify that the prompt does not get added
            bool fTextAdded = stVc.CallInsertBackTranslationUserPrompt(m_vwenvMock, trans);

            Assert.IsFalse(fTextAdded, "User prompt added when it should not have been");

            m_vwenvMock.AssertWasNotCalled(x => x.NoteDependency(Arg <int[]> .Is.Anything, Arg <int[]> .Is.Anything, Arg <int> .Is.Anything));
            m_vwenvMock.AssertWasNotCalled(x => x.AddProp(Arg <int> .Is.Anything, Arg <IVwViewConstructor> .Is.Anything, Arg <int> .Is.Anything));
            m_vwenvMock.VerifyAllExpectations();
        }
Example #21
0
		public void UpdateUserPrompt_NormalBT_Pasting()
		{
			// Set up section head with an empty paragraph
			IScrSection section = AddSectionToMockedBook(m_book);
			IStTxtPara para = AddSectionHeadParaToSection(section, "", ScrStyleNames.SectionHead);

			int defAnalWs = Cache.DefaultAnalWs;
			IVwRootBox rootb;
			IVwSelection vwsel;
			IVwRootSite rootsite;
			SetUpResultsForUpdateUserPromptTests(5,	"TE2ST", out rootb, out vwsel, out rootsite);

			DummyTeStVc stVc = new DummyTeStVc(Cache, defAnalWs, rootb);
				// set up the text to paste - will be TE2ST with vernacular WS
				ITsPropsFactory propFact = TsPropsFactoryClass.Create();
				ITsTextProps ttp = propFact.MakeProps(null, defAnalWs, 0);

				ITsStrBldr bldr = TsStrBldrClass.Create();
				bldr.ReplaceRgch(0, 0, "TEST", 4, ttp);
				ttp = propFact.MakeProps(ScrStyleNames.VerseNumber, defAnalWs, 0);
				bldr.ReplaceRgch(2, 2, "2", 1, ttp);
				ITsString tssPasted = bldr.GetString();

				// Now simulate the user pasting over the user prompt
				ICmTranslation bt = para.GetOrCreateBT();
				stVc.UpdateProp(vwsel, bt.Hvo, SimpleRootSite.kTagUserPrompt, CmTranslationTags.kflidTranslation, tssPasted);

				// Verify that the text is in the paragraph and that the character formatting survives.
				AssertEx.AreTsStringsEqual(tssPasted, bt.Translation.get_String(defAnalWs));

				m_vwenvMock.VerifyAllExpectations();
				VerifyArgsSentToRequestSelectionAtEndOfUow(rootsite, rootb, defAnalWs, 5, CmTranslationTags.kflidTranslation, "TE2ST");
			}
Example #22
0
		public void UserPromptForSectionHeadWithEmptyPara_NoOption()
		{
			// Set up section head with an empty paragraph
			IScrSection section = AddSectionToMockedBook(m_book);
			IStTxtPara para = AddSectionHeadParaToSection(section, "", ScrStyleNames.SectionHead);

			Options.ShowEmptyParagraphPromptsSetting = false;

			DummyTeStVc stVc = new DummyTeStVc(Cache, Cache.DefaultVernWs);
				bool fTextAdded = stVc.CallInsertUserPrompt(m_vwenvMock, para);

				Assert.IsFalse(fTextAdded, "User prompt added");
				m_vwenvMock.VerifyAllExpectations();
			}
Example #23
0
		public void NoUserPromptForContentPara()
		{
			// Set up empty content paragraph
			IScrSection section = AddSectionToMockedBook(m_book);
			IStTxtPara para = AddParaToMockedSectionContent(section,
				ScrStyleNames.NormalParagraph);

			DummyTeStVc stVc = new DummyTeStVc(Cache, Cache.DefaultVernWs);
				bool fTextAdded = stVc.CallInsertUserPrompt(m_vwenvMock, para);

				Assert.IsFalse(fTextAdded, "User prompt was added to empty content para");

				m_vwenvMock.AssertWasNotCalled(x => x.NoteDependency(Arg<int[]>.Is.Anything, Arg<int[]>.Is.Anything, Arg<int>.Is.Anything));
				m_vwenvMock.AssertWasNotCalled(x => x.AddProp(Arg<int>.Is.Anything, Arg<IVwViewConstructor>.Is.Anything, Arg<int>.Is.Anything));
				m_vwenvMock.VerifyAllExpectations();
			}
Example #24
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();
			}
Example #25
0
		public void NoUserPromptForBTWithText()
		{
			// 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 a translation to the paragraph. The mock for the AltString provides text by default.
			int wsBT = Cache.DefaultAnalWs;
			ICmTranslation trans = AddBtToMockedParagraph(para, wsBT);
			AddRunToMockedTrans(trans, wsBT, "this is text in the BT", null);

			DummyTeStVc stVc = new DummyTeStVc(Cache, wsBT);
				// verify that the prompt does not get added
				bool fTextAdded = stVc.CallInsertBackTranslationUserPrompt(m_vwenvMock, trans);
				Assert.IsFalse(fTextAdded, "User prompt added when it should not have been");

				m_vwenvMock.AssertWasNotCalled(x => x.NoteDependency(Arg<int[]>.Is.Anything, Arg<int[]>.Is.Anything, Arg<int>.Is.Anything));
				m_vwenvMock.AssertWasNotCalled(x => x.AddProp(Arg<int>.Is.Anything, Arg<IVwViewConstructor>.Is.Anything, Arg<int>.Is.Anything));
				m_vwenvMock.VerifyAllExpectations();
			}
Example #26
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();
		}
Example #27
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();
			}
Example #28
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();
			}
Example #29
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();
		}
Example #30
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();
		}
Example #31
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();
		}
Example #32
0
		public void UserPromptChangeWSWhenPasting()
		{
			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);

			// set up the text to paste - will be TE2ST with vernacular WS
			int ws = m_inMemoryCache.Cache.DefaultVernWs;
			ITsPropsFactory propFact = TsPropsFactoryClass.Create();
			ITsTextProps ttp = propFact.MakeProps(null, ws, 0);
			ITsStrBldr bldr = TsStrBldrClass.Create();
			bldr.ReplaceRgch(0, 0, "TEST", 4, ttp);
			ttp = propFact.MakeProps(ScrStyleNames.VerseNumber, ws, 0);
			bldr.ReplaceRgch(2, 2, "2", 1, ttp);
			ITsString tssVal = bldr.GetString();

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

			// verify that the text is in the paragraph, that there is no longer a user
			// prompt, and that the ws changed but the character formatting survives.
			bldr = tssVal.GetBldr();
			bldr.SetIntPropValues(0, 5, (int)FwTextPropType.ktptWs,
				(int)FwTextPropVar.ktpvDefault, m_inMemoryCache.Cache.DefaultAnalWs);
			AssertEx.AreTsStringsEqual(bldr.GetString(), para.Contents.UnderlyingTsString);

			m_vwenvMock.Verify();
		}
Example #33
0
		public void UserPromptForSectionHeadWithEmptyPara_NoOption()
		{
			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 = false;

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

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

			Assert.IsFalse(fTextAdded, "User prompt added");
			m_vwenvMock.Verify();
		}
Example #34
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");
			}
Example #35
0
		public void NoUserPromptForBTWithEmptyPara()
		{
			CheckDisposed();

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

			// 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);

			m_vwenvMock.ExpectNoCall("NoteDependency", new string[] { typeof(int[]).FullName,
				typeof(int[]).FullName, typeInt });
			m_vwenvMock.ExpectNoCall("AddProp", new string[] { typeInt,
				typeof(IVwViewConstructor).FullName, typeInt });

			// verify that the prompt does not get added
			IVwEnv vwEnv = (IVwEnv)m_vwenvMock.MockInstance;
			bool fTextAdded = stVc.CallInsertBackTranslationUserPrompt(vwEnv, trans.Hvo);
			Assert.IsFalse(fTextAdded, "User prompt was added and should not have been");

			// verify the mock
			m_vwenvMock.Verify();
		}
Example #36
0
		public void MakeDispPropOverrides_invalidValues_ReversedMinLim()
		{
			IStText text = m_inMemoryCache.AddTitleToMockedBook(m_book.Hvo, "Title text");

			DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultVernWs);
			Assert.AreEqual(0, stVc.PropOverrides.Count);
			stVc.CallMakeDispPropOverrides((StTxtPara)text.ParagraphsOS[0], 8, 2,
					 delegate(ref DispPropOverride prop)
					 {
						 // Nothing to do
					 });
		}
Example #37
0
		public void NoUserPromptForBTWithEmptyPara()
		{
			// Set up a section and empty paragraph
			IScrSection section = AddSectionToMockedBook(m_book);
			IStTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph);

			// 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);
				// verify that the prompt does not get added
				bool fTextAdded = stVc.CallInsertBackTranslationUserPrompt(m_vwenvMock, trans);
				Assert.IsFalse(fTextAdded, "User prompt was added and should not have been");

				m_vwenvMock.AssertWasNotCalled(x => x.NoteDependency(Arg<int[]>.Is.Anything, Arg<int[]>.Is.Anything, Arg<int>.Is.Anything));
				m_vwenvMock.AssertWasNotCalled(x => x.AddProp(Arg<int>.Is.Anything, Arg<IVwViewConstructor>.Is.Anything, Arg<int>.Is.Anything));
				m_vwenvMock.VerifyAllExpectations();
			}
Example #38
0
		public void MakeDispPropOverrides_invalidValues_BeyondParaBounds2()
		{
			IStText text = AddTitleToMockedBook(m_book, "Title text");

			DummyTeStVc stVc = new DummyTeStVc(Cache, Cache.DefaultVernWs);
				Assert.AreEqual(0, stVc.PropOverrides.Count);
				stVc.CallMakeDispPropOverrides((IScrTxtPara)text[0], 11, 11,
					delegate(ref DispPropOverride prop)
					{
					// Nothing to do
					});
				Assert.AreEqual(1, stVc.PropOverrides.Count);
				Assert.AreEqual(10, stVc.PropOverrides[0].ichMin);
				Assert.AreEqual(10, stVc.PropOverrides[0].ichLim);
			}
Example #39
0
		public void NoUserPromptForContentPara()
		{
			CheckDisposed();

			// Set up empty content paragraph
			IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
			StTxtPara para = m_inMemoryCache.AddParaToMockedSectionContent(section.Hvo,
				ScrStyleNames.NormalParagraph);
			section.AdjustReferences();

			m_vwenvMock.ExpectNoCall("NoteDependency", new string[] { typeof(int[]).FullName,
																		typeof(int[]).FullName, typeInt });
			m_vwenvMock.ExpectNoCall("AddProp", new string[] { typeInt,
																 typeof(IVwViewConstructor).FullName, typeInt });

			DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultVernWs);
			bool fTextAdded = stVc.CallInsertUserPrompt((IVwEnv)m_vwenvMock.MockInstance,
				para.Hvo);

			Assert.IsFalse(fTextAdded, "User prompt was added to empty content para");
			m_vwenvMock.Verify();
		}