public void ScanTextWithDuplicateTerms() { MockTermTable table1 = new MockTermTable("file1"); MockTerm term1 = new MockTerm("foo", 1, "fooClass", "fooComment", "fooRecommended", table1); term1.AddExclusion("foo exclusion 1"); term1.AddExclusion("foo exclusion 2"); table1.AddSearchTerm(term1); MockTermTable table2 = new MockTermTable("file1"); MockTerm term2 = new MockTerm("foo", 1, "fooClass2", "fooComment2", "fooRecommended", table2); term2.AddExclusion("foo exclusion 2"); term2.AddExclusion("foo exclusion 3"); table2.AddSearchTerm(term2); IList <IScanHit> hits = InternalScanText("'foo exclusion 2' should be excluded, 'foo exclusion 1' and 'foo exclusion 3' should not", new ITermTable[] { table1, table2 }); Assert.AreEqual(2, hits.Count, "Search returned wrong number of hits."); Assert.AreEqual(term2, hits[0].Term, "Term property of hit 0 is incorrect."); Assert.AreEqual(0, hits[0].Line, "Line property of hit 0 is incorrect."); Assert.AreEqual(39, hits[0].Column, "Column property of hit 0 is incorrect."); Assert.IsNotNull(hits[0].Warning, "Hit 0 did not have a warning."); Assert.AreEqual(term1, hits[1].Term, "Term property of hit 1 is incorrect."); Assert.AreEqual(0, hits[1].Line, "Line property of hit 1 is incorrect."); Assert.AreEqual(61, hits[1].Column, "Column property of hit 1 is incorrect."); Assert.IsNotNull(hits[1].Warning, "Hit 0 did not have a warning."); }
public void ScanTextWithMultipleExclusions() { MockTermTable table = new MockTermTable("file1"); MockTerm term = new MockTerm("foo", 1, "fooClass", "fooComment", "fooRecommended", table); term.AddExclusion("first foo"); term.AddExclusion("second foo"); term.AddExclusion("third foo"); table.AddSearchTerm(term); IList <IScanHit> hits = InternalScanText("this first-foo will not exclude, but this second foo will, as will this third foo", new ITermTable[] { table }); Assert.AreEqual(1, hits.Count, "Search returned wrong number of hits."); Assert.AreEqual(term, hits[0].Term, "Term property of hit is incorrect."); Assert.AreEqual(0, hits[0].Line, "Line property of hit is incorrect."); Assert.AreEqual(11, hits[0].Column, "Column property of hit is incorrect."); }
public void ScanTextWithTermAppearingMultipleTimesInExclusion() { MockTermTable table = new MockTermTable("file1"); MockTerm term = new MockTerm("smurf", 1, "fooClass", "fooComment", "fooRecommended", table); term.AddExclusion("a smurf a day keeps the smurf away"); table.AddSearchTerm(term); IList <IScanHit> hits = InternalScanText("foo - a smurf a day keeps the smurf away - bar", new ITermTable[] { table }); Assert.AreEqual(0, hits.Count, "Search returned wrong number of hits."); }
public void ScanTextWithTermInMiddleOfExclusion() { MockTermTable table = new MockTermTable("file1"); MockTerm term = new MockTerm("abcdef", 1, "fooClass", "fooComment", "fooRecommended", table); term.AddExclusion("this time the term (abcdef) is in the middle"); table.AddSearchTerm(term); IList <IScanHit> hits = InternalScanText("foo - this time the term (abcdef) is in the middle - bar", new ITermTable[] { table }); Assert.AreEqual(0, hits.Count, "Search returned wrong number of hits."); }
public void ScanTextWithTermAtEndOfExclusion() { MockTermTable table = new MockTermTable("file1"); MockTerm term = new MockTerm("abcdef", 1, "fooClass", "fooComment", "fooRecommended", table); term.AddExclusion("the text at the end of this exclusion is abcdef"); table.AddSearchTerm(term); IList <IScanHit> hits = InternalScanText("the text at the end of this exclusion is abcdef", new ITermTable[] { table }); Assert.AreEqual(0, hits.Count, "Search returned wrong number of hits."); }
public void ScanTextWithDifferentCase() { MockTermTable table = new MockTermTable("file1"); MockTerm term = new MockTerm("foo", 1, "fooClass", "fooComment", "fooRecommended", table); term.AddExclusion("this Foo is excluded"); table.AddSearchTerm(term); IList <IScanHit> hits = InternalScanText("THIS FOO IS EXCLUDED, BUT THIS FOO IS NOT", new ITermTable[] { table }); Assert.AreEqual(1, hits.Count, "Search returned wrong number of hits."); Assert.AreEqual(term, hits[0].Term, "Term property of hit 0 is incorrect."); Assert.AreEqual(0, hits[0].Line, "Line property of hit 0 is incorrect."); Assert.AreEqual(31, hits[0].Column, "Column property of hit 0 is incorrect."); }
public void ScanTextWithTermPartiallyOverlappingExclusion() { MockTermTable table = new MockTermTable("file1"); MockTerm term = new MockTerm("foo", 1, "fooClass", "fooComment", "fooRecommended", table); term.AddExclusion("a foo is not a fo"); table.AddSearchTerm(term); IList <IScanHit> hits = InternalScanText("a foo is not a foo bar", new ITermTable[] { table }); Assert.AreEqual(1, hits.Count, "Search returned wrong number of hits."); Assert.AreEqual(term, hits[0].Term, "Term property of hit 0 is incorrect."); Assert.AreEqual(0, hits[0].Line, "Line property of hit 0 is incorrect."); Assert.AreEqual(15, hits[0].Column, "Column property of hit 0 is incorrect."); }
public void ScanTextWithExclusionPresentButSeparateFromTerm() { MockTermTable table = new MockTermTable("file1"); MockTerm term = new MockTerm("foo", 1, "fooClass", "fooComment", "fooRecommended", table); term.AddExclusion("this foo is excluded"); table.AddSearchTerm(term); IList <IScanHit> hits = InternalScanText("this foo is excluded; this foo is not", new ITermTable[] { table }); Assert.AreEqual(1, hits.Count, "Search returned wrong number of hits."); Assert.AreEqual(term, hits[0].Term, "Term property of hit 0 is incorrect."); Assert.AreEqual(0, hits[0].Line, "Line property of hit 0 is incorrect."); Assert.AreEqual(27, hits[0].Column, "Column property of hit 0 is incorrect."); }
public void ScanTextWithOtherTermsAppearingInExclusion() { MockTermTable table = new MockTermTable("file1"); MockTerm term1 = new MockTerm("foo", 1, "fooClass", "fooComment", "fooRecommended", table); term1.AddExclusion("a foo is not a bar"); MockTerm term2 = new MockTerm("bar", 1, "barClass", "barComment", "fooRecommended", table); table.AddSearchTerm(term1); table.AddSearchTerm(term2); IList <IScanHit> hits = InternalScanText("a foo is not a bar", new ITermTable[] { table }); Assert.AreEqual(1, hits.Count, "Search returned wrong number of hits."); Assert.AreEqual(term2, hits[0].Term, "Term property of hit is incorrect."); Assert.AreEqual(0, hits[0].Line, "Line property of hit is incorrect."); Assert.AreEqual(15, hits[0].Column, "Column property of hit is incorrect."); }
public void ScanTextWithOverlappingExclusionsWhenSecondExclusionIsInvalidatedFirst() { MockTermTable table = new MockTermTable("file1"); MockTerm term1 = new MockTerm("foo", 1, "fooClass", "fooComment", "fooRecommended", table); term1.AddExclusion("abc foo then bar and some more text"); MockTerm term2 = new MockTerm("bar", 1, "barClass", "barComment", "fooRecommended", table); term2.AddExclusion("foo then bar and some more"); table.AddSearchTerm(term1); table.AddSearchTerm(term2); IList <IScanHit> hits = InternalScanText("abc foo then bar and some morINVALIDATED", new ITermTable[] { table }); Assert.AreEqual(2, hits.Count, "Search returned wrong number of hits."); Assert.AreEqual(term1, hits[0].Term, "Term property of hit 0 is incorrect."); Assert.AreEqual(0, hits[0].Line, "Line property of hit 0 is incorrect."); Assert.AreEqual(4, hits[0].Column, "Column property of hit 0 is incorrect."); Assert.AreEqual(term2, hits[1].Term, "Term property of hit 1 is incorrect."); Assert.AreEqual(0, hits[1].Line, "Line property of hit 1 is incorrect."); Assert.AreEqual(13, hits[1].Column, "Column property of hit 1 is incorrect."); }