Example #1
0
		public void RecordError_NearDuplicate_DifferByCitedText()
		{
			ScrChecksDataSource dataSource = new ScrChecksDataSource(Cache);
			DummyEditorialCheck check = new DummyEditorialCheck(kCheckId1);
			ScrCheckingToken tok = new DummyParaCheckingToken(m_scr, Cache.DefaultVernWs, 0);
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 0, 4, "Message"));

			m_scrInMemoryCache.AddBookToMockedScripture(tok.StartRef.Book, "My Favorite Book");

			dataSource.GetText(tok.StartRef.Book, 0);
			dataSource.RunCheck(check);
			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[tok.StartRef.Book - 1];
			Assert.AreEqual(1, annotations.NotesOS.Count,
				"First run of check should add 1 error annotation");
			IScrScriptureNote origErrorAnnotation = annotations.NotesOS[0];

			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 8, "Message"));
			dataSource.RunCheck(check);
			Assert.AreEqual(2, annotations.NotesOS.Count,
				"Second run of check should add another error annotation.");
			Assert.IsTrue(annotations.NotesOS.Contains(origErrorAnnotation));
		}
Example #2
0
		public void RecordError_Duplicate()
		{
			ScrChecksDataSource dataSource = new ScrChecksDataSource(Cache);
			DummyEditorialCheck check = new DummyEditorialCheck(kCheckId1);
			ScrCheckingToken tok = new DummyParaCheckingToken(m_scr, Cache.DefaultVernWs, 0);
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 8, "Lousy message"));

			m_scrInMemoryCache.AddBookToMockedScripture(tok.StartRef.Book, "My Favorite Book");

			dataSource.GetText(tok.StartRef.Book, 0);
			dataSource.RunCheck(check);
			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[tok.StartRef.Book - 1];
			Assert.AreEqual(1, annotations.NotesOS.Count,
				"First run of check should add error annotation");

			dataSource.RunCheck(check);
			Assert.AreEqual(1, annotations.NotesOS.Count,
				"Second run of check shouldn't create a duplicate.");
		}
Example #3
0
		public void RecordError_NearDuplicate_DifferOnlyByParaHvo()
		{
			IScrBook book = m_scrInMemoryCache.AddBookToMockedScripture(1, "My Favorite Book");

			BCVRef reference = new BCVRef(1, 2, 3);

			ScrChecksDataSource dataSource = new ScrChecksDataSource(Cache);
			DummyEditorialCheck check = new DummyEditorialCheck(kCheckId1);
			ScrCheckingToken tok = new DummyParaCheckingToken(book,
				Cache.DefaultVernWs, 0, reference, reference);
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 8, "Message"));

			dataSource.GetText(tok.StartRef.Book, 0);
			dataSource.RunCheck(check);

			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[tok.StartRef.Book - 1];
			Assert.AreEqual(1, annotations.NotesOS.Count,
				"First run of check should add 1 error annotation");
			IScrScriptureNote origErrorAnnotation = annotations.NotesOS[0];

			IScrDraft draft = m_scr.ArchivedDraftsOC.Add(new ScrDraft());
			draft.BooksOS.Append(book);

			Assert.AreEqual(0, m_scr.ScriptureBooksOS.Count);

			check.m_ErrorsToReport.Clear();
			IScrBook newBook = m_scrInMemoryCache.AddBookToMockedScripture(1, "My Favorite Book");

			tok = new DummyParaCheckingToken(newBook, Cache.DefaultVernWs, 0, reference, reference);
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 8, "Message"));
			dataSource.RunCheck(check);
			Assert.AreEqual(1, annotations.NotesOS.Count,
				"Second run of check should add another error annotation.");
			Assert.IsTrue(annotations.NotesOS.Contains(origErrorAnnotation));
			Assert.AreEqual(newBook.Hvo, annotations.NotesOS[0].BeginObjectRAHvo);
			Assert.AreEqual(newBook.Hvo, annotations.NotesOS[0].EndObjectRAHvo);
			Assert.AreEqual(reference, annotations.NotesOS[0].BeginRef);
			Assert.AreEqual(reference, annotations.NotesOS[0].EndRef);
			Assert.AreEqual(5, annotations.NotesOS[0].BeginOffset);
			Assert.AreEqual(13, annotations.NotesOS[0].EndOffset);
		}
