@@ -452,19 +452,35 @@ public void CanSetAndGetMultipleSearchPaths()
452
452
[ Fact ]
453
453
public void CanResetSearchPaths ( )
454
454
{
455
- // set the global search path to its default value
455
+ // all of these calls should reset the config path to the default
456
+ Action [ ] resetActions =
457
+ {
458
+ ( ) => GlobalSettings . SetConfigSearchPaths ( ConfigurationLevel . Global ) ,
459
+ ( ) => GlobalSettings . SetConfigSearchPaths ( ConfigurationLevel . Global , null ) ,
460
+ ( ) => GlobalSettings . SetConfigSearchPaths ( ConfigurationLevel . Global , string . Empty ) ,
461
+ } ;
462
+
463
+ // record the default search path
456
464
GlobalSettings . SetConfigSearchPaths ( ConfigurationLevel . Global , null ) ;
457
465
var oldPaths = GlobalSettings . GetConfigSearchPaths ( ConfigurationLevel . Global ) ;
458
466
Assert . NotNull ( oldPaths ) ;
459
467
460
- // change to something other than the default
468
+ // generate a non-default path to set
461
469
var newPaths = new string [ ] { Path . Combine ( Constants . TemporaryReposPath , Path . GetRandomFileName ( ) ) } ;
462
- GlobalSettings . SetConfigSearchPaths ( ConfigurationLevel . Global , newPaths ) ;
463
- Assert . Equal ( newPaths , GlobalSettings . GetConfigSearchPaths ( ConfigurationLevel . Global ) ) ;
464
470
465
- // set it back to the default
471
+ foreach ( var tryToReset in resetActions )
472
+ {
473
+ // change to the non-default path
474
+ GlobalSettings . SetConfigSearchPaths ( ConfigurationLevel . Global , newPaths ) ;
475
+ Assert . Equal ( newPaths , GlobalSettings . GetConfigSearchPaths ( ConfigurationLevel . Global ) ) ;
476
+
477
+ // set it back to the default
478
+ tryToReset ( ) ;
479
+ Assert . Equal ( oldPaths , GlobalSettings . GetConfigSearchPaths ( ConfigurationLevel . Global ) ) ;
480
+ }
481
+
482
+ // make sure the config paths are reset after the test ends
466
483
GlobalSettings . SetConfigSearchPaths ( ConfigurationLevel . Global , null ) ;
467
- Assert . Equal ( oldPaths , GlobalSettings . GetConfigSearchPaths ( ConfigurationLevel . Global ) ) ;
468
484
}
469
485
470
486
[ Fact ]
0 commit comments