@@ -474,19 +474,35 @@ public void CanSetAndGetMultipleSearchPaths()
474
474
[ Fact ]
475
475
public void CanResetSearchPaths ( )
476
476
{
477
- // set the global search path to its default value
477
+ // all of these calls should reset the config path to the default
478
+ Action [ ] resetActions =
479
+ {
480
+ ( ) => GlobalSettings . SetConfigSearchPaths ( ConfigurationLevel . Global ) ,
481
+ ( ) => GlobalSettings . SetConfigSearchPaths ( ConfigurationLevel . Global , null ) ,
482
+ ( ) => GlobalSettings . SetConfigSearchPaths ( ConfigurationLevel . Global , string . Empty ) ,
483
+ } ;
484
+
485
+ // record the default search path
478
486
GlobalSettings . SetConfigSearchPaths ( ConfigurationLevel . Global , null ) ;
479
487
var oldPaths = GlobalSettings . GetConfigSearchPaths ( ConfigurationLevel . Global ) ;
480
488
Assert . NotNull ( oldPaths ) ;
481
489
482
- // change to something other than the default
490
+ // generate a non-default path to set
483
491
var newPaths = new string [ ] { Path . Combine ( Constants . TemporaryReposPath , Path . GetRandomFileName ( ) ) } ;
484
- GlobalSettings . SetConfigSearchPaths ( ConfigurationLevel . Global , newPaths ) ;
485
- Assert . Equal ( newPaths , GlobalSettings . GetConfigSearchPaths ( ConfigurationLevel . Global ) ) ;
486
492
487
- // set it back to the default
493
+ foreach ( var tryToReset in resetActions )
494
+ {
495
+ // change to the non-default path
496
+ GlobalSettings . SetConfigSearchPaths ( ConfigurationLevel . Global , newPaths ) ;
497
+ Assert . Equal ( newPaths , GlobalSettings . GetConfigSearchPaths ( ConfigurationLevel . Global ) ) ;
498
+
499
+ // set it back to the default
500
+ tryToReset ( ) ;
501
+ Assert . Equal ( oldPaths , GlobalSettings . GetConfigSearchPaths ( ConfigurationLevel . Global ) ) ;
502
+ }
503
+
504
+ // make sure the config paths are reset after the test ends
488
505
GlobalSettings . SetConfigSearchPaths ( ConfigurationLevel . Global , null ) ;
489
- Assert . Equal ( oldPaths , GlobalSettings . GetConfigSearchPaths ( ConfigurationLevel . Global ) ) ;
490
506
}
491
507
492
508
[ Fact ]
0 commit comments