Example #4
0
		public void RecordError_NearDuplicate_DifferByCheck()
		{
			ScrChecksDataSource dataSource = new ScrChecksDataSource(Cache);
			ICmAnnotationDefn annDefnChkError = new CmAnnotationDefn(Cache,
				LangProject.kguidAnnCheckingError);
			CmAnnotationDefn errorCheck1 = new CmAnnotationDefn();
			annDefnChkError.SubPossibilitiesOS.Append(errorCheck1);
			errorCheck1.Guid = Guid.NewGuid();
			errorCheck1.Name.UserDefaultWritingSystem = "Type 1";

			CmAnnotationDefn errorCheck2 = new CmAnnotationDefn();
			annDefnChkError.SubPossibilitiesOS.Append(errorCheck2);
			errorCheck2.Guid = Guid.NewGuid();
			errorCheck2.Name.UserDefaultWritingSystem = "Type 2";

			DummyEditorialCheck check1 = new DummyEditorialCheck(errorCheck1.Guid);
			ScrCheckingToken tok = new DummyParaCheckingToken(m_scr, Cache.DefaultVernWs, 0);
			check1.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 8, "General Error"));

			m_scrInMemoryCache.AddBookToMockedScripture(tok.StartRef.Book, "My Favorite Book");

			dataSource.GetText(tok.StartRef.Book, 0);
			dataSource.RunCheck(check1);
			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[tok.StartRef.Book - 1];
			Assert.AreEqual(1, annotations.NotesOS.Count,
				"Check 1 should add 1 error annotation");
			IScrScriptureNote origErrorAnnotation = annotations.NotesOS[0];

			DummyEditorialCheck check2 = new DummyEditorialCheck(errorCheck2.Guid);
			check2.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 8, "General Error"));

			dataSource.RunCheck(check2);
			Assert.AreEqual(2, annotations.NotesOS.Count,
				"Check 2 should add another error annotation.");
			Assert.IsTrue(annotations.NotesOS.Contains(origErrorAnnotation));
		}
Example #5
0
		public void RunCheck_CorrectedErrorGetsDeleted()
		{
			ScrChecksDataSource dataSource = new ScrChecksDataSource(Cache);
			DummyEditorialCheck check = new DummyEditorialCheck(kCheckId1);
			ScrCheckingToken tok = new DummyParaCheckingToken(m_scr, Cache.DefaultVernWs, 0);
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 8, "Lousy message"));

			m_scrInMemoryCache.AddBookToMockedScripture(tok.StartRef.Book, "My Favorite Book");

			dataSource.GetText(tok.StartRef.Book, 0);
			dataSource.RunCheck(check);
			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[tok.StartRef.Book - 1];
			Assert.AreEqual(1, annotations.NotesOS.Count,
				"First run of check should add 1 error annotation");
			IScrScriptureNote origErrorAnnotation = annotations.NotesOS[0];
			Assert.AreEqual("Lousy message",
				((StTxtPara)origErrorAnnotation.DiscussionOA.ParagraphsOS[0]).Contents.Text);

			check.m_ErrorsToReport.Clear();
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 8, "Goofy message"));
			dataSource.RunCheck(check);
			Assert.AreEqual(1, annotations.NotesOS.Count,
				"Second run of check should delete the 'fixed' error annotation and add another error annotation.");
			IScrScriptureNote newErrorAnnotation = annotations.NotesOS[0];
			Assert.AreNotEqual(origErrorAnnotation, newErrorAnnotation);
			Assert.AreEqual("Goofy message",
				((StTxtPara)newErrorAnnotation.DiscussionOA.ParagraphsOS[0]).Contents.Text);
		}
