Exemplo n.º 1
0
		public string GetContent()
		{
			XMLContentBuilder xmlContentBuilder = new XMLContentBuilder(m_scanRules);
			return xmlContentBuilder.BuildContent(m_results);
		}
Exemplo n.º 2
0
		public void TestBuildContentNoContext()
		{
			const string expectedContent = 
					  "<DISRules>" +
					  "<rule name=\"Find some\" level=\"High\">" +
					  "<results>" +
					  "<result match=\"Some\" context=\"Paragraph\" count=\"2\" />" +
					  "<result match=\"some\" context=\"Comment\" count=\"3\" />" +
					  "</results>" +
					  "</rule>" +
					  "</DISRules>";

			WsScanRules scanRules = new WsScanRules();
			WsScanRule findSomeRule = new WsScanRule("Rule 1", "Find some", "some", RuleLevels.High);
			scanRules.Add(findSomeRule);

			WsMatchInRangeCollection results = new WsMatchInRangeCollection();
			
			ArrayList someDataInParagraph = new ArrayList();
			someDataInParagraph.Add("Some");
			someDataInParagraph.Add("Some");
			results.Add(new WsMatchInRange(RangeTypes.Paragraph, findSomeRule.Condition, someDataInParagraph));

			ArrayList someDataInComment = new ArrayList();
			someDataInComment.Add("some");
			someDataInComment.Add("some");
			someDataInComment.Add("some");
			results.Add(new WsMatchInRange(RangeTypes.Comment, findSomeRule.Condition, someDataInComment));

			XMLContentBuilder xmlContentBuilder = new XMLContentBuilder(scanRules);
			string xmlContent = xmlContentBuilder.BuildContent(results);
			Assert.AreEqual(expectedContent, xmlContent);
		}
Exemplo n.º 3
0
		public void TestBuildContentNoResults()
		{
			const string expectedContent = "<DISRules />";

			WsScanRules scanRules = new WsScanRules();
			WsScanRule findSomeRule = new WsScanRule("Rule 1", "Find not exist", "not exist", RuleLevels.High);
			findSomeRule.Ranges.Add(RangeTypes.Paragraph);
			scanRules.Add(findSomeRule);

			XMLContentBuilder xmlContentBuilder = new XMLContentBuilder(scanRules);
			string xmlContent = xmlContentBuilder.BuildContent(new WsMatchInRangeCollection());
			Assert.AreEqual(expectedContent, xmlContent);
		}
Exemplo n.º 4
0
		public void TestBuildContent()
		{
			string expectedContent = 
					  "<DISRules>" +
					  "<rule name=\"Find some\" level=\"High\">" +
					  "<results>" +
					  "<result match=\"some\" context=\"Paragraph\" count=\"1\" />" +
					  "<result match=\"Some\" context=\"Paragraph\" count=\"2\" />" +
					  "</results>" +
					  "</rule>" +
					  "<rule name=\"Find that\" level=\"Medium\">" +
					  "<results>" +
					  "<result match=\"that\" context=\"Paragraph\" count=\"3\" />" +
					  "</results>" +
					  "</rule>" +
					  "</DISRules>";

			if (Is64Bit())
				expectedContent = "<DISRules>" +
					  "<rule name=\"Find some\" level=\"High\">" +
					  "<results>" +
					  "<result match=\"Some\" context=\"Paragraph\" count=\"2\" />" +
					  "<result match=\"some\" context=\"Paragraph\" count=\"1\" />" +
					  "</results>" +
					  "</rule>" +
					  "<rule name=\"Find that\" level=\"Medium\">" +
					  "<results>" +
					  "<result match=\"that\" context=\"Paragraph\" count=\"3\" />" +
					  "</results>" +
					  "</rule>" +
					  "</DISRules>";



			WsScanRules scanRules = new WsScanRules();
			WsScanRule findSomeRule = new WsScanRule("Rule 1", "Find some", "some", RuleLevels.High);
			findSomeRule.Ranges.Add(RangeTypes.Paragraph);
			scanRules.Add(findSomeRule);

			WsScanRule findThatRule = new WsScanRule("Rule 2", "Find that", "that", RuleLevels.Medium);
			findThatRule.Ranges.Add(RangeTypes.Paragraph);
			scanRules.Add(findThatRule);

			WsMatchInRangeCollection results = new WsMatchInRangeCollection();
			
			ArrayList someData = new ArrayList();
			someData.Add("Some");
			someData.Add("Some");
			someData.Add("some");
			results.Add(new WsMatchInRange(RangeTypes.Paragraph, findSomeRule.Condition, someData));

			ArrayList thatData = new ArrayList();
			thatData.Add("that");
			thatData.Add("that");
			thatData.Add("that");
			results.Add(new WsMatchInRange(RangeTypes.Paragraph, findThatRule.Condition, thatData));

			XMLContentBuilder xmlContentBuilder = new XMLContentBuilder(scanRules);
			string xmlContent = xmlContentBuilder.BuildContent(results);
			Assert.AreEqual(expectedContent, xmlContent);
		}