/// ------------------------------------------------------------------------------------ /// <summary> /// Create and Check an Annotation /// </summary> /// <param name="hvoParaStart">The hvo para start.</param> /// <param name="hvoParaEnd">The hvo para end.</param> /// <param name="startRef">The start ref.</param> /// <param name="endRef">The end ref.</param> /// <param name="startOffset">The start offset.</param> /// <param name="endOffset">The end offset.</param> /// <param name="tssQuote">The text in the quote.</param> /// <param name="sel">selection in main window</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ private IScrScriptureNote CreateAndCheckAnnotation(ICmObject topObj, ICmObject bottomObj, int startRef, int endRef, int startOffset, int endOffset, string strQuote) { ILangProject lp = Cache.LangProject; ICmAnnotationDefn transNoteAnnDefn = Cache.ServiceLocator.GetInstance <ICmAnnotationDefnRepository>().TranslatorAnnotationDefn; // Get information from the selection about the location of the annotation. ITsStrBldr tssBldrQuote = TsStrBldrClass.Create(); tssBldrQuote.Replace(0, 0, strQuote, StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); IScrScriptureNote ann = m_notesEditingHelper.InsertNote(transNoteAnnDefn, startRef, endRef, topObj, bottomObj, startOffset, endOffset, tssBldrQuote.GetString()); Assert.IsNotNull(ann); Assert.AreEqual(transNoteAnnDefn, ann.AnnotationTypeRA, "Wrong type of note created"); Assert.AreEqual(topObj, ann.BeginObjectRA, "Wrong paragraph annotated"); Assert.AreEqual(bottomObj, ann.EndObjectRA, "Wrong paragraph annotated"); Assert.AreEqual(startRef, ann.BeginRef, "Should have the correct start para reference"); Assert.AreEqual(endRef, ann.EndRef, "Should have the correct end para reference"); Assert.AreEqual(startOffset, ann.BeginOffset, "Should have the correct starting char offset"); Assert.AreEqual(endOffset, ann.EndOffset, "Should have the correct ending char offset"); Assert.AreEqual(lp.DefaultUserAgent, ann.SourceRA, "Wrong agent"); VerifyInitializedText(ann.DiscussionOA, "Discussion"); Assert.AreEqual(tssBldrQuote.Text, ((IStTxtPara)ann.QuoteOA.ParagraphsOS[0]).Contents.Text); VerifyInitializedText(ann.RecommendationOA, "Recommendation"); VerifyInitializedText(ann.ResolutionOA, "Resolution"); return(ann); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create and Check an Annotation /// </summary> /// <param name="hvoParaStart">The hvo para start.</param> /// <param name="hvoParaEnd">The hvo para end.</param> /// <param name="startRef">The start ref.</param> /// <param name="endRef">The end ref.</param> /// <param name="startOffset">The start offset.</param> /// <param name="endOffset">The end offset.</param> /// <param name="tssQuote">The text in the quote.</param> /// <param name="sel">selection in main window</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ private IScrScriptureNote CreateAndCheckAnnotation(int hvoObjStart, int hvoObjEnd, int startRef, int endRef, int startOffset, int endOffset, string strQuote) { ILangProject lp = Cache.LangProject; CmAnnotationDefn transNoteAnnDefn = new CmAnnotationDefn(Cache, LangProject.kguidAnnTranslatorNote); // Get information from the selection about the location of the annotation. CmObject topObj = (CmObject)CmObject.CreateFromDBObject(m_inMemoryCache.Cache, hvoObjStart); CmObject bottomObj = (CmObject)CmObject.CreateFromDBObject(m_inMemoryCache.Cache, hvoObjEnd); int wsSelector = -1; ITsStrBldr tssBldrQuote = TsStrBldrClass.Create(); tssBldrQuote.Replace(0, 0, strQuote, StyleUtils.ParaStyleTextProps(ScrStyleNames.Remark)); IScrScriptureNote ann = m_notesEditingHelper.InsertNote(transNoteAnnDefn, startRef, endRef, topObj, bottomObj, wsSelector, startOffset, endOffset, tssBldrQuote.GetString()); Assert.IsNotNull(ann); Assert.AreEqual(transNoteAnnDefn.Hvo, ann.AnnotationTypeRAHvo, "Wrong type of note created"); Assert.AreEqual(hvoObjStart, ann.BeginObjectRAHvo, "Wrong paragraph annotated"); Assert.AreEqual(hvoObjEnd, ann.EndObjectRAHvo, "Wrong paragraph annotated"); Assert.AreEqual(startRef, ann.BeginRef, "Should have the correct start para reference"); Assert.AreEqual(endRef, ann.EndRef, "Should have the correct end para reference"); Assert.AreEqual(startOffset, ann.BeginOffset, "Should have the correct starting char offset"); Assert.AreEqual(endOffset, ann.EndOffset, "Should have the correct ending char offset"); Assert.AreEqual(lp.DefaultUserAgent.Hvo, ann.SourceRAHvo, "Wrong agent"); VerifyInitializedText(ann.DiscussionOA, "Discussion"); Assert.AreEqual(tssBldrQuote.Text, ((StTxtPara)ann.QuoteOA.ParagraphsOS[0]).Contents.Text); VerifyInitializedText(ann.RecommendationOA, "Recommendation"); VerifyInitializedText(ann.ResolutionOA, "Resolution"); return(ann); }