Beispiel #1
0
		public void RecordError_PictureCaptionToken()
		{
			ScrChecksDataSource dataSource = new ScrChecksDataSource(Cache);
			ScrCheckingToken tok = new DummyPictureCheckingToken(m_scr, Cache.DefaultUserWs, "en");

			Dictionary<int, Dictionary<Guid, ScrCheckRunResult>> bkChkFailedLst =
				new Dictionary<int, Dictionary<Guid, ScrCheckRunResult>>();
			bkChkFailedLst[tok.StartRef.Book] = new Dictionary<Guid, ScrCheckRunResult>();
			bkChkFailedLst[tok.StartRef.Book][kCheckId1] = ScrCheckRunResult.NoInconsistencies;
			ReflectionHelper.SetField(dataSource, "m_bookChecksFailed", bkChkFailedLst);

			TextTokenSubstring tts = new TextTokenSubstring(tok, 15, 9, "Weird bilingual picture caption");
			dataSource.RecordError(new RecordErrorEventArgs(tts, kCheckId1));
			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[tok.StartRef.Book - 1];
			IScrScriptureNote note = annotations.NotesOS[0];
			Assert.IsNotNull(note);
			Assert.AreEqual(NoteType.CheckingError, note.AnnotationType);
			Assert.AreEqual(m_scr, note.BeginObjectRA);
			Assert.AreEqual(m_scr, note.EndObjectRA);
			Assert.AreEqual(15, note.BeginOffset);
			Assert.AreEqual(24, note.EndOffset);
			Assert.AreEqual(0, note.CategoriesRS.Count);
			Assert.AreEqual(1, note.QuoteOA.ParagraphsOS.Count);
			ITsStrFactory factory = TsStrFactoryClass.Create();
			ITsString tssQuote = factory.MakeString("in Monroe", Cache.DefaultUserWs);
			AssertEx.AreTsStringsEqual(tssQuote, ((StTxtPara)note.QuoteOA.ParagraphsOS[0]).Contents.UnderlyingTsString);
			Assert.AreEqual(1, note.DiscussionOA.ParagraphsOS.Count);
			Assert.AreEqual("Weird bilingual picture caption", ((StTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents.Text);
			Assert.AreEqual(NoteStatus.Open, note.ResolutionStatus);
			VerifyEmptyStJournalText(note.RecommendationOA);
			VerifyEmptyStJournalText(note.ResolutionOA);
			Assert.AreEqual((int)CmPicture.CmPictureTags.kflidCaption, note.Flid);
			Assert.AreEqual(Cache.DefaultVernWs, note.WsSelector);
			Assert.AreEqual(01003034, note.BeginRef);
			Assert.AreEqual(01003034, note.EndRef);
			Assert.AreEqual(Cache.LangProject.DefaultComputerAgent, note.SourceRA);
		}
Beispiel #2
0
		public void RecordError_ParaContentsToken_SecondRun()
		{
			ScrChecksDataSource dataSource = new ScrChecksDataSource(Cache);
			ScrCheckingToken tok = new DummyParaCheckingToken(m_scr, Cache.DefaultVernWs, 10);

			Dictionary<int, Dictionary<Guid, ScrCheckRunResult>> bkChkFailedLst =
				new Dictionary<int, Dictionary<Guid, ScrCheckRunResult>>();
			bkChkFailedLst[tok.StartRef.Book] = new Dictionary<Guid, ScrCheckRunResult>();
			bkChkFailedLst[tok.StartRef.Book][kCheckId1] = ScrCheckRunResult.NoInconsistencies;
			ReflectionHelper.SetField(dataSource, "m_bookChecksFailed", bkChkFailedLst);

			TextTokenSubstring tts = new TextTokenSubstring(tok, 5, 8, "Lousy message");
			dataSource.RecordError(new RecordErrorEventArgs(tts, kCheckId1));
			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[tok.StartRef.Book - 1];
			IScrScriptureNote note = annotations.NotesOS[0];
			Assert.IsNotNull(note);
			Assert.AreEqual(NoteType.CheckingError, note.AnnotationType);
			Assert.AreEqual(m_scr, note.BeginObjectRA);
			Assert.AreEqual(m_scr, note.EndObjectRA);
			Assert.AreEqual(15, note.BeginOffset);
			Assert.AreEqual(23, note.EndOffset);
			Assert.AreEqual(0, note.CategoriesRS.Count);
			Assert.AreEqual(1, note.QuoteOA.ParagraphsOS.Count);
			ITsStrFactory factory = TsStrFactoryClass.Create();
			ITsString tssQuote = factory.MakeString("is lousy", Cache.DefaultVernWs);
			AssertEx.AreTsStringsEqual(tssQuote, ((StTxtPara)note.QuoteOA.ParagraphsOS[0]).Contents.UnderlyingTsString);
			Assert.AreEqual(1, note.DiscussionOA.ParagraphsOS.Count);
			Assert.AreEqual("Lousy message", ((StTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents.Text);
			Assert.AreEqual(NoteStatus.Open, note.ResolutionStatus);
			VerifyEmptyStJournalText(note.RecommendationOA);
			VerifyEmptyStJournalText(note.ResolutionOA);
			Assert.AreEqual((int)StTxtPara.StTxtParaTags.kflidContents, note.Flid);
			// TODO: Test this for an annotation on a CmPicture: Assert.AreEqual(0, note.WsSelector);
			Assert.AreEqual(01003034, note.BeginRef);
			Assert.AreEqual(01003034, note.EndRef);
			// TODO: Assert.AreEqual(???, note.SourceRA);
		}