Example #6
0
		public void RunCheck_ScrCheckRunRecordsWithOneBookTwoChecks()
		{
			ScrChecksDataSource dataSource = new ScrChecksDataSource(Cache);
			DummyEditorialCheck check1 = new DummyEditorialCheck(kCheckId1);
			ScrCheckingToken tok = new DummyParaCheckingToken(m_scr, Cache.DefaultVernWs, 0);
			check1.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 2, "Verbification"));
			tok = new DummyParaCheckingToken(m_scr, m_inMemoryCache.Cache.DefaultVernWs, 0);
			check1.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 26, 2, "Verbification"));

			DummyEditorialCheck check2 = new DummyEditorialCheck(kCheckId2);
			check2.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 2, "Stupid Check"));
			tok = new DummyParaCheckingToken(m_scr, m_inMemoryCache.Cache.DefaultVernWs, 0);
			check2.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 26, 2, "Stupid Check"));

			m_scrInMemoryCache.AddBookToMockedScripture(tok.StartRef.Book, "The Book of David");

			dataSource.GetText(tok.StartRef.Book, 0);
			dataSource.RunCheck(check1);
			dataSource.RunCheck(check2);
			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[tok.StartRef.Book - 1];

			Assert.AreEqual(2, annotations.ChkHistRecsOC.Count);
			Assert.AreEqual(4, annotations.NotesOS.Count);

			ScrCheckRun scr1 =
				new ScrCheckRun(Cache, annotations.ChkHistRecsOC.HvoArray[0]);
			ScrCheckRun scr2 =
				new ScrCheckRun(Cache, annotations.ChkHistRecsOC.HvoArray[1]);

			Assert.AreEqual(ScrCheckRunResult.Inconsistencies, scr1.Result);
			Assert.AreEqual(ScrCheckRunResult.Inconsistencies, scr2.Result);
			Assert.AreEqual(NoteStatus.Open, annotations.NotesOS[0].ResolutionStatus);
			Assert.AreEqual(NoteStatus.Open, annotations.NotesOS[1].ResolutionStatus);
			Assert.AreEqual(NoteStatus.Open, annotations.NotesOS[2].ResolutionStatus);
			Assert.AreEqual(NoteStatus.Open, annotations.NotesOS[3].ResolutionStatus);

			annotations.NotesOS[0].ResolutionStatus = NoteStatus.Closed;
			annotations.NotesOS[1].ResolutionStatus = NoteStatus.Closed;
			dataSource.RunCheck(check1);

			scr1 = new ScrCheckRun(Cache, annotations.ChkHistRecsOC.HvoArray[0]);
			scr2 = new ScrCheckRun(Cache, annotations.ChkHistRecsOC.HvoArray[1]);
			Assert.AreEqual(ScrCheckRunResult.IgnoredInconsistencies, scr1.Result);
			Assert.AreEqual(ScrCheckRunResult.Inconsistencies, scr2.Result);
		}
Example #7
0
		public void RunCheck_ScrCheckRunRecordsWithFixedInconsistency()
		{
			ScrChecksDataSource dataSource = new ScrChecksDataSource(Cache);
			DummyEditorialCheck check = new DummyEditorialCheck(kCheckId1);
			ScrCheckingToken tok = new DummyParaCheckingToken(m_scr, Cache.DefaultVernWs, 0);
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 2, "Verbification"));

			m_scrInMemoryCache.AddBookToMockedScripture(tok.StartRef.Book, "The Book of David");

			dataSource.GetText(tok.StartRef.Book, 0);
			dataSource.RunCheck(check);
			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[tok.StartRef.Book - 1];

			Assert.AreEqual(1, annotations.ChkHistRecsOC.Count);
			Assert.AreEqual(1, annotations.NotesOS.Count);

			ScrCheckRun scr =
				new ScrCheckRun(Cache, annotations.ChkHistRecsOC.HvoArray[0]);

			Assert.AreEqual(ScrCheckRunResult.Inconsistencies, scr.Result);
			Assert.AreEqual(NoteStatus.Open, annotations.NotesOS[0].ResolutionStatus);

			check.m_ErrorsToReport.Clear();
			dataSource.RunCheck(check);

			Assert.AreEqual(1, annotations.ChkHistRecsOC.Count);
			Assert.AreEqual(0, annotations.NotesOS.Count);

			scr = new ScrCheckRun(Cache, annotations.ChkHistRecsOC.HvoArray[0]);
			Assert.AreEqual(ScrCheckRunResult.NoInconsistencies, scr.Result);
		}
