8
8
using System . Threading ;
9
9
using System . Threading . Tasks ;
10
10
using Microsoft . AspNetCore . Razor . LanguageServer . ProjectSystem ;
11
+ using Microsoft . AspNetCore . Razor . Test . Common ;
11
12
using Microsoft . AspNetCore . Razor . Test . Common . LanguageServer ;
12
13
using Microsoft . AspNetCore . Razor . Test . Common . ProjectSystem ;
13
14
using Microsoft . AspNetCore . Razor . Test . Common . Workspaces ;
@@ -28,7 +29,8 @@ public class MonitorProjectConfigurationFilePathEndpointTest : LanguageServerTes
28
29
public MonitorProjectConfigurationFilePathEndpointTest ( ITestOutputHelper testOutput )
29
30
: base ( testOutput )
30
31
{
31
- _directoryPathResolver = Mock . Of < WorkspaceDirectoryPathResolver > ( resolver => resolver . Resolve ( ) == "C:/dir" , MockBehavior . Strict ) ;
32
+ var path = PathUtilities . CreateRootedPath ( "dir" ) ;
33
+ _directoryPathResolver = Mock . Of < WorkspaceDirectoryPathResolver > ( resolver => resolver . Resolve ( ) == path , MockBehavior . Strict ) ;
32
34
}
33
35
34
36
[ Fact ]
@@ -45,10 +47,15 @@ public async Task Handle_Disposed_Noops()
45
47
TestLanguageServerFeatureOptions . Instance ,
46
48
LoggerFactory ) ;
47
49
configurationFileEndpoint . Dispose ( ) ;
50
+
51
+ var debugDirectory = PathUtilities . CreateRootedPath ( "dir" , "obj" , "Debug" ) ;
52
+ var projectKeyDirectory = PathUtilities . CreateRootedPath ( "dir" , "obj" ) ;
53
+ var projectKey = TestProjectKey . Create ( projectKeyDirectory ) ;
54
+
48
55
var request = new MonitorProjectConfigurationFilePathParams ( )
49
56
{
50
- ProjectKeyId = TestProjectKey . Create ( "C:/dir/obj" ) . Id ,
51
- ConfigurationFilePath = "C:/dir/obj/Debug/ project.razor.bin",
57
+ ProjectKeyId = projectKey . Id ,
58
+ ConfigurationFilePath = Path . Combine ( debugDirectory , " project.razor.bin")
52
59
} ;
53
60
var requestContext = CreateRazorRequestContext ( documentContext : null ) ;
54
61
@@ -69,9 +76,13 @@ public async Task Handle_ConfigurationFilePath_UntrackedMonitorNoops()
69
76
Enumerable . Empty < IProjectConfigurationFileChangeListener > ( ) ,
70
77
TestLanguageServerFeatureOptions . Instance ,
71
78
LoggerFactory ) ;
79
+
80
+ var projectKeyDirectory = PathUtilities . CreateRootedPath ( "dir" , "obj" ) ;
81
+ var projectKey = TestProjectKey . Create ( projectKeyDirectory ) ;
82
+
72
83
var request = new MonitorProjectConfigurationFilePathParams ( )
73
84
{
74
- ProjectKeyId = TestProjectKey . Create ( "C:/dir/obj" ) . Id ,
85
+ ProjectKeyId = projectKey . Id ,
75
86
ConfigurationFilePath = null ! ,
76
87
} ;
77
88
var requestContext = CreateRazorRequestContext ( documentContext : null ) ;
@@ -91,16 +102,21 @@ public async Task Handle_ConfigurationFilePath_TrackedMonitor_StopsMonitor()
91
102
_directoryPathResolver ,
92
103
Enumerable . Empty < IProjectConfigurationFileChangeListener > ( ) ,
93
104
LoggerFactory ) ;
105
+
106
+ var debugDirectory = PathUtilities . CreateRootedPath ( "externaldir" , "obj" , "Debug" ) ;
107
+ var projectKeyDirectory = PathUtilities . CreateRootedPath ( "dir" , "obj" ) ;
108
+ var projectKey = TestProjectKey . Create ( projectKeyDirectory ) ;
109
+
94
110
var startRequest = new MonitorProjectConfigurationFilePathParams ( )
95
111
{
96
- ProjectKeyId = TestProjectKey . Create ( "C:/dir/obj" ) . Id ,
97
- ConfigurationFilePath = "C:/externaldir/obj/Debug/ project.razor.bin",
112
+ ProjectKeyId = projectKey . Id ,
113
+ ConfigurationFilePath = Path . Combine ( debugDirectory , " project.razor.bin")
98
114
} ;
99
115
var requestContext = CreateRazorRequestContext ( documentContext : null ) ;
100
116
await configurationFileEndpoint . HandleNotificationAsync ( startRequest , requestContext , DisposalToken ) ;
101
117
var stopRequest = new MonitorProjectConfigurationFilePathParams ( )
102
118
{
103
- ProjectKeyId = TestProjectKey . Create ( "C:/dir/obj" ) . Id ,
119
+ ProjectKeyId = projectKey . Id ,
104
120
ConfigurationFilePath = null ! ,
105
121
} ;
106
122
@@ -123,10 +139,15 @@ public async Task Handle_InWorkspaceDirectory_Noops()
123
139
_directoryPathResolver ,
124
140
Enumerable . Empty < IProjectConfigurationFileChangeListener > ( ) ,
125
141
LoggerFactory ) ;
142
+
143
+ var debugDirectory = PathUtilities . CreateRootedPath ( "dir" , "obj" , "Debug" ) ;
144
+ var projectKeyDirectory = PathUtilities . CreateRootedPath ( "dir" , "obj" ) ;
145
+ var projectKey = TestProjectKey . Create ( projectKeyDirectory ) ;
146
+
126
147
var startRequest = new MonitorProjectConfigurationFilePathParams ( )
127
148
{
128
- ProjectKeyId = TestProjectKey . Create ( "C:/dir/obj" ) . Id ,
129
- ConfigurationFilePath = "C:/dir/obj/Debug/ project.razor.bin",
149
+ ProjectKeyId = projectKey . Id ,
150
+ ConfigurationFilePath = Path . Combine ( debugDirectory , " project.razor.bin")
130
151
} ;
131
152
var requestContext = CreateRazorRequestContext ( documentContext : null ) ;
132
153
@@ -149,10 +170,15 @@ public async Task Handle_InWorkspaceDirectory_MonitorsIfLanguageFeatureOptionSet
149
170
Enumerable . Empty < IProjectConfigurationFileChangeListener > ( ) ,
150
171
LoggerFactory ,
151
172
options : new TestLanguageServerFeatureOptions ( monitorWorkspaceFolderForConfigurationFiles : false ) ) ;
173
+
174
+ var debugDirectory = PathUtilities . CreateRootedPath ( "dir" , "obj" , "Debug" ) ;
175
+ var projectKeyDirectory = PathUtilities . CreateRootedPath ( "dir" , "obj" ) ;
176
+ var projectKey = TestProjectKey . Create ( projectKeyDirectory ) ;
177
+
152
178
var startRequest = new MonitorProjectConfigurationFilePathParams ( )
153
179
{
154
- ProjectKeyId = TestProjectKey . Create ( "C:/dir/obj" ) . Id ,
155
- ConfigurationFilePath = "C:/dir/obj/Debug/ project.razor.bin",
180
+ ProjectKeyId = projectKey . Id ,
181
+ ConfigurationFilePath = Path . Combine ( debugDirectory , " project.razor.bin")
156
182
} ;
157
183
var requestContext = CreateRazorRequestContext ( documentContext : null ) ;
158
184
@@ -174,10 +200,15 @@ public async Task Handle_DuplicateMonitors_Noops()
174
200
_directoryPathResolver ,
175
201
Enumerable . Empty < IProjectConfigurationFileChangeListener > ( ) ,
176
202
LoggerFactory ) ;
203
+
204
+ var debugDirectory = PathUtilities . CreateRootedPath ( "externaldir" , "obj" , "Debug" ) ;
205
+ var projectKeyDirectory = PathUtilities . CreateRootedPath ( "dir" , "obj" ) ;
206
+ var projectKey = TestProjectKey . Create ( projectKeyDirectory ) ;
207
+
177
208
var startRequest = new MonitorProjectConfigurationFilePathParams ( )
178
209
{
179
- ProjectKeyId = TestProjectKey . Create ( "C:/dir/obj" ) . Id ,
180
- ConfigurationFilePath = "C:/externaldir/obj/Debug/ project.razor.bin",
210
+ ProjectKeyId = projectKey . Id ,
211
+ ConfigurationFilePath = Path . Combine ( debugDirectory , " project.razor.bin")
181
212
} ;
182
213
var requestContext = CreateRazorRequestContext ( documentContext : null ) ;
183
214
@@ -202,18 +233,20 @@ public async Task Handle_ChangedConfigurationOutputPath_StartsWithNewPath()
202
233
Enumerable . Empty < IProjectConfigurationFileChangeListener > ( ) ,
203
234
LoggerFactory ) ;
204
235
205
- var debugDirectory = Path . Combine ( "C:" , "externaldir" , "obj" , "Debug" ) ;
206
- var releaseDirectory = Path . Combine ( "C:" , "externaldir" , "obj" , "Release" ) ;
236
+ var debugDirectory = PathUtilities . CreateRootedPath ( "externaldir" , "obj" , "Debug" ) ;
237
+ var releaseDirectory = PathUtilities . CreateRootedPath ( "externaldir" , "obj" , "Release" ) ;
238
+ var projectKeyDirectory = PathUtilities . CreateRootedPath ( "dir" , "obj" ) ;
239
+ var projectKey = TestProjectKey . Create ( projectKeyDirectory ) ;
207
240
208
241
var debugOutputPath = new MonitorProjectConfigurationFilePathParams ( )
209
242
{
210
- ProjectKeyId = TestProjectKey . Create ( "C:/dir/obj" ) . Id ,
243
+ ProjectKeyId = projectKey . Id ,
211
244
ConfigurationFilePath = Path . Combine ( debugDirectory , "project.razor.bin" )
212
245
} ;
213
246
214
247
var releaseOutputPath = new MonitorProjectConfigurationFilePathParams ( )
215
248
{
216
- ProjectKeyId = debugOutputPath . ProjectKeyId ,
249
+ ProjectKeyId = projectKey . Id ,
217
250
ConfigurationFilePath = Path . Combine ( releaseDirectory , "project.razor.bin" )
218
251
} ;
219
252
@@ -240,18 +273,20 @@ public async Task Handle_ChangedConfigurationExternalToInternal_StopsWithoutRest
240
273
Enumerable . Empty < IProjectConfigurationFileChangeListener > ( ) ,
241
274
LoggerFactory ) ;
242
275
243
- var debugDirectory = Path . Combine ( "C:" , "externaldir" , "obj" , "Debug" ) ;
244
- var releaseDirectory = Path . Combine ( "C:" , "dir" , "obj" , "Release" ) ;
276
+ var debugDirectory = PathUtilities . CreateRootedPath ( "externaldir" , "obj" , "Debug" ) ;
277
+ var releaseDirectory = PathUtilities . CreateRootedPath ( "dir" , "obj" , "Release" ) ;
278
+ var projectKeyDirectory = PathUtilities . CreateRootedPath ( "dir" , "obj" ) ;
279
+ var projectKey = TestProjectKey . Create ( projectKeyDirectory ) ;
245
280
246
281
var externalRequest = new MonitorProjectConfigurationFilePathParams ( )
247
282
{
248
- ProjectKeyId = TestProjectKey . Create ( "C: \\ dir \\ obj" ) . Id ,
283
+ ProjectKeyId = projectKey . Id ,
249
284
ConfigurationFilePath = Path . Combine ( debugDirectory , "project.razor.bin" )
250
285
} ;
251
286
252
287
var internalRequest = new MonitorProjectConfigurationFilePathParams ( )
253
288
{
254
- ProjectKeyId = externalRequest . ProjectKeyId ,
289
+ ProjectKeyId = projectKey . Id ,
255
290
ConfigurationFilePath = Path . Combine ( releaseDirectory , "project.razor.bin" )
256
291
} ;
257
292
@@ -282,18 +317,20 @@ public async Task Handle_ProjectPublished()
282
317
Enumerable . Empty < IProjectConfigurationFileChangeListener > ( ) ,
283
318
LoggerFactory ) ;
284
319
285
- var debugDirectory = Path . Combine ( "C:" , "externaldir1" , "obj" , "Debug" ) ;
286
- var releaseDirectory = Path . Combine ( "C:" , "externaldir1" , "obj" , "Release" ) ;
320
+ var debugDirectory = PathUtilities . CreateRootedPath ( "externaldir1" , "obj" , "Debug" ) ;
321
+ var releaseDirectory = PathUtilities . CreateRootedPath ( "externaldir1" , "obj" , "Release" ) ;
322
+ var projectKeyDirectory = PathUtilities . CreateRootedPath ( "dir" , "obj" ) ;
323
+ var projectKey = TestProjectKey . Create ( projectKeyDirectory ) ;
287
324
288
325
var debugOutputPath = new MonitorProjectConfigurationFilePathParams ( )
289
326
{
290
- ProjectKeyId = TestProjectKey . Create ( "C: \\ dir \\ obj" ) . Id ,
327
+ ProjectKeyId = projectKey . Id ,
291
328
ConfigurationFilePath = Path . Combine ( debugDirectory , "project.razor.bin" )
292
329
} ;
293
330
294
331
var releaseOutputPath = new MonitorProjectConfigurationFilePathParams ( )
295
332
{
296
- ProjectKeyId = debugOutputPath . ProjectKeyId ,
333
+ ProjectKeyId = projectKey . Id ,
297
334
ConfigurationFilePath = Path . Combine ( releaseDirectory , "project.razor.bin" )
298
335
} ;
299
336
@@ -335,25 +372,29 @@ public async Task Handle_MultipleProjects_StartedAndStopped()
335
372
Enumerable . Empty < IProjectConfigurationFileChangeListener > ( ) ,
336
373
LoggerFactory ) ;
337
374
338
- var debugDirectory1 = Path . Combine ( "C:" , "externaldir1" , "obj" , "Debug" ) ;
339
- var releaseDirectory1 = Path . Combine ( "C:" , "externaldir1" , "obj" , "Release" ) ;
340
- var debugDirectory2 = Path . Combine ( "C:" , "externaldir2" , "obj" , "Debug" ) ;
375
+ var debugDirectory1 = PathUtilities . CreateRootedPath ( "externaldir1" , "obj" , "Debug" ) ;
376
+ var releaseDirectory1 = PathUtilities . CreateRootedPath ( "externaldir1" , "obj" , "Release" ) ;
377
+ var debugDirectory2 = PathUtilities . CreateRootedPath ( "externaldir2" , "obj" , "Debug" ) ;
378
+ var projectKeyDirectory1 = PathUtilities . CreateRootedPath ( "dir" , "obj" ) ;
379
+ var projectKey1 = TestProjectKey . Create ( projectKeyDirectory1 ) ;
380
+ var projectKeyDirectory2 = PathUtilities . CreateRootedPath ( "dir" , "obj2" ) ;
381
+ var projectKey2 = TestProjectKey . Create ( projectKeyDirectory2 ) ;
341
382
342
383
var debugOutputPath1 = new MonitorProjectConfigurationFilePathParams ( )
343
384
{
344
- ProjectKeyId = TestProjectKey . Create ( "C: \\ dir \\ obj" ) . Id ,
385
+ ProjectKeyId = projectKey1 . Id ,
345
386
ConfigurationFilePath = Path . Combine ( debugDirectory1 , "project.razor.bin" )
346
387
} ;
347
388
348
389
var releaseOutputPath1 = new MonitorProjectConfigurationFilePathParams ( )
349
390
{
350
- ProjectKeyId = debugOutputPath1 . ProjectKeyId ,
391
+ ProjectKeyId = projectKey1 . Id ,
351
392
ConfigurationFilePath = Path . Combine ( releaseDirectory1 , "project.razor.bin" )
352
393
} ;
353
394
354
395
var debugOutputPath2 = new MonitorProjectConfigurationFilePathParams ( )
355
396
{
356
- ProjectKeyId = TestProjectKey . Create ( "C: \\ dir \\ obj2" ) . Id ,
397
+ ProjectKeyId = projectKey2 . Id ,
357
398
ConfigurationFilePath = Path . Combine ( debugDirectory2 , "project.razor.bin" )
358
399
} ;
359
400
0 commit comments