66import { should , expect } from 'chai' ;
77import { Options } from '../../src/omnisharp/options' ;
88import { getFakeVsCode , getWorkspaceConfiguration } from './testAssets/Fakes' ;
9+ import { WorkspaceConfiguration } from '../../src/vscodeAdapter' ;
910
10- function getVSCode ( ) {
11+ function getVSCode ( omnisharpConfig ?: WorkspaceConfiguration , csharpConfig ?: WorkspaceConfiguration ) {
1112 const vscode = getFakeVsCode ( ) ;
1213
13- const omnisharpConfig = getWorkspaceConfiguration ( ) ;
14- const csharpConfig = getWorkspaceConfiguration ( ) ;
14+ const _omnisharpConfig = omnisharpConfig || getWorkspaceConfiguration ( ) ;
15+ const _csharpConfig = csharpConfig || getWorkspaceConfiguration ( ) ;
1516
1617 vscode . workspace . getConfiguration = ( section ?, resource ?) =>
1718 {
1819 if ( section === 'omnisharp' )
1920 {
20- return omnisharpConfig ;
21+ return _omnisharpConfig ;
2122 }
2223
2324 if ( section === 'csharp' )
2425 {
25- return csharpConfig ;
26+ return _csharpConfig ;
2627 }
2728
2829 return undefined ;
@@ -34,7 +35,7 @@ function getVSCode() {
3435suite ( "Options tests" , ( ) => {
3536 suiteSetup ( ( ) => should ( ) ) ;
3637
37- test ( 'Construct options and verify defaults' , ( ) =>
38+ test ( 'Verify defaults' , ( ) =>
3839 {
3940 const vscode = getVSCode ( ) ;
4041 const options = Options . Read ( vscode ) ;
@@ -53,4 +54,83 @@ suite("Options tests", () => {
5354 options . disableCodeActions . should . equal ( false ) ;
5455 options . disableCodeActions . should . equal ( false ) ;
5556 } ) ;
57+
58+ test ( 'BACK-COMPAT: "omnisharp.loggingLevel": "verbose" == "omnisharp.loggingLevel": "debug"' , ( ) =>
59+ {
60+ const omnisharpConfig = getWorkspaceConfiguration ( ) ;
61+ omnisharpConfig . update ( 'loggingLevel' , "verbose" ) ;
62+ const vscode = getVSCode ( omnisharpConfig ) ;
63+
64+ const options = Options . Read ( vscode ) ;
65+
66+ options . loggingLevel . should . equal ( "debug" ) ;
67+ } ) ;
68+
69+ test ( 'BACK-COMPAT: "omnisharp.useMono": true == "omnisharp.useGlobalMono": "always"' , ( ) =>
70+ {
71+ const omnisharpConfig = getWorkspaceConfiguration ( ) ;
72+ omnisharpConfig . update ( 'useMono' , true ) ;
73+ const vscode = getVSCode ( omnisharpConfig ) ;
74+
75+ const options = Options . Read ( vscode ) ;
76+
77+ options . useGlobalMono . should . equal ( "always" ) ;
78+ } ) ;
79+
80+ test ( 'BACK-COMPAT: "omnisharp.useMono": false == "omnisharp.useGlobalMono": "auto"' , ( ) =>
81+ {
82+ const omnisharpConfig = getWorkspaceConfiguration ( ) ;
83+ omnisharpConfig . update ( 'useMono' , false ) ;
84+ const vscode = getVSCode ( omnisharpConfig ) ;
85+
86+ const options = Options . Read ( vscode ) ;
87+
88+ options . useGlobalMono . should . equal ( "auto" ) ;
89+ } ) ;
90+
91+ test ( 'BACK-COMPAT: "csharp.omnisharpUsesMono": true == "omnisharp.useGlobalMono": "always"' , ( ) =>
92+ {
93+ const csharpConfig = getWorkspaceConfiguration ( ) ;
94+ csharpConfig . update ( 'omnisharpUsesMono' , true ) ;
95+ const vscode = getVSCode ( undefined , csharpConfig ) ;
96+
97+ const options = Options . Read ( vscode ) ;
98+
99+ options . useGlobalMono . should . equal ( "always" ) ;
100+ } ) ;
101+
102+ test ( 'BACK-COMPAT: "csharp.omnisharpUsesMono": false == "omnisharp.useGlobalMono": "auto"' , ( ) =>
103+ {
104+ const csharpConfig = getWorkspaceConfiguration ( ) ;
105+ csharpConfig . update ( 'omnisharpUsesMono' , false ) ;
106+ const vscode = getVSCode ( undefined , csharpConfig ) ;
107+
108+ const options = Options . Read ( vscode ) ;
109+
110+ options . useGlobalMono . should . equal ( "auto" ) ;
111+ } ) ;
112+
113+ test ( 'BACK-COMPAT: "csharp.omnisharp" is used if it is set and "omnisharp.path" is not' , ( ) =>
114+ {
115+ const csharpConfig = getWorkspaceConfiguration ( ) ;
116+ csharpConfig . update ( 'omnisharp' , 'OldPath' ) ;
117+ const vscode = getVSCode ( undefined , csharpConfig ) ;
118+
119+ const options = Options . Read ( vscode ) ;
120+
121+ options . path . should . equal ( "OldPath" ) ;
122+ } ) ;
123+
124+ test ( 'BACK-COMPAT: "csharp.omnisharp" is not used if "omnisharp.path" is set' , ( ) =>
125+ {
126+ const omnisharpConfig = getWorkspaceConfiguration ( ) ;
127+ omnisharpConfig . update ( 'path' , 'NewPath' ) ;
128+ const csharpConfig = getWorkspaceConfiguration ( ) ;
129+ csharpConfig . update ( 'omnisharp' , 'OldPath' ) ;
130+ const vscode = getVSCode ( omnisharpConfig , csharpConfig ) ;
131+
132+ const options = Options . Read ( vscode ) ;
133+
134+ options . path . should . equal ( "NewPath" ) ;
135+ } ) ;
56136} ) ;
0 commit comments