Ejemplo n.º 1
0
 private Workspace CreateWorkspaceWithSolution(
     SolutionKind solutionKind,
     out Solution solution,
     TestHost testHost = TestHost.InProcess
     ) =>
 solutionKind switch
 {
Ejemplo n.º 2
0
        private static void Verify(
            string searchTerm,
            bool respectCase,
            SolutionKind 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(SolutionKind), workspaceKind)
                    )
                );
            if (actualResultCount > 0)
            {
                VerifyResults(declarations, expectedResults);
            }
        }
        public async Task FindSourceDeclarationsWithPatternAsync_Solution_Test(SolutionKind workspaceKind, string[] expectedResult)
        {
            using var workspace = CreateWorkspaceWithSolution(workspaceKind, out var solution);
            var declarations = await SymbolFinder.FindSourceDeclarationsWithPatternAsync(solution, "test").ConfigureAwait(false);

            Verify(workspaceKind, declarations, expectedResult);
        }
        public async Task FindSourceDeclarationsAsync_Project_Func_Test(SolutionKind workspaceKind, string[] expectedResults)
        {
            using var workspace = CreateWorkspaceWithProject(workspaceKind, out var project);
            var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, str => str.Contains("Test")).ConfigureAwait(false);

            Verify(workspaceKind, declarations, expectedResults);
        }
        private static void Verify(SolutionKind 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(SolutionKind), workspaceKind)));
            if (actualResultCount > 0)
            {
                VerifyResults(declarations, expectedResults);
            }
        }
        public async Task FindDeclarationsAsync_Test(string searchTerm, bool ignoreCase, SolutionKind workspaceKind, string[] expectedResults)
        {
            using var workspace = CreateWorkspaceWithProject(workspaceKind, out var project);
            var declarations = await SymbolFinder.FindDeclarationsAsync(project, searchTerm, ignoreCase).ConfigureAwait(false);

            Verify(searchTerm, ignoreCase, workspaceKind, declarations, expectedResults);
        }
        public async Task FindSourceDeclarationsWithPatternAsync_CamelCase_Project_Test(SolutionKind workspaceKind, string pattern, string[] expectedResults)
        {
            using var workspace = CreateWorkspaceWithProject(workspaceKind, out var project);
            var declarations = await SymbolFinder.FindSourceDeclarationsWithPatternAsync(project, pattern).ConfigureAwait(false);

            Verify(workspaceKind, declarations, expectedResults);
        }