当前位置: 首页>>代码示例>>C#>>正文


C# SearchResult.ToString方法代码示例

本文整理汇总了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
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:SearchResultTester.cs

示例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);
 }
开发者ID:clarkcb,项目名称:xsearch,代码行数:26,代码来源:SearchResultTests.cs

示例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);
        }
开发者ID:clarkcb,项目名称:xsearch,代码行数:16,代码来源:SearchResultTests.cs

示例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);
        }
开发者ID:clarkcb,项目名称:xsearch,代码行数:17,代码来源:SearchResultTests.cs


注:本文中的SearchResult.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。