Exemplo n.º 1
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"));

			m_scrInMemoryCache.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", ((StTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents.Text);
			Assert.AreEqual("is", ((StTxtPara)note.QuoteOA.ParagraphsOS[0]).Contents.Text);
		}
Exemplo n.º 2
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"));

			m_scrInMemoryCache.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", ((StTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents.Text);
			Assert.AreEqual("is", ((StTxtPara)note.QuoteOA.ParagraphsOS[0]).Contents.Text);

			IScrScriptureNote maxNote = annotations.NotesOS[1];
			Assert.AreEqual("Maximum number of Dummy Check 1 errors exceeded.",
				((StTxtPara)maxNote.DiscussionOA.ParagraphsOS[0]).Contents.Text);
			Assert.AreEqual("is", ((StTxtPara)maxNote.QuoteOA.ParagraphsOS[0]).Contents.Text);
		}
Exemplo n.º 3
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"));

			m_scrInMemoryCache.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", ((StTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents.Text);
			Assert.AreEqual("is", ((StTxtPara)note.QuoteOA.ParagraphsOS[0]).Contents.Text);
			note = annotations.NotesOS[1];
			Assert.AreEqual("different", ((StTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents.Text);
			Assert.AreEqual("is", ((StTxtPara)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.",
				((StTxtPara)maxNote.DiscussionOA.ParagraphsOS[0]).Contents.Text);
			Assert.AreEqual("is", ((StTxtPara)maxNote.QuoteOA.ParagraphsOS[0]).Contents.Text);
		}
Exemplo n.º 4
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"));

			m_scrInMemoryCache.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", ((StTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents.Text);
				Assert.AreEqual("is", ((StTxtPara)note.QuoteOA.ParagraphsOS[0]).Contents.Text);
			}
		}
Exemplo n.º 5
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"));

			m_scrInMemoryCache.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", ((StTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents.Text);
				Assert.AreEqual("is", ((StTxtPara)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.",
				((StTxtPara)maxNote.DiscussionOA.ParagraphsOS[0]).Contents.Text);
			Assert.AreEqual("is", ((StTxtPara)maxNote.QuoteOA.ParagraphsOS[0]).Contents.Text);
		}