Example #8
0
		public void RecordError_Duplicate_SameErrorTwiceInVerse()
		{
			ScrChecksDataSource dataSource = new ScrChecksDataSource(Cache);
			DummyEditorialCheck check = new DummyEditorialCheck(kCheckId1);
			ScrCheckingToken tok = new DummyParaCheckingToken(m_scr, Cache.DefaultVernWs, 0);
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 2, "Lousy message"));
			tok = new DummyParaCheckingToken(m_scr, m_inMemoryCache.Cache.DefaultVernWs, 0);
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 26, 2, "Lousy message"));

			m_scrInMemoryCache.AddBookToMockedScripture(tok.StartRef.Book, "My Favorite Book");

			dataSource.GetText(tok.StartRef.Book, 0);
			dataSource.RunCheck(check);
			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[tok.StartRef.Book - 1];
			Assert.AreEqual(2, annotations.NotesOS.Count,
				"First run of check should add two error annotations");
			Assert.AreEqual(5, annotations.NotesOS[0].BeginOffset);
			Assert.AreEqual(26, annotations.NotesOS[1].BeginOffset);
			Assert.AreEqual(28, annotations.NotesOS[1].EndOffset);

			// Change the offset of the second error (but the text is still the same at that ich, so the
			// error's key will be the same).
			check.m_ErrorsToReport[1].m_ichStart = 37;

			dataSource.RunCheck(check);
			Assert.AreEqual(2, annotations.NotesOS.Count,
				"Second run of check shouldn't create a duplicate.");
			Assert.AreEqual(5, annotations.NotesOS[0].BeginOffset,
				"Offset of first annotation shouldn't change.");
			Assert.AreEqual(37, annotations.NotesOS[1].BeginOffset,
				"Begin offset of second annotation should get updated.");
			Assert.AreEqual(39, annotations.NotesOS[1].EndOffset,
				"End offset of second annotation should get updated.");
		}
Example #9
0
		public void RecordError_DuplicateAfterAdjustingReference()
		{
			ScrChecksDataSource dataSource = new ScrChecksDataSource(Cache);
			DummyEditorialCheck check = new DummyEditorialCheck(kCheckId1);
			ScrCheckingToken tok = new DummyParaCheckingToken(m_scr, Cache.DefaultVernWs, 0);
			tok.MissingStartRef = new BCVRef(tok.StartRef);
			tok.MissingStartRef.Verse++;
			tok.MissingEndRef = new BCVRef(tok.MissingStartRef);
			tok.MissingEndRef.Verse++; // this simulates missing two verses
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 1, 1, "3"));

			m_scrInMemoryCache.AddBookToMockedScripture(tok.StartRef.Book, "My Favorite Book");

			dataSource.GetText(tok.StartRef.Book, 0);
			dataSource.RunCheck(check);
			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[tok.StartRef.Book - 1];
			Assert.AreEqual(1, annotations.NotesOS.Count,
				"First run of check should add error annotation");

			annotations.NotesOS[0].ResolutionStatus = NoteStatus.Closed;

			// Need a new token because the one above has already gotten changed.
			tok = new DummyParaCheckingToken(m_scr, Cache.DefaultVernWs, 0);
			tok.MissingStartRef = new BCVRef(tok.StartRef);
			tok.MissingStartRef.Verse++;
			tok.MissingEndRef = new BCVRef(tok.MissingStartRef);
			tok.MissingEndRef.Verse++; // this simulates missing two verses
			check.m_ErrorsToReport.Clear();
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 1, 1, "3"));

			dataSource.RunCheck(check);
			Assert.AreEqual(1, annotations.NotesOS.Count,
				"Second run of check shouldn't create a duplicate.");
			Assert.AreEqual(NoteStatus.Closed, annotations.NotesOS[0].ResolutionStatus,
				"Annotation should still be resolved/closed (ignored).");
		}