Dummy "check" that just calls the RecordError delegate once for each "error" in its list.
Inheritance: IScriptureCheck
コード例 #1
0
		public void RecordError_ErrorsIdentical()
		{
			// Setup a data source that allows a maximum of two identical errors for all checks.
			// Setup three identical checking errors.
			DummyScrChecksDataSource dataSource = new DummyScrChecksDataSource(Cache, 2);
			DummyEditorialCheck check = new DummyEditorialCheck(kCheckId1);
			ScrCheckingToken tok = new DummyParaCheckingToken(m_scr, Cache.DefaultVernWs, 0);
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 2, "identical"));
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 26, 2, "identical"));
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 37, 2, "identical"));

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

			// Run the Scripture check
			dataSource.GetText(tok.StartRef.Book, 0);
			dataSource.RunCheck(check);

			// We expect three error annotations to be created: two for the allowed identical errors,
			// and one indicating that a maximum has been exceeded.
			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[tok.StartRef.Book - 1];
			Assert.AreEqual(3, annotations.NotesOS.Count,
				"Three error annotations should have been added.");
			for (int iNote = 0; iNote < 2; iNote++)
			{
				// verify allowed identical annotations
				IScrScriptureNote note = annotations.NotesOS[iNote];
				Assert.AreEqual("identical", ((IStTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents.Text);
				Assert.AreEqual("is", ((IStTxtPara)note.QuoteOA.ParagraphsOS[0]).Contents.Text);
			}
			// verify identical error exceeded annotation.
			IScrScriptureNote maxNote = annotations.NotesOS[2];
			Assert.AreEqual("Maximum number of Dummy Check 1 errors exceeded.",
				((IStTxtPara)maxNote.DiscussionOA.ParagraphsOS[0]).Contents.Text);
			Assert.AreEqual("is", ((IStTxtPara)maxNote.QuoteOA.ParagraphsOS[0]).Contents.Text);
		}
コード例 #2
0
		public void RecordError_Duplicate()
		{
			ScrChecksDataSource dataSource = CreateScrChecksDataSource();
			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"));

			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.");
		}
コード例 #3
0
		public void RecordError_DuplicateAfterAdjustingReference()
		{
			ScrChecksDataSource dataSource = CreateScrChecksDataSource();
			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"));

			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).");
		}
コード例 #4
0
		public void RecordError_NearDuplicate_DifferByCheck()
		{
			IFdoServiceLocator servloc = Cache.ServiceLocator;
			ScrChecksDataSource dataSource = CreateScrChecksDataSource();
			ICmAnnotationDefn annDefnChkError = servloc.GetInstance<ICmAnnotationDefnRepository>().CheckingError;
			ICmAnnotationDefn errorCheck1 = servloc.GetInstance<ICmAnnotationDefnFactory>().Create(
				Guid.NewGuid(), annDefnChkError);
			errorCheck1.Name.SetUserWritingSystem("Type 1");

			ICmAnnotationDefn errorCheck2 = servloc.GetInstance<ICmAnnotationDefnFactory>().Create(
				Guid.NewGuid(), annDefnChkError);
			errorCheck2.Name.SetUserWritingSystem("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"));

			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));
		}
コード例 #5
0
		public void RecordError_NearDuplicate_DifferByCitedText()
		{
			ScrChecksDataSource dataSource = CreateScrChecksDataSource();
			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"));

			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));
		}
コード例 #6
0
		public void RunCheck_CorrectedErrorGetsDeleted()
		{
			ScrChecksDataSource dataSource = CreateScrChecksDataSource();
			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"));

			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",
				((IStTxtPara)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",
				((IStTxtPara)newErrorAnnotation.DiscussionOA.ParagraphsOS[0]).Contents.Text);
		}
コード例 #7
0
		public void RecordError_NearDuplicate_DifferOnlyByParaHvo()
		{
			IScrBook book = AddBookToMockedScripture(1, "My Favorite Book");

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

			ScrChecksDataSource dataSource = CreateScrChecksDataSource();
			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 = Cache.ServiceLocator.GetInstance<IScrDraftFactory>().Create("RecordError_NearDuplicate_DifferOnlyByParaHvo");
			draft.BooksOS.Add(book);

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

			check.m_ErrorsToReport.Clear();
			IScrBook newBook = 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, annotations.NotesOS[0].BeginObjectRA);
			Assert.AreEqual(newBook, annotations.NotesOS[0].EndObjectRA);
			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);
		}
