public void SetUp() { // Set up SearchOptions required by the BruteForceSearchStrategy. SearchOptions.CurrentFindPattern = "foo"; SearchOptions.MatchCase = false; SearchOptions.MatchWholeWord = false; // Create search. search = new Search(); search.TextIteratorBuilder = new ForwardTextIteratorBuilder(); search.SearchStrategy = new BruteForceSearchStrategy(); MockCurrentDocumentIterator currentDocIterator = new MockCurrentDocumentIterator(); search.DocumentIterator = currentDocIterator; // Create the document to be searched. MockDocument doc = new MockDocument(); StringTextBufferStrategy textBufferStrategy = new StringTextBufferStrategy(); textBufferStrategy.SetContent("foo"); doc.TextBufferStrategy = textBufferStrategy; // Create a doc info with an initial end offset right // at the end of the text. ProvidedDocumentInformation docInfo = new ProvidedDocumentInformation(doc, @"C:\Temp\test.txt", doc.TextLength); currentDocIterator.Current = docInfo; currentDocIterator.CurrentFileName = docInfo.FileName; // Search the document. search.SearchStrategy.CompilePattern(null); result = search.FindNext(null); }
public static ITextBufferStrategy CreateTextBufferFromFile(string fileName) { if (!File.Exists(fileName)) { throw new System.IO.FileNotFoundException(fileName); } StringTextBufferStrategy s = new StringTextBufferStrategy(); s.SetContent(Util.FileReader.ReadFileContent(fileName, Encoding.Default)); return s; }
public static ITextBufferStrategy CreateTextBufferFromFile(string fileName) { if (!File.Exists(fileName)) { throw new FileNotFoundException(fileName); } StringTextBufferStrategy stringTextBufferStrategy = new StringTextBufferStrategy(); stringTextBufferStrategy.SetContent(FileReader.ReadFileContent(fileName, Encoding.Default)); return(stringTextBufferStrategy); }
public void SetUp() { // Create the document to be iterated through. MockDocument doc = new MockDocument(); StringTextBufferStrategy textBufferStrategy = new StringTextBufferStrategy(); textBufferStrategy.SetContent("bar"); doc.TextBufferStrategy = textBufferStrategy; // Create a doc info with an initial end offset right // at the end of the text. ProvidedDocumentInformation docInfo = new ProvidedDocumentInformation(doc, @"C:\Temp\test.txt", doc.TextLength); // Create the forward iterator. forwardTextIterator = new ForwardTextIterator(docInfo); }