public void ExistingAnnotation_WithResponses() { IScrScriptureNote existingAnn = AddAnnotation(null, 02002008, NoteType.Translator, "This is my discussion"); existingAnn.ResolutionStatus = NoteStatus.Open; IStJournalText exisingResponse1 = Cache.ServiceLocator.GetInstance <IStJournalTextFactory>().Create(); existingAnn.ResponsesOS.Add(exisingResponse1); AddParasTo(exisingResponse1, "This is my first response"); IStJournalText exisingResponse2 = Cache.ServiceLocator.GetInstance <IStJournalTextFactory>().Create(); existingAnn.ResponsesOS.Add(exisingResponse2); AddParasTo(exisingResponse2, "This is my second response"); DateTime now = DateTime.Now; DateTime utcNow = now.ToUniversalTime(); XmlScrNote ann = CreateNote(); ann.BeginScrRef = "EXO 2:8"; ann.ResolutionStatus = NoteStatus.Open; ann.AnnotationTypeGuid = CmAnnotationDefnTags.kguidAnnTranslatorNote.ToString(); ann.DateTimeCreated = utcNow.ToString(); ann.DateTimeModified = utcNow.AddDays(1).ToString(); AddParasTo(ann.Discussion, "This is my discussion"); XmlNoteResponse firstResponse = new XmlNoteResponse(); AddParasTo(firstResponse.Paragraphs, "This is my first response"); ann.Responses.Add(firstResponse); XmlNoteResponse secondResponse = new XmlNoteResponse(); AddParasTo(secondResponse.Paragraphs, "This is my second response"); ann.Responses.Add(secondResponse); DummyXmlScrAnnotationsList list = new DummyXmlScrAnnotationsList(); list.Annotations.Add(ann); list.CallWriteToCache(Cache, m_stylesheet); IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[1]; Assert.AreEqual(1, annotations.NotesOS.Count); IScrScriptureNote note = annotations.NotesOS[0]; Assert.AreEqual(NoteType.Translator, note.AnnotationType); Assert.IsTrue(AreDateTimesClose(now, note.DateCreated)); Assert.IsTrue(AreDatesClose(now.AddDays(1), note.DateModified)); Assert.AreEqual(DateTime.MinValue, note.DateResolved); IFdoOwningSequence <IStJournalText> responses = note.ResponsesOS; Assert.AreEqual(2, responses.Count); TestAnnotationField(responses[0], "This is my first response"); TestAnnotationField(responses[1], "This is my second response"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a new XmlScrNote and initializes some fields that the deserializer would /// initialize. /// </summary> /// <returns>The new XmlScrNote</returns> /// ------------------------------------------------------------------------------------ private XmlScrNote CreateNote() { XmlScrNote ann = new XmlScrNote(); ann.Categories = new List <XmlNoteCategory>(); ann.Discussion = new List <XmlNotePara>(); ann.Resolution = new List <XmlNotePara>(); ann.Suggestion = new List <XmlNotePara>(); ann.Responses = new List <XmlNoteResponse>(); ann.Quote = new List <XmlNotePara>(); return(ann); }
public void SavingDeserializedAnnotationsToCache_WithResponses() { DateTime now = DateTime.Now; DateTime utcNow = now.ToUniversalTime(); XmlScrNote ann = CreateNote(); ann.BeginScrRef = "EXO 2:8"; ann.ResolutionStatus = NoteStatus.Open; ann.AnnotationTypeGuid = LangProject.kguidAnnTranslatorNote.ToString(); ann.DateTimeCreated = utcNow.ToString(); ann.DateTimeModified = utcNow.AddDays(1).ToString(); AddParasTo(ann.Discussion, "This is my discussion"); AddParasTo(ann.Resolution, "This is my resolution for the note"); AddParasTo(ann.Quote, "This is the quoted text"); AddParasTo(ann.Suggestion, "This is my suggestion"); XmlNoteResponse firstResponse = new XmlNoteResponse(); AddParasTo(firstResponse.Paragraphs, "This is", "my", "first", "response"); ann.Responses.Add(firstResponse); XmlNoteResponse secondResponse = new XmlNoteResponse(); AddParasTo(secondResponse.Paragraphs, "This is", "my second response"); ann.Responses.Add(secondResponse); DummyXmlScrAnnotationsList list = new DummyXmlScrAnnotationsList(); list.Annotations.Add(ann); list.CallWriteToCache(Cache, m_stylesheet); IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[1]; Assert.AreEqual(1, annotations.NotesOS.Count); IScrScriptureNote note = annotations.NotesOS[0]; Assert.AreEqual(NoteType.Translator, note.AnnotationType); Assert.IsTrue(AreDateTimesClose(now, note.DateCreated)); Assert.IsTrue(AreDateTimesClose(now.AddDays(1), note.DateModified)); Assert.AreEqual(DateTime.MinValue, note.DateResolved); TestAnnotationField(note.QuoteOA, "This is the quoted text"); TestAnnotationField(note.DiscussionOA, "This is my discussion"); TestAnnotationField(note.ResolutionOA, "This is my resolution for the note"); TestAnnotationField(note.RecommendationOA, "This is my suggestion"); FdoOwningSequence <IStJournalText> responses = note.ResponsesOS; Assert.AreEqual(2, responses.Count); TestAnnotationField(responses[0], "This is", "my", "first", "response"); TestAnnotationField(responses[1], "This is", "my second response"); }
public void SavingDeserializedAnnotationsToCache_WithHyperlink() { DateTime now = DateTime.Now; DateTime utcNow = now.ToUniversalTime(); XmlScrNote ann = CreateNote(); ann.BeginScrRef = "GEN 2:8"; ann.ResolutionStatus = NoteStatus.Closed; ann.AnnotationTypeGuid = CmAnnotationDefnTags.kguidAnnTranslatorNote.ToString(); ann.DateTimeCreated = utcNow.ToString(CultureInfo.InvariantCulture); ann.DateTimeModified = utcNow.AddDays(1).ToString(CultureInfo.InvariantCulture); ann.DateTimeResolved = utcNow.AddDays(2).ToString(CultureInfo.InvariantCulture); AddParasTo(ann.Discussion, "This is my", "discussion"); AddParasTo(ann.Resolution, "This is my", "resolution for", "the note"); AddParasTo(ann.Quote, "This is the", "quoted text"); AddParasTo(ann.Suggestion, "This is", "my", "suggestion"); AddHyperTo(ann.Suggestion[1], "http://www.tim.david.com/cooldudes.html"); DummyXmlScrAnnotationsList list = new DummyXmlScrAnnotationsList(); list.Annotations.Add(ann); list.CallWriteToCache(Cache, m_stylesheet); IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[0]; Assert.AreEqual(1, annotations.NotesOS.Count); IScrScriptureNote note = annotations.NotesOS[0]; Assert.AreEqual(NoteType.Translator, note.AnnotationType); Assert.IsTrue(AreDateTimesClose(now, note.DateCreated)); Assert.IsTrue(AreDatesClose(now.AddDays(1), note.DateModified)); Assert.IsTrue(AreDatesClose(now.AddDays(2), note.DateResolved)); TestAnnotationField(note.QuoteOA, "This is the", "quoted text"); TestAnnotationField(note.DiscussionOA, "This is my", "discussion"); TestAnnotationField(note.ResolutionOA, "This is my", "resolution for", "the note"); TestAnnotationField(note.RecommendationOA, "This is", "mymy link", "suggestion"); // Check the hyperlink location ITsTextProps props = ((IStTxtPara)note.RecommendationOA.ParagraphsOS[1]).Contents.get_Properties(1); string href = TsStringUtils.GetURL(props.GetStrPropValue((int)FwTextPropType.ktptObjData)); Assert.AreEqual("http://www.tim.david.com/cooldudes.html", href); Assert.AreEqual(0, note.ResponsesOS.Count); }
public void SavingDeserializedAnnotationsToCache() { DateTime now = DateTime.Now; DateTime utcNow = now.ToUniversalTime(); XmlScrNote ann = CreateNote(); ann.BeginScrRef = "GEN 2:8"; ann.ResolutionStatus = NoteStatus.Closed; ann.AnnotationTypeGuid = CmAnnotationDefnTags.kguidAnnTranslatorNote.ToString(); ann.DateTimeCreated = utcNow.ToString(CultureInfo.InvariantCulture); ann.DateTimeModified = utcNow.AddDays(1).ToString(CultureInfo.InvariantCulture); ann.DateTimeResolved = utcNow.AddDays(2).ToString(CultureInfo.InvariantCulture); ann.BeginObjGuid = m_paraObj.Guid; ann.EndObjGuid = m_paraObj.Guid; AddParasTo(ann.Discussion, "This is my", "discussion"); AddParasTo(ann.Resolution, "This is my", "resolution for", "the note"); AddParasTo(ann.Quote, "This is the", "quoted text"); AddParasTo(ann.Suggestion, "This is", "my", "suggestion"); DummyXmlScrAnnotationsList list = new DummyXmlScrAnnotationsList(); list.Annotations.Add(ann); list.CallWriteToCache(Cache, m_stylesheet); IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[0]; Assert.AreEqual(1, annotations.NotesOS.Count); IScrScriptureNote note = annotations.NotesOS[0]; Assert.AreEqual(NoteType.Translator, note.AnnotationType); Assert.IsTrue(AreDateTimesClose(now, note.DateCreated)); Assert.IsTrue(AreDatesClose(now.AddDays(1), note.DateModified)); Assert.IsTrue(AreDatesClose(now.AddDays(2), note.DateResolved)); TestAnnotationField(note.QuoteOA, "This is the", "quoted text"); TestAnnotationField(note.DiscussionOA, "This is my", "discussion"); TestAnnotationField(note.ResolutionOA, "This is my", "resolution for", "the note"); TestAnnotationField(note.RecommendationOA, "This is", "my", "suggestion"); Assert.AreEqual(0, note.ResponsesOS.Count); }
public void SavingDeserializedAnnotationsToCache_InvalidResolvedAndModifiedDate() { DateTime now = DateTime.Now; DateTime utcNow = now.ToUniversalTime(); XmlScrNote ann = CreateNote(); ann.BeginScrRef = "GEN 2:8"; ann.ResolutionStatus = NoteStatus.Closed; ann.AnnotationTypeGuid = LangProject.kguidAnnTranslatorNote.ToString(); ann.DateTimeCreated = utcNow.ToString(); ann.DateTimeModified = "0009-05-02 20:00:00.00"; ann.DateTimeResolved = "0003-01-01 20:00:00.00"; AddParasTo(ann.Discussion, "This is my discussion"); AddParasTo(ann.Resolution, "This is my resolution for the note"); AddParasTo(ann.Quote, "This is the quoted text"); AddParasTo(ann.Suggestion, "This is my suggestion"); DummyXmlScrAnnotationsList list = new DummyXmlScrAnnotationsList(); list.Annotations.Add(ann); list.CallWriteToCache(Cache, m_stylesheet); IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[0]; Assert.AreEqual(1, annotations.NotesOS.Count); IScrScriptureNote note = annotations.NotesOS[0]; Assert.AreEqual(NoteType.Translator, note.AnnotationType); Assert.IsTrue(AreDateTimesClose(now, note.DateCreated)); Assert.IsTrue(AreDateTimesClose(DateTime.FromFileTime(0), note.DateModified)); Assert.IsTrue(AreDateTimesClose(DateTime.FromFileTime(0), note.DateModified)); TestAnnotationField(note.QuoteOA, "This is the quoted text"); TestAnnotationField(note.DiscussionOA, "This is my discussion"); TestAnnotationField(note.ResolutionOA, "This is my resolution for the note"); TestAnnotationField(note.RecommendationOA, "This is my suggestion"); Assert.AreEqual(0, note.ResponsesOS.Count); }
public void SavingDeserializedAnnotationsToCache_InvalidResolvedDate() { #if __MonoCS__ // TODO-Linux: work around [SetCulture("en-US")] being ignored on mono System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); #endif DateTime now = DateTime.Now; DateTime utcNow = now.ToUniversalTime(); XmlScrNote ann = CreateNote(); ann.BeginScrRef = "GEN 2:8"; ann.ResolutionStatus = NoteStatus.Closed; ann.AnnotationTypeGuid = CmAnnotationDefnTags.kguidAnnTranslatorNote.ToString(); ann.DateTimeCreated = utcNow.ToString(); ann.DateTimeModified = utcNow.AddDays(1).ToString(); ann.DateTimeResolved = "0003-01-01 20:00:00.00"; AddParasTo(ann.Discussion, "This is my discussion"); AddParasTo(ann.Resolution, "This is my resolution for the note"); AddParasTo(ann.Quote, "This is the quoted text"); AddParasTo(ann.Suggestion, "This is my suggestion"); DummyXmlScrAnnotationsList list = new DummyXmlScrAnnotationsList(); list.Annotations.Add(ann); list.CallWriteToCache(Cache, m_stylesheet); IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[0]; Assert.AreEqual(1, annotations.NotesOS.Count); IScrScriptureNote note = annotations.NotesOS[0]; Assert.AreEqual(NoteType.Translator, note.AnnotationType); Assert.IsTrue(AreDateTimesClose(now, note.DateCreated)); Assert.IsTrue(AreDatesClose(now.AddDays(1), note.DateModified)); Assert.IsTrue(AreDateTimesClose(note.DateModified, note.DateResolved)); TestAnnotationField(note.QuoteOA, "This is the quoted text"); TestAnnotationField(note.DiscussionOA, "This is my discussion"); TestAnnotationField(note.ResolutionOA, "This is my resolution for the note"); TestAnnotationField(note.RecommendationOA, "This is my suggestion"); Assert.AreEqual(0, note.ResponsesOS.Count); }
public void SavingDeserializedAnnotationsToCache_WithCategories() { DateTime now = DateTime.Now; DateTime utcNow = now.ToUniversalTime(); XmlScrNote ann = CreateNote(); ann.BeginScrRef = "LEV 2:8"; ann.ResolutionStatus = NoteStatus.Open; ann.AnnotationTypeGuid = CmAnnotationDefnTags.kguidAnnTranslatorNote.ToString(); ann.DateTimeCreated = utcNow.ToString(CultureInfo.InvariantCulture); ann.DateTimeModified = utcNow.AddDays(1).ToString(CultureInfo.InvariantCulture); AddParasTo(ann.Discussion, "This is my discussion"); AddParasTo(ann.Resolution, "This is my resolution for the note"); AddParasTo(ann.Quote, "This is the quoted text"); AddParasTo(ann.Suggestion, "This is my suggestion"); XmlNoteCategory category1 = new XmlNoteCategory(); category1.CategoryName = "Monkey"; category1.IcuLocale = "en"; ann.Categories.Add(category1); XmlNoteCategory category2 = new XmlNoteCategory(); category2.CategoryName = "Discourse"; category2.IcuLocale = "en"; ann.Categories.Add(category2); DummyXmlScrAnnotationsList list = new DummyXmlScrAnnotationsList(); list.Annotations.Add(ann); // Make sure 'Monkey' is not in the DB yet int wsEn = Cache.ServiceLocator.WritingSystemManager.GetWsFromStr("en"); foreach (ICmPossibility poss in m_scr.NoteCategoriesOA.PossibilitiesOS) { Assert.AreNotEqual("Monkey", poss.Name.get_String(wsEn)); } list.CallWriteToCache(Cache, m_stylesheet); IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[2]; Assert.AreEqual(1, annotations.NotesOS.Count); IScrScriptureNote note = annotations.NotesOS[0]; Assert.AreEqual(NoteType.Translator, note.AnnotationType); Assert.IsTrue(AreDateTimesClose(now, note.DateCreated)); Assert.IsTrue(AreDatesClose(now.AddDays(1), note.DateModified)); Assert.AreEqual(DateTime.MinValue, note.DateResolved); TestAnnotationField(note.QuoteOA, "This is the quoted text"); TestAnnotationField(note.DiscussionOA, "This is my discussion"); TestAnnotationField(note.ResolutionOA, "This is my resolution for the note"); TestAnnotationField(note.RecommendationOA, "This is my suggestion"); Assert.AreEqual(0, note.ResponsesOS.Count); bool foundMonkey = false; foreach (ICmPossibility poss in m_scr.NoteCategoriesOA.PossibilitiesOS) { foundMonkey |= (poss.Name.get_String(wsEn).Text == "Monkey"); } Assert.IsTrue(foundMonkey, "Monkey should have been added to the DB"); Assert.AreEqual(2, note.CategoriesRS.Count); Assert.AreEqual("Monkey", note.CategoriesRS[0].Name.get_String(wsEn).Text); Assert.AreEqual("Discourse", note.CategoriesRS[1].Name.get_String(wsEn).Text); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a new XmlScrNote and initializes some fields that the deserializer would /// initialize. /// </summary> /// <returns>The new XmlScrNote</returns> /// ------------------------------------------------------------------------------------ private XmlScrNote CreateNote() { XmlScrNote ann = new XmlScrNote(); ann.Categories = new List<XmlNoteCategory>(); ann.Discussion = new List<XmlNotePara>(); ann.Resolution = new List<XmlNotePara>(); ann.Suggestion = new List<XmlNotePara>(); ann.Responses = new List<XmlNoteResponse>(); ann.Quote = new List<XmlNotePara>(); return ann; }