示例#1
0
 public void SearchTestAllOccurencesOfLongString()
 {
     // Find all occurences of "First man on moon Neil Armstrong dead at 82"
     indexMatches = Program.Search(text, "First man on moon Neil Armstrong dead at 82");
     // There is 1 occurence
     Assert.AreEqual(1, indexMatches.Count());
     // The occurence is between index 0 and 42
     Assert.AreEqual(42, indexMatches[0].Start + indexMatches[0].End);
     Assert.IsTrue(indexMatches[0].Start < indexMatches[0].End);
 }
示例#2
0
 public void SearchTestAllOccurencesTwoChars()
 {
     // Find all occurences of "sa".
     indexMatches = Program.Search(text, "sa");
     // There are 4 occurences of "sa"
     Assert.AreEqual(4, indexMatches.Count());
     // The first occurence of "sa" is between index 51 and 52
     Assert.AreEqual(51 + 52, indexMatches[0].Start + indexMatches[0].End);
     Assert.IsTrue(indexMatches[0].Start < indexMatches[0].End);
     // The second occurence of "sa" is between index 250 and 251
     Assert.AreEqual(250 + 251, indexMatches[1].Start + indexMatches[1].End);
     Assert.IsTrue(indexMatches[0].Start < indexMatches[0].End);
     // The third occurence of "sa" is between index 258 and 259
     Assert.AreEqual(258 + 259, indexMatches[2].Start + indexMatches[2].End);
     Assert.IsTrue(indexMatches[0].Start < indexMatches[0].End);
     // The second occurence of "sa" is between index 330 and 331
     Assert.AreEqual(330 + 331, indexMatches[3].Start + indexMatches[3].End);
     Assert.IsTrue(indexMatches[0].Start < indexMatches[0].End);
 }
示例#3
0
 public void SearchTestEmptySearch()
 {
     // Test for ""
     try
     {
         indexMatches = Program.Search(text, "");
         Assert.Fail();
     }
     catch (ArgumentNullException e)
     {
         //We are all happy now! =)
     }
 }
示例#4
0
 public void GetTestFile()
 {
     // The test text
     text = TextFileReader.ReadFile(@"..\..\..\testFile.txt");
     indexMatches = null;
 }
示例#5
0
 public void SerchTestAllOccurences1()
 {
     // Find all occurences of "il ar"
     indexMatches = Program.Search(text, "il+ar");
     // There are 2 occurences
     Assert.AreEqual(2, indexMatches.Count());
     // The first occurence is between index 20 and 24
     Assert.AreEqual(20 + 24, indexMatches[0].Start + indexMatches[0].End);
     Assert.IsTrue(indexMatches[0].Start < indexMatches[0].End);
     // The second occurence is between index 111 and 115
     Assert.AreEqual(111 + 115, indexMatches[1].Start + indexMatches[1].End);
     Assert.IsTrue(indexMatches[0].Start < indexMatches[0].End);
 }
示例#6
0
 public void SearchTestStartingChars()
 {
     // Find all occurences with "arm" as starting characters
     indexMatches = Program.Search(text, "arm*");
     // There are 2 occurences
     Assert.AreEqual(2, indexMatches.Count());
     // The first occurence is between index 23 and 31
     Assert.AreEqual(23 + 31, indexMatches[0].Start + indexMatches[0].End);
     Assert.IsTrue(indexMatches[0].Start < indexMatches[0].End);
     // The second occurence is between index 114 and 122
     Assert.AreEqual(114 + 122, indexMatches[1].Start + indexMatches[1].End);
     Assert.IsTrue(indexMatches[0].Start < indexMatches[0].End);
 }
示例#7
0
 public void SearchTestEndingChars()
 {
     // Find all occurences with "ad" as ending characters
     indexMatches = Program.Search(text, "*ad");
     // There is 1 occurence
     Assert.AreEqual(1, indexMatches.Count());
     // The occurence is between index 33 and 36
     Assert.AreEqual(33 + 36, indexMatches[0].Start + indexMatches[0].End);
     Assert.IsTrue(indexMatches[0].Start < indexMatches[0].End);
 }