예제 #1
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();
        }
예제 #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Add an annotation to a language project.
        /// </summary>
        /// <param name="scrInMemoryCache">in-memory cache to use for testing</param>
        /// <param name="noteText">text to include in discussion</param>
        /// <param name="startRef"></param>
        /// <param name="endRef"></param>
        /// <param name="topPara">Begin StTxtPara to annotate</param>
        /// <param name="bottomPara">End StTxtPara to annotate</param>
        /// <returns>a new annotation</returns>
        /// ------------------------------------------------------------------------------------
        internal static IScrScriptureNote AddAnnotation(ScrInMemoryFdoCache scrInMemoryCache, string noteText,
                                                        ScrReference startRef, ScrReference endRef, ICmObject topPara, ICmObject bottomPara)
        {
            ILangProject       lp          = scrInMemoryCache.Cache.LangProject;
            ScrBookAnnotations annotations = (ScrBookAnnotations)lp.TranslatedScriptureOA.BookAnnotationsOS[startRef.Book - 1];
            IScrScriptureNote  note        = annotations.InsertNote(startRef, endRef, topPara, bottomPara,
                                                                    StandardNoteType(scrInMemoryCache).Guid);

            StTxtPara discussionPara = (StTxtPara)note.DiscussionOA.ParagraphsOS[0];

            scrInMemoryCache.AddRunToMockedPara(discussionPara, noteText, scrInMemoryCache.Cache.DefaultAnalWs);

            note.DateCreated = new DateTime(s_Ticks++);

            return(note);
        }
예제 #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a new paragraph
        /// </summary>
        /// <param name="sectionHvo">The hvo of the section to which the paragraph will be
        /// added</param>
        /// <param name="chapterNumber">the chapter number to create or <c>null</c> if no
        /// chapter number is desired.</param>
        /// <param name="verseNumber">the chapter number to create or <c>null</c> if no
        /// verse number is desired.</param>
        /// <returns>The newly created paragraph.</returns>
        /// ------------------------------------------------------------------------------------
        protected StTxtPara SetupParagraph(int sectionHvo, string chapterNumber, string verseNumber)
        {
            StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(sectionHvo, "Paragraph");

            if (chapterNumber != null)
            {
                m_scrInMemoryCache.AddRunToMockedPara(para, chapterNumber, "Chapter Number");
            }
            if (verseNumber != null)
            {
                m_scrInMemoryCache.AddRunToMockedPara(para, verseNumber, "Verse Number");
            }
            m_scrInMemoryCache.AddRunToMockedPara(para, kParagraphText, null);

            return(para);
        }