本文整理汇总了C#中SearchResult.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SearchResult.ToString方法的具体用法?C# SearchResult.ToString怎么用?C# SearchResult.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchResult
的用法示例。
在下文中一共展示了SearchResult.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestToString
public void TestToString()
{
SearchResult result1 = new SearchResult() { Index = 0, Exists = true };
Assert.AreEqual("Exists = True, Index = 0", result1.ToString(), "The wrong string representation was returned."); // implicit conversion
SearchResult result2 = new SearchResult() { Index = 1, Exists = false };
Assert.AreEqual("Exists = False, Index = 1", result2.ToString(), "The wrong string representation was returned."); // implicit conversion
}
示例2: SearchResultMultiLine_ToString_EqualsExpected
public void SearchResultMultiLine_ToString_EqualsExpected()
{
var settings = new SearchSettings();
var pattern = new Regex("Search");
var searchFile = new SearchFile(CsSearchPath, "Searcher.cs", FileType.Text);
var lineNum = 10;
var matchStartIndex = 15;
var matchEndIndex = 23;
var line = "\tpublic class Searcher";
var linesBefore = new List<string> { "namespace CsSearch", "{" };
var linesAfter = new List<string> {"\t{", "\t\tprivate readonly FileTypes _fileTypes;"};
var searchResult = new SearchResult(pattern, searchFile, lineNum,
matchStartIndex, matchEndIndex,
line, linesBefore, linesAfter);
var expectedPath = CsSearchPath + "/Searcher.cs";
var expectedOutput = string.Format(new string('=', 80) + "\n" +
"{0}: {1}: [{2}:{3}]\n" +
new string('-', 80) + "\n" +
" 8 | namespace CsSearch\n" +
" 9 | {{\n" +
"> 10 | public class Searcher\n" +
" 11 | {{\n" +
" 12 | private readonly FileTypes _fileTypes;\n",
expectedPath, lineNum, matchStartIndex, matchEndIndex);
Assert.AreEqual(searchResult.ToString(settings), expectedOutput);
}
示例3: SearchResultBinaryFile_ToString_EqualsExpected
public void SearchResultBinaryFile_ToString_EqualsExpected()
{
var settings = new SearchSettings();
var pattern = new Regex("Search");
var searchFile = new SearchFile(CsSearchPath, "Searcher.exe", FileType.Binary);
var lineNum = 0;
var matchStartIndex = 0;
var matchEndIndex = 0;
string line = null;
var searchResult = new SearchResult(pattern, searchFile, lineNum,
matchStartIndex, matchEndIndex, line);
var expectedPath = CsSearchPath + "/Searcher.exe";
var expectedOutput = string.Format("{0} matches", expectedPath);
Assert.AreEqual(searchResult.ToString(settings), expectedOutput);
}
示例4: SearchResultSingleLine_ToString_EqualsExpected
public void SearchResultSingleLine_ToString_EqualsExpected()
{
var settings = new SearchSettings();
var pattern = new Regex("Search");
var searchFile = new SearchFile(CsSearchPath, "Searcher.cs", FileType.Text);
var lineNum = 10;
var matchStartIndex = 15;
var matchEndIndex = 23;
var line = "\tpublic class Searcher\n";
var searchResult = new SearchResult(pattern, searchFile, lineNum,
matchStartIndex, matchEndIndex, line);
var expectedPath = CsSearchPath + "/Searcher.cs";
var expectedOutput = string.Format("{0}: {1}: [{2}:{3}]: {4}", expectedPath,
lineNum, matchStartIndex, matchEndIndex, line.Trim());
Assert.AreEqual(searchResult.ToString(settings), expectedOutput);
}