コード例 #8
0
		public void RunCheck_ScrCheckRunRecordsWithOneBookOneCheck()
		{
			ScrChecksDataSource dataSource = CreateScrChecksDataSource();
			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"));
			tok = new DummyParaCheckingToken(m_scr, Cache.DefaultVernWs, 0);
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 26, 2, "Verbification"));

			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(2, annotations.NotesOS.Count);

			IScrCheckRun scr = annotations.ChkHistRecsOC.First<IScrCheckRun>();

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

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

			scr = annotations.ChkHistRecsOC.First<IScrCheckRun>();
			Assert.AreEqual(ScrCheckRunResult.Inconsistencies, scr.Result);

			annotations.NotesOS[0].ResolutionStatus = NoteStatus.Closed;
			annotations.NotesOS[1].ResolutionStatus = NoteStatus.Closed;
			dataSource.RunCheck(check);
			scr = annotations.ChkHistRecsOC.First<IScrCheckRun>();
			Assert.AreEqual(ScrCheckRunResult.IgnoredInconsistencies, scr.Result);
		}
コード例 #9
0
		public void RunCheck_ScrCheckRunRecordsWithOneBookTwoChecks()
		{
			ScrChecksDataSource dataSource = CreateScrChecksDataSource();
			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, 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, Cache.DefaultVernWs, 0);
			check2.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 26, 2, "Stupid Check"));

			IScrBook book = AddBookToMockedScripture(tok.StartRef.Book, "The Book of David");

			dataSource.GetText(book.CanonicalNum, 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);

			foreach (IScrCheckRun run in annotations.ChkHistRecsOC)
				Assert.AreEqual(ScrCheckRunResult.Inconsistencies, run.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);

			Assert.AreEqual(2, annotations.ChkHistRecsOC.Count);
			IScrCheckRunRepository repo = Cache.ServiceLocator.GetInstance<IScrCheckRunRepository>();
			Assert.AreEqual(ScrCheckRunResult.IgnoredInconsistencies,
				repo.InstanceForCheck(book.CanonicalNum, check1.CheckId).Result);
			Assert.AreEqual(ScrCheckRunResult.Inconsistencies,
				repo.InstanceForCheck(book.CanonicalNum, check2.CheckId).Result,
				"Result for check 2 shouldn't have changed.");
		}
コード例 #10
0
		public void RecordError_Duplicate_SameErrorTwiceInVerse()
		{
			ScrChecksDataSource dataSource = CreateScrChecksDataSource();
			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, Cache.DefaultVernWs, 0);
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 26, 2, "Lousy message"));

			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.");
		}
