1+ /*---------------------------------------------------------------------------------------------
2+ * Copyright (c) Microsoft Corporation. All rights reserved.
3+ * Licensed under the MIT License. See License.txt in the project root for license information.
4+ *--------------------------------------------------------------------------------------------*/
5+
6+ import * as vscode from 'vscode' ;
7+ import { should , expect } from 'chai' ;
8+ import { activateCSharpExtension } from './integrationHelpers' ;
9+ import testAssetWorkspace from './testAssets/testAssetWorkspace' ;
10+
11+ const chai = require ( 'chai' ) ;
12+ chai . use ( require ( 'chai-arrays' ) ) ;
13+ chai . use ( require ( 'chai-fs' ) ) ;
14+
15+ suite ( `WorkspaceSymbolProvider: ${ testAssetWorkspace . description } ` , function ( ) {
16+
17+ suiteSetup ( async function ( ) {
18+ should ( ) ;
19+ await testAssetWorkspace . restore ( ) ;
20+ await activateCSharpExtension ( ) ;
21+
22+ let projectDirectory = vscode . Uri . file ( testAssetWorkspace . projects [ 0 ] . projectDirectoryPath ) ;
23+ await vscode . commands . executeCommand ( "vscode.openFolder" , projectDirectory ) ;
24+ } ) ;
25+
26+ suiteTeardown ( async ( ) => {
27+ await testAssetWorkspace . cleanupWorkspace ( ) ;
28+ } ) ;
29+
30+ test ( "Returns elements" , async function ( ) {
31+ let symbols = await GetWorkspaceSymbols ( "P" ) ;
32+ expect ( symbols . length ) . to . be . greaterThan ( 0 ) ;
33+ } ) ;
34+
35+ test ( "Returns no elements when minimum filter length is configured and search term is shorter" , async function ( ) {
36+ let omnisharpConfig = vscode . workspace . getConfiguration ( 'omnisharp' ) ;
37+ await omnisharpConfig . update ( 'minFindSymbolsFilterLength' , 2 ) ;
38+
39+ let symbols = await GetWorkspaceSymbols ( "P" ) ;
40+ expect ( symbols . length ) . to . be . equal ( 0 ) ;
41+ } ) ;
42+
43+ test ( "Returns elements when minimum filter length is configured and search term is longer or equal" , async function ( ) {
44+ let omnisharpConfig = vscode . workspace . getConfiguration ( 'omnisharp' ) ;
45+ await omnisharpConfig . update ( 'minFindSymbolsFilterLength' , 2 ) ;
46+
47+ let symbols = await GetWorkspaceSymbols ( "P1" ) ;
48+ expect ( symbols . length ) . to . be . greaterThan ( 0 ) ;
49+ } ) ;
50+ } ) ;
51+
52+ async function GetWorkspaceSymbols ( filter : string ) {
53+ return < vscode . SymbolInformation [ ] > await vscode . commands . executeCommand ( "vscode.executeWorkspaceSymbolProvider" , filter ) ;
54+ }
0 commit comments