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");
        }
        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 ExistingAnnotation_WithNewResponse()
		{
			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 utcCreated = existingAnn.DateCreated.ToUniversalTime();

			XmlScrNote ann = CreateNote();
			ann.BeginScrRef = "EXO 2:8";
			ann.ResolutionStatus = NoteStatus.Open;
			ann.AnnotationTypeGuid = CmAnnotationDefnTags.kguidAnnTranslatorNote.ToString();
			ann.DateTimeCreated = utcCreated.ToString(CultureInfo.InvariantCulture);
			// (The modified date is now set as automatically when the fields in the note are modified.)
			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 a new response");
			ann.Responses.Add(secondResponse);
			XmlNoteResponse thirdResponse = new XmlNoteResponse();
			AddParasTo(thirdResponse.Paragraphs, "This is my second response");
			ann.Responses.Add(thirdResponse);

			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(DateTime.Now, note.DateCreated));
			Assert.IsTrue(AreDateTimesClose(DateTime.Now, note.DateModified));
			Assert.AreEqual(DateTime.MinValue, note.DateResolved);

			IFdoOwningSequence<IStJournalText> responses = note.ResponsesOS;
			Assert.AreEqual(3, responses.Count);
			TestAnnotationField(responses[0], "This is my first response");
			TestAnnotationField(responses[1], "This is my second response");
			TestAnnotationField(responses[2], "This is a new response");
		}
		public void SavingDeserializedAnnotationsToCache_WithResponses()
		{
			DateTime now = DateTime.Now;

			XmlScrNote ann = CreateNote();
			ann.BeginScrRef = "EXO 2:8";
			ann.ResolutionStatus = NoteStatus.Open;
			ann.AnnotationTypeGuid = CmAnnotationDefnTags.kguidAnnTranslatorNote.ToString();
			// (The created and modified dates are now set as side effects when the note is
			// created and when the fields in the note are modified.)
			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, 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");

			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");
		}