コード例 #1
0
        public async Task FindSourceDeclarationsWithPatternAsync_Project_Test(WorkspaceKind workspaceKind, string[] expectedResults)
        {
            var project      = GetProject(workspaceKind);
            var declarations = await SymbolFinder.FindSourceDeclarationsWithPatternAsync(project, "test").ConfigureAwait(false);

            Verify(workspaceKind, declarations, expectedResults);
        }
コード例 #2
0
        public async Task FindSourceDeclarationsWithPatternAsync_Solution_Test(WorkspaceKind workspaceKind, string[] expectedResult)
        {
            var solution     = GetSolution(workspaceKind);
            var declarations = await SymbolFinder.FindSourceDeclarationsWithPatternAsync(solution, "test").ConfigureAwait(false);

            Verify(workspaceKind, declarations, expectedResult);
        }
コード例 #3
0
        public async Task FindSourceDeclarationsAsync_Solution_Func_Test(WorkspaceKind workspaceKind, string[] expectedResult)
        {
            var solution     = GetSolution(workspaceKind);
            var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, str => str.Contains("Test")).ConfigureAwait(false);

            Verify(workspaceKind, declarations, expectedResult);
        }
コード例 #4
0
        public async Task FindSourceDeclarationsAsync_Project_Func_Test(WorkspaceKind workspaceKind, string[] expectedResults)
        {
            var project      = GetProject(workspaceKind);
            var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, str => str.Contains("Test")).ConfigureAwait(false);

            Verify(workspaceKind, declarations, expectedResults);
        }
        private static Solution GetSolution(WorkspaceKind workspaceKind)
        {
            switch (workspaceKind)
            {
            case WorkspaceKind.SingleClass:
                return(GetSingleProjectSolution(SingleClass));

            case WorkspaceKind.SingleClassWithSingleMethod:
                return(GetSingleProjectSolution(SingleClassWithSingleMethod));

            case WorkspaceKind.SingleClassWithSingleProperty:
                return(GetSingleProjectSolution(SingleClassWithSingleProperty));

            case WorkspaceKind.SingleClassWithSingleField:
                return(GetSingleProjectSolution(SingleClassWithSingleField));

            case WorkspaceKind.TwoProjectsEachWithASingleClassWithSingleMethod:
                return(GetMultipleProjectSolution(SingleClassWithSingleMethod, SingleClassWithSingleMethod));

            case WorkspaceKind.TwoProjectsEachWithASingleClassWithSingleProperty:
                return(GetMultipleProjectSolution(SingleClassWithSingleProperty, SingleClassWithSingleProperty));

            case WorkspaceKind.TwoProjectsEachWithASingleClassWithSingleField:
                return(GetMultipleProjectSolution(SingleClassWithSingleField, SingleClassWithSingleField));

            case WorkspaceKind.NestedClass:
                return(GetSingleProjectSolution(NestedClass));

            case WorkspaceKind.TwoNamespacesWithIdenticalClasses:
                return(GetSingleProjectSolution(Namespace1, Namespace2));

            default:
                return(null);
            }
        }
        private static void Verify(WorkspaceKind workspaceKind, IEnumerable <ISymbol> declarations, params string[] expectedResults)
        {
            var actualResultCount   = declarations.Count();
            var expectedResultCount = expectedResults.Length;

            Assert.True(expectedResultCount == actualResultCount,
                        string.Format("Expected '{0}' results, found '{1}. Workspace {2} was used",
                                      expectedResultCount,
                                      actualResultCount,
                                      Enum.GetName(typeof(WorkspaceKind), workspaceKind)));
            if (actualResultCount > 0)
            {
                VerifyResults(declarations, expectedResults);
            }
        }
        private static void Verify(string searchTerm, bool respectCase, WorkspaceKind workspaceKind, IEnumerable <ISymbol> declarations, params string[] expectedResults)
        {
            var actualResultCount   = declarations.Count();
            var expectedResultCount = expectedResults.Length;

            Assert.True(expectedResultCount == actualResultCount,
                        string.Format("Search term '{0}' expected '{1}' results, found '{2}.  Ignore case was set to '{3}', Workspace {4} was used",
                                      searchTerm,
                                      expectedResultCount,
                                      actualResultCount,
                                      respectCase,
                                      Enum.GetName(typeof(WorkspaceKind), workspaceKind)));
            if (actualResultCount > 0)
            {
                VerifyResults(declarations, expectedResults);
            }
        }
コード例 #8
0
        public static async Task FindDeclarationsAsync_Test(string searchTerm, bool ignoreCase, WorkspaceKind workspaceKind, string[] expectedResults)
        {
            var project      = GetProject(workspaceKind);
            var declarations = await SymbolFinder.FindDeclarationsAsync(project, searchTerm, ignoreCase).ConfigureAwait(false);

            Verify(searchTerm, ignoreCase, workspaceKind, declarations, expectedResults);
        }
コード例 #9
0
        public static async Task FindSourceDeclarationsAsync_Solution_Test(string searchTerm, bool ignoreCase, WorkspaceKind workspaceKind, string[] expectedResults)
        {
            var solution     = GetSolution(workspaceKind);
            var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, searchTerm, ignoreCase).ConfigureAwait(false);

            Verify(searchTerm, ignoreCase, workspaceKind, declarations, expectedResults);
        }
コード例 #10
0
 public static async Task FindDeclarationsAsync_Test(string searchTerm, bool ignoreCase, WorkspaceKind workspaceKind, string[] expectedResults)
 {
     var project = GetProject(workspaceKind);
     var declarations = await SymbolFinder.FindDeclarationsAsync(project, searchTerm, ignoreCase).ConfigureAwait(false);
     Verify(searchTerm, ignoreCase, workspaceKind, declarations, expectedResults);
 }
コード例 #11
0
 public static async Task FindSourceDeclarationsAsync_Solution_Func_Test(WorkspaceKind workspaceKind, string[] expectedResult)
 {
     var solution = GetSolution(workspaceKind);
     var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, str => str.Contains("Test")).ConfigureAwait(false);
     Verify(workspaceKind, declarations, expectedResult);
 }
コード例 #12
0
 public static async Task FindSourceDeclarationsAsync_Project_Func_Test(WorkspaceKind workspaceKind, string[] expectedResults)
 {
     var project = GetProject(workspaceKind);
     var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, str => str.Contains("Test")).ConfigureAwait(false);
     Verify(workspaceKind, declarations, expectedResults);
 }
コード例 #13
0
 public static async Task FindSourceDeclarationsAsync_Solution_Test(string searchTerm, bool ignoreCase, WorkspaceKind workspaceKind, string[] expectedResults)
 {
     var solution = GetSolution(workspaceKind);
     var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, searchTerm, ignoreCase).ConfigureAwait(false);
     Verify(searchTerm, ignoreCase, workspaceKind, declarations, expectedResults);
 }
コード例 #14
0
 private static Solution GetSolution(WorkspaceKind workspaceKind)
 => workspaceKind switch
 {
 private static Project GetProject(WorkspaceKind workspaceKind)
 {
     return(GetSolution(workspaceKind).Projects.First());
 }
コード例 #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WorkspaceInfo" /> class
 /// </summary>
 /// <param name="path">The path</param>
 /// <param name="kind">The kind</param>
 /// <param name="files">The files</param>
 public WorkspaceInfo(string path, WorkspaceKind kind, IEnumerable <string> files) =>
 (Path, Kind, Files) = (path, kind, files);