SIL.FieldWorks.FDO.FDOTests.FdoTestHelper.VerifyAnalysis C# (CSharp) Method

VerifyAnalysis() public static method

Verifies the analysis for the given segment.
public static VerifyAnalysis ( ISegment seg, int iSeg, IEnumerable expectedFormsWithoutAnalyses, IEnumerable expectedWordforms ) : void
seg ISegment The segment.
iSeg int The index of the segment in the paragraph.
expectedFormsWithoutAnalyses IEnumerable List of indices of wordforms which are /// not expected to have any analyses.
expectedWordforms IEnumerable List of indices of analyses that are expected to be /// word forms, rather than glosses (these should correspond to whole words that did not /// survive the resegmentation)
return void
		public static void VerifyAnalysis(ISegment seg, int iSeg,
			IEnumerable<int> expectedFormsWithoutAnalyses, IEnumerable<int> expectedWordforms)
		{
			string baseline = seg.BaselineText.Text;

			if (seg.IsLabel)
			{
				// We don't really care about analyses in label segments, but if we do have one, it better
				// be a punctuation form that exactly matches the segment's baseline.
				Assert.IsTrue(seg.AnalysesRS.Count == 0 ||
					(seg.AnalysesRS.Count == 1 && ((IPunctuationForm)seg.AnalysesRS[0]).Form.Text == baseline));
				return;
			}

			int cAnalysis = ParseSegBaseline(seg, seg.BeginOffset, seg.EndOffset,
				(iForm, word, iAnalysis) => VerifyWfi(seg, iForm, word, iAnalysis, expectedFormsWithoutAnalyses, expectedWordforms),
				(puncForm, iAnalysis) => VerifyPunctuationForm(seg, puncForm, iAnalysis),
				(ich, iAnalysis) =>
				{
					ITsString form = VerifyPunctuationForm(seg, StringUtils.kszObject, iAnalysis);
					FwObjDataTypes odt, odtExpected;
					TsRunInfo tri;
					ITsTextProps ttp;
					Guid guid = TsStringUtils.GetGuidFromRun(form, 0, out odt, out tri, out ttp, null);
					Assert.AreEqual(TsStringUtils.GetGuidFromProps(
						seg.BaselineText.get_PropertiesAt(ich), null, out odtExpected), guid);
					Assert.AreEqual(odtExpected, odt);
				});

			Assert.AreEqual(cAnalysis, seg.AnalysesRS.Count, "Segment " + iSeg + " (" +
				seg.BaselineText.Text + ") had too many analyses");
		}

Usage Example

Example #1
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Verifies the free translations for the segments of the specified paragraph.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 private static void VerifyParaSegments(IStTxtPara para, params string[] segmentFTs)
 {
     Assert.AreEqual(segmentFTs.Length, para.SegmentsOS.Count);
     for (int i = 0; i < segmentFTs.Length; i++)
     {
         Assert.AreEqual(segmentFTs[i], para.SegmentsOS[i].FreeTranslation.AnalysisDefaultWritingSystem.Text,
                         "Free translation for segment " + i + " is wrong");
         FdoTestHelper.VerifyAnalysis(para.SegmentsOS[i], i, new int[0], new int[0]);
     }
 }