2828using SafeExamBrowser . UserInterface . Contracts . Windows ;
2929using SafeExamBrowser . UserInterface . Contracts . Windows . Data ;
3030
31- namespace SafeExamBrowser . Runtime . UnitTests . Operations
31+ namespace SafeExamBrowser . Runtime . UnitTests . Operations . Session
3232{
3333 [ TestClass ]
3434 public class ConfigurationOperationTests
3535 {
3636 private const string FILE_NAME = "SebClientSettings.seb" ;
37+ private static readonly string FILE_PATH = Path . Combine ( Path . GetDirectoryName ( typeof ( ConfigurationOperationTests ) . Assembly . Location ) , nameof ( Operations ) , nameof ( Session ) , "Testdata" , FILE_NAME ) ;
3738
3839 private AppConfig appConfig ;
3940 private RuntimeContext context ;
@@ -84,10 +85,9 @@ public void Perform_MustUseCommandLineArgumentAs1stPrio()
8485 {
8586 var settings = new AppSettings { ConfigurationMode = ConfigurationMode . Exam } ;
8687 var url = @"http://www.safeexambrowser.org/whatever.seb" ;
87- var location = Path . Combine ( Path . GetDirectoryName ( GetType ( ) . Assembly . Location ) , nameof ( Operations ) , "Testdata" , FILE_NAME ) ;
8888
89- appConfig . AppDataFilePath = location ;
90- appConfig . ProgramDataFilePath = location ;
89+ appConfig . AppDataFilePath = FILE_PATH ;
90+ appConfig . ProgramDataFilePath = FILE_PATH ;
9191
9292 repository . Setup ( r => r . TryLoadSettings ( It . IsAny < Uri > ( ) , out settings , It . IsAny < PasswordParameters > ( ) ) ) . Returns ( LoadStatus . Success ) ;
9393
@@ -102,33 +102,31 @@ public void Perform_MustUseCommandLineArgumentAs1stPrio()
102102 [ TestMethod ]
103103 public void Perform_MustUseProgramDataAs2ndPrio ( )
104104 {
105- var location = Path . Combine ( Path . GetDirectoryName ( GetType ( ) . Assembly . Location ) , nameof ( Operations ) , "Testdata" , FILE_NAME ) ;
106105 var settings = default ( AppSettings ) ;
107106
108- appConfig . ProgramDataFilePath = location ;
107+ appConfig . ProgramDataFilePath = FILE_PATH ;
109108
110109 repository . Setup ( r => r . TryLoadSettings ( It . IsAny < Uri > ( ) , out settings , It . IsAny < PasswordParameters > ( ) ) ) . Returns ( LoadStatus . Success ) ;
111110
112111 var sut = new ConfigurationOperation ( null , dependencies , fileSystem . Object , hashAlgorithm . Object , repository . Object , uiFactory . Object ) ;
113112 var result = sut . Perform ( ) ;
114113
115- repository . Verify ( r => r . TryLoadSettings ( It . Is < Uri > ( u => u . Equals ( location ) ) , out settings , It . IsAny < PasswordParameters > ( ) ) , Times . Once ) ;
114+ repository . Verify ( r => r . TryLoadSettings ( It . Is < Uri > ( u => u . Equals ( FILE_PATH ) ) , out settings , It . IsAny < PasswordParameters > ( ) ) , Times . Once ) ;
116115 Assert . AreEqual ( OperationResult . Success , result ) ;
117116 }
118117
119118 [ TestMethod ]
120119 public void Perform_MustUseAppDataAs3rdPrio ( )
121120 {
122- var location = Path . Combine ( Path . GetDirectoryName ( GetType ( ) . Assembly . Location ) , nameof ( Operations ) , "Testdata" , FILE_NAME ) ;
123121 var settings = default ( AppSettings ) ;
124122
125- appConfig . AppDataFilePath = location ;
123+ appConfig . AppDataFilePath = FILE_PATH ;
126124 repository . Setup ( r => r . TryLoadSettings ( It . IsAny < Uri > ( ) , out settings , It . IsAny < PasswordParameters > ( ) ) ) . Returns ( LoadStatus . Success ) ;
127125
128126 var sut = new ConfigurationOperation ( null , dependencies , fileSystem . Object , hashAlgorithm . Object , repository . Object , uiFactory . Object ) ;
129127 var result = sut . Perform ( ) ;
130128
131- repository . Verify ( r => r . TryLoadSettings ( It . Is < Uri > ( u => u . Equals ( location ) ) , out settings , It . IsAny < PasswordParameters > ( ) ) , Times . Once ) ;
129+ repository . Verify ( r => r . TryLoadSettings ( It . Is < Uri > ( u => u . Equals ( FILE_PATH ) ) , out settings , It . IsAny < PasswordParameters > ( ) ) , Times . Once ) ;
132130 Assert . AreEqual ( OperationResult . Success , result ) ;
133131 }
134132
@@ -290,13 +288,13 @@ public void Perform_MustOnlyAllowToEnterAdminPasswordFiveTimes()
290288 var settings = new AppSettings { ConfigurationMode = ConfigurationMode . ConfigureClient } ;
291289 var url = @"http://www.safeexambrowser.org/whatever.seb" ;
292290
293- appConfig . AppDataFilePath = Path . Combine ( Path . GetDirectoryName ( GetType ( ) . Assembly . Location ) , nameof ( Operations ) , "Testdata" , FILE_NAME ) ;
291+ appConfig . AppDataFilePath =
294292 localSettings . Security . AdminPasswordHash = "1234" ;
295293 settings . Security . AdminPasswordHash = "9876" ;
296294 nextSession . Settings = settings ;
297295
298296 dialog . Setup ( d => d . Show ( It . IsAny < IWindow > ( ) ) ) . Callback ( ( ) => count ++ ) . Returns ( new PasswordDialogResult { Success = true } ) ;
299- repository . Setup ( r => r . TryLoadSettings ( It . IsAny < Uri > ( ) , out settings , It . IsAny < PasswordParameters > ( ) ) ) . Returns ( LoadStatus . Success ) ;
297+ repository . Setup ( r => r . TryLoadSettings ( It . IsAny < Uri > ( ) , out settings , It . IsAny < PasswordParameters > ( ) ) ) . Returns ( LoadStatus . PasswordNeeded ) ;
300298 repository . Setup ( r => r . TryLoadSettings ( It . Is < Uri > ( u => u . LocalPath . Contains ( FILE_NAME ) ) , out localSettings , It . IsAny < PasswordParameters > ( ) ) ) . Returns ( LoadStatus . Success ) ;
301299 uiFactory . Setup ( f => f . CreatePasswordDialog ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ) . Returns ( dialog . Object ) ;
302300
@@ -404,17 +402,16 @@ public void Perform_MustSucceedIfSettingsPasswordCorrect()
404402 public void Perform_MustUseCurrentPasswordIfAvailable ( )
405403 {
406404 var url = @"http://www.safeexambrowser.org/whatever.seb" ;
407- var location = Path . Combine ( Path . GetDirectoryName ( GetType ( ) . Assembly . Location ) , nameof ( Operations ) , "Testdata" , FILE_NAME ) ;
408405 var settings = new AppSettings { ConfigurationMode = ConfigurationMode . Exam } ;
409406
410- appConfig . AppDataFilePath = location ;
407+ appConfig . AppDataFilePath = FILE_PATH ;
411408 settings . Security . AdminPasswordHash = "1234" ;
412409
413410 repository
414411 . Setup ( r => r . TryLoadSettings ( It . IsAny < Uri > ( ) , out settings , It . IsAny < PasswordParameters > ( ) ) )
415412 . Returns ( LoadStatus . PasswordNeeded ) ;
416413 repository
417- . Setup ( r => r . TryLoadSettings ( It . Is < Uri > ( u => u . Equals ( new Uri ( location ) ) ) , out settings , It . IsAny < PasswordParameters > ( ) ) )
414+ . Setup ( r => r . TryLoadSettings ( It . Is < Uri > ( u => u . Equals ( new Uri ( FILE_PATH ) ) ) , out settings , It . IsAny < PasswordParameters > ( ) ) )
418415 . Returns ( LoadStatus . Success ) ;
419416 repository
420417 . Setup ( r => r . TryLoadSettings ( It . IsAny < Uri > ( ) , out settings , It . Is < PasswordParameters > ( p => p . IsHash == true && p . Password == settings . Security . AdminPasswordHash ) ) )
@@ -437,7 +434,7 @@ public void Perform_MustAbortAskingForAdminPasswordIfDecidedByUser()
437434 var nextSettings = new AppSettings { ConfigurationMode = ConfigurationMode . ConfigureClient } ;
438435 var url = @"http://www.safeexambrowser.org/whatever.seb" ;
439436
440- appConfig . AppDataFilePath = Path . Combine ( Path . GetDirectoryName ( GetType ( ) . Assembly . Location ) , nameof ( Operations ) , "Testdata" , FILE_NAME ) ;
437+ appConfig . AppDataFilePath = FILE_PATH ;
441438 currentSession . Settings = currentSettings ;
442439 currentSettings . Security . AdminPasswordHash = "1234" ;
443440 nextSession . Settings = nextSettings ;
@@ -479,7 +476,7 @@ public void Repeat_MustPerformForExamWithCorrectUri()
479476 {
480477 var currentSettings = new AppSettings ( ) ;
481478 var location = Path . GetDirectoryName ( GetType ( ) . Assembly . Location ) ;
482- var resource = new Uri ( Path . Combine ( location , nameof ( Operations ) , "Testdata" , FILE_NAME ) ) ;
479+ var resource = new Uri ( Path . Combine ( location , nameof ( Operations ) , nameof ( Session ) , "Testdata" , FILE_NAME ) ) ;
483480 var settings = new AppSettings { ConfigurationMode = ConfigurationMode . Exam } ;
484481
485482 currentSession . Settings = currentSettings ;
@@ -501,7 +498,7 @@ public void Repeat_MustPerformForClientConfigurationWithCorrectUri()
501498 {
502499 var currentSettings = new AppSettings ( ) ;
503500 var location = Path . GetDirectoryName ( GetType ( ) . Assembly . Location ) ;
504- var resource = new Uri ( Path . Combine ( location , nameof ( Operations ) , "Testdata" , FILE_NAME ) ) ;
501+ var resource = new Uri ( Path . Combine ( location , nameof ( Operations ) , nameof ( Session ) , "Testdata" , FILE_NAME ) ) ;
505502 var settings = new AppSettings { ConfigurationMode = ConfigurationMode . ConfigureClient } ;
506503
507504 currentSession . Settings = currentSettings ;
@@ -524,7 +521,7 @@ public void Repeat_MustDeleteTemporaryFileAfterClientConfiguration()
524521 {
525522 var currentSettings = new AppSettings ( ) ;
526523 var location = Path . GetDirectoryName ( GetType ( ) . Assembly . Location ) ;
527- var resource = new Uri ( Path . Combine ( location , nameof ( Operations ) , "Testdata" , FILE_NAME ) ) ;
524+ var resource = new Uri ( Path . Combine ( location , nameof ( Operations ) , nameof ( Session ) , "Testdata" , FILE_NAME ) ) ;
528525 var settings = new AppSettings { ConfigurationMode = ConfigurationMode . ConfigureClient } ;
529526 var delete = 0 ;
530527 var configure = 0 ;
@@ -578,7 +575,7 @@ public void Repeat_MustAbortForSettingsPasswordIfWishedByUser()
578575 var currentSettings = new AppSettings ( ) ;
579576 var dialog = new Mock < IPasswordDialog > ( ) ;
580577 var location = Path . GetDirectoryName ( GetType ( ) . Assembly . Location ) ;
581- var resource = new Uri ( Path . Combine ( location , nameof ( Operations ) , "Testdata" , FILE_NAME ) ) ;
578+ var resource = new Uri ( Path . Combine ( location , nameof ( Operations ) , nameof ( Session ) , "Testdata" , FILE_NAME ) ) ;
582579 var settings = new AppSettings { ConfigurationMode = ConfigurationMode . ConfigureClient } ;
583580
584581 currentSession . Settings = currentSettings ;
@@ -601,7 +598,7 @@ public void Repeat_MustNotWaitForPasswordViaClientIfCommunicationHasFailed()
601598 var clientProxy = new Mock < IClientProxy > ( ) ;
602599 var currentSettings = new AppSettings ( ) ;
603600 var location = Path . GetDirectoryName ( GetType ( ) . Assembly . Location ) ;
604- var resource = new Uri ( Path . Combine ( location , nameof ( Operations ) , "Testdata" , FILE_NAME ) ) ;
601+ var resource = new Uri ( Path . Combine ( location , nameof ( Operations ) , nameof ( Session ) , "Testdata" , FILE_NAME ) ) ;
605602 var settings = new AppSettings { ConfigurationMode = ConfigurationMode . ConfigureClient } ;
606603
607604 context . ClientProxy = clientProxy . Object ;
0 commit comments