private void ContentHelper(string context, string searchText) { TestPolicyHelper.DeleteWorkingPolicy(); TestPolicyHelper.CreateTestPolicy("TestProject", searchText, context); MockStrategyEventSink mockStrategyEventSink = new MockStrategyEventSink(); ContentDiscoveryStrategy strategy = new ContentDiscoveryStrategy(); mockStrategyEventSink.Advise(strategy); Assert.AreEqual(0, mockStrategyEventSink.Content.Count); strategy.Execute(m_testPath + "TestValidFile.doc", null); Assert.AreEqual(1, mockStrategyEventSink.Content.Count); string expectedContent = "<DISRules>" + "<rule name=\"Find text\" level=\"High\">" + "<results>" + "<result match=\"" + searchText + "\" context=\"" + context + "\" count=\"1\" />" + "</results>" + "</rule>" + "</DISRules>"; Assert.AreEqual(expectedContent, (string)mockStrategyEventSink.Content[0]); }
private void ContentHelper(string testFilename) { if (m_testPath.Substring(0, 2).ToLower() != "p:") { System.Reflection.Module module = System.Reflection.Assembly.GetCallingAssembly().ManifestModule; string path = System.IO.Path.GetDirectoryName(module.FullyQualifiedName).ToLower(); path = path.Substring(0, path.IndexOf(@"\win32")); if (!m_testPath.StartsWith(path)) { m_testPath = path + m_testPath; } } string filename = m_testPath + System.IO.Path.GetFileNameWithoutExtension(testFilename); string expectedFilename = filename + ".Expected.xml"; string exclusionFilename = filename + ".Exclusions.xml"; MockStrategyEventSink mockStrategyEventSink = new MockStrategyEventSink(); ContentDiscoveryStrategy strategy = new ContentDiscoveryStrategy(); mockStrategyEventSink.Advise(strategy); Assert.AreEqual(0, mockStrategyEventSink.Content.Count); strategy.Execute(m_testPath + testFilename, null); Assert.AreEqual(1, mockStrategyEventSink.Content.Count); string results = (string)mockStrategyEventSink.Content[0]; TestHelpers.VerifyReportResults(results, expectedFilename); TestHelpers.ShouldNotContain(results, exclusionFilename); }
public void TestContentNotDiscovered() { TestPolicyHelper.DeleteWorkingPolicy(); TestPolicyHelper.CreateTestPolicy("TestProject", "(?:Password)\\s*[\\=|:|;|\\-|is]+\\s*.*", "Paragraph"); MockStrategyEventSink mockStrategyEventSink = new MockStrategyEventSink(); ContentDiscoveryStrategy strategy = new ContentDiscoveryStrategy(); mockStrategyEventSink.Advise(strategy); Assert.AreEqual(0, mockStrategyEventSink.Content.Count); strategy.Execute(m_testPath + "Cravath_contentrisk.doc", null); string expectedContent = "<DISRules>" + "<rule name=\"Find text\" level=\"High\">" + "<results>" + "<result match=\"" + "password: mickey
" + "\" context=\"" + "Paragraph" + "\" count=\"1\" />" + "</results>" + "</rule>" + "</DISRules>"; Assert.AreEqual(expectedContent, (string)mockStrategyEventSink.Content[0]); }