コード例 #1
0
		public void TestAddSingleConditionForMultipleRanges()
		{
			WsMatchInRangeCollection matchInRangeCollection = new WsMatchInRangeCollection();
			Assert.AreEqual(0, matchInRangeCollection.Count);
			ArrayList matchesInParagraph = new ArrayList();
			const string scanText = "Test text";
			const string testConditionIndex = "TestTextIndex";
			matchesInParagraph.Add(scanText);
			matchesInParagraph.Add(scanText);
			WsMatchInRange matchInParagraphRange = new WsMatchInRange(RangeTypes.Paragraph, testConditionIndex, matchesInParagraph);
			matchInRangeCollection.Add(matchInParagraphRange);
			Assert.AreEqual(1, matchInRangeCollection.Count, "Expected the collection count to be one");
			Assert.AreEqual(2, matchInRangeCollection.TotalMatchCount, "Expected the total match count to be two");

			ArrayList matchesInComment = new ArrayList();
			matchesInComment.Add(scanText);
			WsMatchInRange matchInCommentRange = new WsMatchInRange(RangeTypes.Comment, testConditionIndex, matchesInComment);
			matchInRangeCollection.Add(matchInCommentRange);

			Assert.AreEqual(2, matchInRangeCollection.Count, "Expected the collection count to be two, one for paragraph and one for comment");
			Assert.AreEqual(1, matchInRangeCollection.GetMatches(RangeTypes.Paragraph, testConditionIndex).Count, "Expected the collection count for paragraphs to be one");
			Assert.AreEqual(1, matchInRangeCollection.GetMatches(RangeTypes.Comment, testConditionIndex).Count, "Expected the collection count for comments to be one");

			Assert.AreEqual(3, matchInRangeCollection.TotalMatchCount, "Expected the total match count to be three");
			Assert.AreEqual(2, matchInRangeCollection.GetMatches(RangeTypes.Paragraph, testConditionIndex).TotalMatchCount, "Expected the match count for comments to be two");
			Assert.AreEqual(1, matchInRangeCollection.GetMatches(RangeTypes.Comment, testConditionIndex).TotalMatchCount, "Expected the match count for comments to be one");
		}
コード例 #2
0
		public void TestAddMultipleConditionsForSingleRange()
		{
			WsMatchInRangeCollection matchInRangeCollection = new WsMatchInRangeCollection();
			Assert.AreEqual(0, matchInRangeCollection.Count);
			ArrayList matchesInParagraph = new ArrayList();
			const string scanText = "Test text";
			const string testConditionIndex = "TestTextIndex";
			matchesInParagraph.Add(scanText);
			matchesInParagraph.Add(scanText);
			WsMatchInRange matchInParagraphRange = new WsMatchInRange(RangeTypes.Paragraph, testConditionIndex, matchesInParagraph);
			matchInRangeCollection.Add(matchInParagraphRange);
			Assert.AreEqual(1, matchInRangeCollection.Count, "Expected the collection count to be one");
			Assert.AreEqual(2, matchInRangeCollection.TotalMatchCount, "Expected the total match count to be two");

			ArrayList matchesInParagraphRange2 = new ArrayList();
			const string scanText2 = "This is more text to find";
			const string testConditionIndex2 = "TestTextIndex2";
			matchesInParagraphRange2.Add(scanText2);
			WsMatchInRange matchInParagraphRange2 = new WsMatchInRange(RangeTypes.Paragraph, testConditionIndex2, matchesInParagraphRange2);
			matchInRangeCollection.Add(matchInParagraphRange2);

			Assert.AreEqual(2, matchInRangeCollection.Count, "Expected the collection count to be two, one for paragraph for first condition and one for paragraph for second condition");
			Assert.AreEqual(1, matchInRangeCollection.GetMatches(RangeTypes.Paragraph, testConditionIndex).Count, "Expected the collection count for paragraphs of first condition to be one");
			Assert.AreEqual(1, matchInRangeCollection.GetMatches(RangeTypes.Paragraph, testConditionIndex2).Count, "Expected the collection count for paragraphs of second condition to be one");

			Assert.AreEqual(3, matchInRangeCollection.TotalMatchCount, "Expected the total match count to be three");
			Assert.AreEqual(2, matchInRangeCollection.GetMatches(RangeTypes.Paragraph, testConditionIndex).TotalMatchCount, "Expected the match count for first condition to be two");
			Assert.AreEqual(1, matchInRangeCollection.GetMatches(RangeTypes.Paragraph, testConditionIndex2).TotalMatchCount, "Expected the match count for second condition to be one");
		}