@@ -39,8 +39,8 @@ namespace SonarLint.VisualStudio.ConnectedMode.UnitTests;
39
39
public class SlCoreConnectionAdapterTests
40
40
{
41
41
private static readonly BasicAuthCredentials ValidToken = new ( "I_AM_JUST_A_TOKEN" , new SecureString ( ) ) ;
42
- private static readonly ServerConnection . SonarQube SonarQubeConnection = new ( new Uri ( "http://localhost:9000/" ) , new ServerConnectionSettings ( true ) , ValidToken ) ;
43
- private static readonly ServerConnection . SonarCloud SonarCloudConnection = new ( "myOrg" , new ServerConnectionSettings ( true ) , ValidToken ) ;
42
+ private readonly ServerConnection . SonarQube sonarQubeConnection = new ( new Uri ( "http://localhost:9000/" ) , new ServerConnectionSettings ( true ) , ValidToken ) ;
43
+ private readonly ServerConnection . SonarCloud sonarCloudConnection = new ( "myOrg" , new ServerConnectionSettings ( true ) , ValidToken ) ;
44
44
45
45
private SlCoreConnectionAdapter testSubject ;
46
46
private ISLCoreServiceProvider slCoreServiceProvider ;
@@ -258,7 +258,7 @@ public async Task GetAllProjectsAsync_SwitchesToBackgroundThread()
258
258
var threadHandlingMock = Substitute . For < IThreadHandling > ( ) ;
259
259
var slCoreConnectionAdapter = new SlCoreConnectionAdapter ( slCoreServiceProvider , threadHandlingMock , logger ) ;
260
260
261
- await slCoreConnectionAdapter . GetAllProjectsAsync ( SonarQubeConnection ) ;
261
+ await slCoreConnectionAdapter . GetAllProjectsAsync ( sonarQubeConnection ) ;
262
262
263
263
await threadHandlingMock . Received ( 1 ) . RunOnBackgroundThread ( Arg . Any < Func < Task < AdapterResponseWithData < List < ServerProject > > > > > ( ) ) ;
264
264
}
@@ -268,7 +268,7 @@ public async Task GetAllProjectsAsync_GettingConnectionConfigurationSLCoreServic
268
268
{
269
269
slCoreServiceProvider . TryGetTransientService ( out IConnectionConfigurationSLCoreService _ ) . Returns ( false ) ;
270
270
271
- var response = await testSubject . GetAllProjectsAsync ( SonarQubeConnection ) ;
271
+ var response = await testSubject . GetAllProjectsAsync ( sonarQubeConnection ) ;
272
272
273
273
logger . Received ( 1 ) . LogVerbose ( $ "[{ nameof ( IConnectionConfigurationSLCoreService ) } ] { SLCoreStrings . ServiceProviderNotInitialized } ") ;
274
274
response . Success . Should ( ) . BeFalse ( ) ;
@@ -277,7 +277,7 @@ public async Task GetAllProjectsAsync_GettingConnectionConfigurationSLCoreServic
277
277
[ TestMethod ]
278
278
public async Task GetAllProjectsAsync_ConnectionToSonarQubeWithToken_CallsGetAllProjectsAsyncWithCorrectParams ( )
279
279
{
280
- await testSubject . GetAllProjectsAsync ( SonarQubeConnection ) ;
280
+ await testSubject . GetAllProjectsAsync ( sonarQubeConnection ) ;
281
281
282
282
await connectionConfigurationSlCoreService . Received ( 1 )
283
283
. GetAllProjectsAsync ( Arg . Is < GetAllProjectsParams > ( x => IsExpectedSonarQubeConnectionParams ( x . transientConnection , ValidToken . UserName ) ) ) ;
@@ -288,9 +288,9 @@ public async Task GetAllProjectsAsync_ConnectionToSonarQubeWithCredentials_Calls
288
288
{
289
289
const string username = "username" ;
290
290
const string password = "password" ;
291
- SonarQubeConnection . Credentials = new BasicAuthCredentials ( username , password . CreateSecureString ( ) ) ;
291
+ sonarQubeConnection . Credentials = new BasicAuthCredentials ( username , password . CreateSecureString ( ) ) ;
292
292
293
- await testSubject . GetAllProjectsAsync ( SonarQubeConnection ) ;
293
+ await testSubject . GetAllProjectsAsync ( sonarQubeConnection ) ;
294
294
295
295
await connectionConfigurationSlCoreService . Received ( 1 )
296
296
. GetAllProjectsAsync ( Arg . Is < GetAllProjectsParams > ( x => IsExpectedSonarQubeConnectionParams ( x . transientConnection , username , password ) ) ) ;
@@ -299,7 +299,7 @@ await connectionConfigurationSlCoreService.Received(1)
299
299
[ TestMethod ]
300
300
public async Task GetAllProjectsAsync_ConnectionToSonarCloudWithToken_CallsGetAllProjectsAsyncWithCorrectParams ( )
301
301
{
302
- await testSubject . GetAllProjectsAsync ( SonarCloudConnection ) ;
302
+ await testSubject . GetAllProjectsAsync ( sonarCloudConnection ) ;
303
303
304
304
await connectionConfigurationSlCoreService . Received ( 1 )
305
305
. GetAllProjectsAsync ( Arg . Is < GetAllProjectsParams > ( x => IsExpectedSonarCloudConnectionParams ( x . transientConnection , ValidToken . UserName ) ) ) ;
@@ -310,9 +310,9 @@ public async Task GetAllProjectsAsync_ConnectionToSonarCloudWithCredentials_Call
310
310
{
311
311
const string username = "username" ;
312
312
const string password = "password" ;
313
- SonarCloudConnection . Credentials = new BasicAuthCredentials ( username , password . CreateSecureString ( ) ) ;
313
+ sonarCloudConnection . Credentials = new BasicAuthCredentials ( username , password . CreateSecureString ( ) ) ;
314
314
315
- await testSubject . GetAllProjectsAsync ( SonarCloudConnection ) ;
315
+ await testSubject . GetAllProjectsAsync ( sonarCloudConnection ) ;
316
316
317
317
await connectionConfigurationSlCoreService . Received ( 1 )
318
318
. GetAllProjectsAsync ( Arg . Is < GetAllProjectsParams > ( x => IsExpectedSonarCloudConnectionParams ( x . transientConnection , username , password ) ) ) ;
@@ -324,7 +324,7 @@ public async Task GetAllProjectsAsync_ReturnsResponseFromSlCore()
324
324
List < SonarProjectDto > expectedServerProjects = [ CreateSonarProjectDto ( "projKey1" , "projName1" ) , CreateSonarProjectDto ( "projKey2" , "projName2" ) ] ;
325
325
connectionConfigurationSlCoreService . GetAllProjectsAsync ( Arg . Any < GetAllProjectsParams > ( ) ) . Returns ( new GetAllProjectsResponse ( expectedServerProjects ) ) ;
326
326
327
- var response = await testSubject . GetAllProjectsAsync ( SonarCloudConnection ) ;
327
+ var response = await testSubject . GetAllProjectsAsync ( sonarCloudConnection ) ;
328
328
329
329
response . Success . Should ( ) . BeTrue ( ) ;
330
330
response . ResponseData . Count . Should ( ) . Be ( expectedServerProjects . Count ) ;
@@ -340,7 +340,7 @@ public async Task GetServerProjectByKeyAsync_SwitchesToBackgroundThread()
340
340
var threadHandlingMock = Substitute . For < IThreadHandling > ( ) ;
341
341
var slCoreConnectionAdapter = new SlCoreConnectionAdapter ( slCoreServiceProvider , threadHandlingMock , logger ) ;
342
342
343
- await slCoreConnectionAdapter . GetServerProjectByKeyAsync ( SonarCloudConnection , "server-project-key" ) ;
343
+ await slCoreConnectionAdapter . GetServerProjectByKeyAsync ( sonarCloudConnection , "server-project-key" ) ;
344
344
345
345
await threadHandlingMock . Received ( 1 ) . RunOnBackgroundThread ( Arg . Any < Func < Task < AdapterResponseWithData < ServerProject > > > > ( ) ) ;
346
346
}
@@ -350,7 +350,7 @@ public async Task GetServerProjectByKeyAsync_GettingConnectionConfigurationSLCor
350
350
{
351
351
slCoreServiceProvider . TryGetTransientService ( out IConnectionConfigurationSLCoreService _ ) . Returns ( false ) ;
352
352
353
- var response = await testSubject . GetServerProjectByKeyAsync ( SonarCloudConnection , "server-project-key" ) ;
353
+ var response = await testSubject . GetServerProjectByKeyAsync ( sonarCloudConnection , "server-project-key" ) ;
354
354
355
355
logger . Received ( 1 ) . LogVerbose ( $ "[{ nameof ( IConnectionConfigurationSLCoreService ) } ] { SLCoreStrings . ServiceProviderNotInitialized } ") ;
356
356
response . Success . Should ( ) . BeFalse ( ) ;
@@ -364,7 +364,7 @@ public async Task GetServerProjectByKeyAsync_SlCoreThrowsException_ReturnsFailed
364
364
connectionConfigurationSlCoreService . When ( x => x . GetProjectNamesByKeyAsync ( Arg . Any < GetProjectNamesByKeyParams > ( ) ) )
365
365
. Do ( _ => throw new Exception ( exceptionMessage ) ) ;
366
366
367
- var response = await testSubject . GetServerProjectByKeyAsync ( SonarCloudConnection , "server-project-key" ) ;
367
+ var response = await testSubject . GetServerProjectByKeyAsync ( sonarCloudConnection , "server-project-key" ) ;
368
368
369
369
logger . Received ( 1 ) . LogVerbose ( $ "{ Resources . GetServerProjectByKey_Fails } : { exceptionMessage } ") ;
370
370
response . Success . Should ( ) . BeFalse ( ) ;
@@ -378,7 +378,7 @@ public async Task GetServerProjectByKeyAsync_ProjectNotFound_ReturnsFailedRespon
378
378
connectionConfigurationSlCoreService . GetProjectNamesByKeyAsync ( Arg . Any < GetProjectNamesByKeyParams > ( ) )
379
379
. Returns ( new GetProjectNamesByKeyResponse ( slCoreResponse ) ) ;
380
380
381
- var response = await testSubject . GetServerProjectByKeyAsync ( SonarCloudConnection , "project-key" ) ;
381
+ var response = await testSubject . GetServerProjectByKeyAsync ( sonarCloudConnection , "project-key" ) ;
382
382
383
383
response . Success . Should ( ) . BeFalse ( ) ;
384
384
response . ResponseData . Should ( ) . BeNull ( ) ;
@@ -393,7 +393,7 @@ public async Task GetServerProjectByKeyAsync_ProjectFound_ReturnsSuccessResponse
393
393
} ;
394
394
connectionConfigurationSlCoreService . GetProjectNamesByKeyAsync ( Arg . Any < GetProjectNamesByKeyParams > ( ) )
395
395
. Returns ( new GetProjectNamesByKeyResponse ( slCoreResponse ) ) ;
396
- var response = await testSubject . GetServerProjectByKeyAsync ( SonarQubeConnection , "project-key" ) ;
396
+ var response = await testSubject . GetServerProjectByKeyAsync ( sonarQubeConnection , "project-key" ) ;
397
397
398
398
response . Success . Should ( ) . BeTrue ( ) ;
399
399
response . ResponseData . Should ( ) . BeEquivalentTo ( new ServerProject ( "project-key" , "project-name" ) ) ;
@@ -407,7 +407,7 @@ public async Task GetAllProjectsAsync_SlCoreValidationThrowsException_ReturnsUns
407
407
connectionConfigurationSlCoreService . When ( x => x . GetAllProjectsAsync ( Arg . Any < GetAllProjectsParams > ( ) ) )
408
408
. Do ( _ => throw new Exception ( exceptionMessage ) ) ;
409
409
410
- var response = await testSubject . GetAllProjectsAsync ( SonarCloudConnection ) ;
410
+ var response = await testSubject . GetAllProjectsAsync ( sonarCloudConnection ) ;
411
411
412
412
logger . Received ( 1 ) . LogVerbose ( $ "{ Resources . GetAllProjects_Fails } : { exceptionMessage } ") ;
413
413
response . Success . Should ( ) . BeFalse ( ) ;
0 commit comments