コード例 #11
0
		public void RecordError_ErrorMaxIncreased()
		{
			// Setup a data source with a limit of one identical error for all checks.
			// Setup three identical checking errors.
			DummyScrChecksDataSource dataSource = new DummyScrChecksDataSource(Cache, 1);
			DummyEditorialCheck check = new DummyEditorialCheck(kCheckId1);
			ScrCheckingToken tok = new DummyParaCheckingToken(m_scr, Cache.DefaultVernWs, 0);

			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 2, "identical"));
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 26, 2, "identical"));
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 37, 2, "identical"));

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

			// Run the Scripture check
			dataSource.GetText(tok.StartRef.Book, 0);
			dataSource.RunCheck(check);

			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[tok.StartRef.Book - 1];
			Assert.AreEqual(2, annotations.NotesOS.Count,
				"Two error annotations should have been added: one error and one maximum exceeded msg.");

			// Now update the maximum identical errors to be unlimited and run the check again.
			dataSource.MaxIdenticalErrors = -1;
			dataSource.GetText(tok.StartRef.Book, 0);
			dataSource.RunCheck(check);

			// We expect three error annotations and we confirm the last error.
			Assert.AreEqual(3, annotations.NotesOS.Count,
				"There should be three error annotations now.");

			IScrScriptureNote note = annotations.NotesOS[2];
			Assert.AreEqual("identical", ((IStTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents.Text);
			Assert.AreEqual("is", ((IStTxtPara)note.QuoteOA.ParagraphsOS[0]).Contents.Text);
		}
コード例 #12
0
		public void RecordError_ErrorMaxDecreased()
		{
			// Setup a data source that does not set a limit on identical errors for all checks.
			// Setup three identical checking errors.
			DummyScrChecksDataSource dataSource = new DummyScrChecksDataSource(Cache, -1);
			DummyEditorialCheck check = new DummyEditorialCheck(kCheckId1);
			ScrCheckingToken tok = new DummyParaCheckingToken(m_scr, Cache.DefaultVernWs, 0);

			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 2, "identical"));
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 26, 2, "identical"));
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 37, 2, "identical"));

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

			// Run the Scripture check
			dataSource.GetText(tok.StartRef.Book, 0);
			dataSource.RunCheck(check);

			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[tok.StartRef.Book - 1];
			Assert.AreEqual(3, annotations.NotesOS.Count,
				"Three error annotations should have been added.");

			// Now update the maximum identical errors to only 1 and run the check again.
			dataSource.MaxIdenticalErrors = 1;
			dataSource.GetText(tok.StartRef.Book, 0);
			dataSource.RunCheck(check);

			// We expect two error annotations: one for the only allowed error and
			// one indicating that a maximum has been exceeded.
			Assert.AreEqual(2, annotations.NotesOS.Count,
				"There should be two error annotations now.");

			IScrScriptureNote note = annotations.NotesOS[0];
			Assert.AreEqual("identical", ((IStTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents.Text);
			Assert.AreEqual("is", ((IStTxtPara)note.QuoteOA.ParagraphsOS[0]).Contents.Text);

			IScrScriptureNote maxNote = annotations.NotesOS[1];
			Assert.AreEqual("Maximum number of Dummy Check 1 errors exceeded.",
				((IStTxtPara)maxNote.DiscussionOA.ParagraphsOS[0]).Contents.Text);
			Assert.AreEqual("is", ((IStTxtPara)maxNote.QuoteOA.ParagraphsOS[0]).Contents.Text);
		}
コード例 #13
0
		public void RecordError_ErrorsWithNoMax()
		{
			// Setup a data source that does not set a limit on identical errors for all checks.
			// Setup three identical checking errors.
			DummyScrChecksDataSource dataSource = new DummyScrChecksDataSource(Cache, -1);
			DummyEditorialCheck check = new DummyEditorialCheck(kCheckId1);
			ScrCheckingToken tok = new DummyParaCheckingToken(m_scr, Cache.DefaultVernWs, 0);

			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 2, "identical"));
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 26, 2, "identical"));
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 37, 2, "identical"));

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

			// Run the Scripture check
			dataSource.GetText(tok.StartRef.Book, 0);
			dataSource.RunCheck(check);

			// We expect three identical error annotations to be created.
			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[tok.StartRef.Book - 1];
			Assert.AreEqual(3, annotations.NotesOS.Count,
				"Three error annotations should have been added.");
			// verify allowed identical annotations
			for (int iNote = 0; iNote < 3; iNote++)
			{
				// verify allowed identical annotations
				IScrScriptureNote note = annotations.NotesOS[iNote];
				Assert.AreEqual("identical", ((IStTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents.Text);
				Assert.AreEqual("is", ((IStTxtPara)note.QuoteOA.ParagraphsOS[0]).Contents.Text);
			}
		}
コード例 #14
0
		public void RecordError_ErrorsAlmostIdentical2()
		{
			// Setup a data source that warns the user on the second identical error that they
			// have exceeded the maximum.
			// Setup three identical checking errors.
			DummyScrChecksDataSource dataSource = new DummyScrChecksDataSource(Cache, 1);
			DummyEditorialCheck check = new DummyEditorialCheck(kCheckId1);
			ScrCheckingToken tok = new DummyParaCheckingToken(m_scr, Cache.DefaultVernWs, 0);

			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 5, 2, "identical"));
			// For this second error report, the message is different.
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 26, 2, "different"));
			check.m_ErrorsToReport.Add(new DummyEditorialCheck.DummyError(tok, 37, 2, "identical"));

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

			// Run the Scripture check
			dataSource.GetText(tok.StartRef.Book, 0);
			dataSource.RunCheck(check);

			// We expect three error annotations to be created: one for the only allowed error,
			// one with a message that is different, and one indicating that a maximum has been
			// exceeded. The cited text is identical in all three annotations.
			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[tok.StartRef.Book - 1];
			Assert.AreEqual(3, annotations.NotesOS.Count,
				"Three error annotations should have been added.");
			// verify allowed identical annotations
			IScrScriptureNote note = annotations.NotesOS[0];
			Assert.AreEqual("identical", ((IStTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents.Text);
			Assert.AreEqual("is", ((IStTxtPara)note.QuoteOA.ParagraphsOS[0]).Contents.Text);
			note = annotations.NotesOS[1];
			Assert.AreEqual("different", ((IStTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents.Text);
			Assert.AreEqual("is", ((IStTxtPara)note.QuoteOA.ParagraphsOS[0]).Contents.Text);

			// verify identical error exceeded annotation.
			IScrScriptureNote maxNote = annotations.NotesOS[2];
			Assert.AreEqual("Maximum number of Dummy Check 1 errors exceeded.",
				((IStTxtPara)maxNote.DiscussionOA.ParagraphsOS[0]).Contents.Text);
			Assert.AreEqual("is", ((IStTxtPara)maxNote.QuoteOA.ParagraphsOS[0]).Contents.Text);
		}