@@ -311,6 +311,39 @@ public void Perform_MustDoNothingIfNormalSession()
311311 Assert . AreEqual ( OperationResult . Success , result ) ;
312312 }
313313
314+ [ TestMethod ]
315+ public void Perform_MustSetCustomBrowserExamKey ( )
316+ {
317+ var connection = new ConnectionInfo { Api = "some API" , ConnectionToken = "some token" , Oauth2Token = "some OAuth2 token" } ;
318+ var browserExamKey = "BEK-TEST-1234" ;
319+ var exam = new Exam { Id = "some id" , LmsName = "some LMS" , Name = "some name" , Url = "some URL" } ;
320+ var examSettings = new AppSettings ( ) ;
321+ var serverSettings = context . Next . Settings . Server ;
322+ var examDialog = new Mock < IExamSelectionDialog > ( ) ;
323+ var serverDialog = new Mock < IServerFailureDialog > ( ) ;
324+
325+ examDialog . Setup ( d => d . Show ( It . IsAny < IWindow > ( ) ) ) . Callback ( Assert . Fail ) ;
326+ repository . Setup ( c => c . TryLoadSettings ( It . IsAny < Uri > ( ) , out examSettings , It . IsAny < PasswordParameters > ( ) ) ) . Returns ( LoadStatus . Success ) ;
327+ context . Next . Settings . SessionMode = SessionMode . Server ;
328+ context . Next . Settings . Server . ExamId = "some id" ;
329+ fileSystem . Setup ( f => f . Delete ( It . IsAny < string > ( ) ) ) ;
330+ server . Setup ( s => s . Connect ( ) ) . Returns ( new ServerResponse ( true ) ) ;
331+ server . Setup ( s => s . Initialize ( It . IsAny < ServerSettings > ( ) ) ) ;
332+ server . Setup ( s => s . GetConnectionInfo ( ) ) . Returns ( connection ) ;
333+ server . Setup ( s => s . GetAvailableExams ( It . IsAny < string > ( ) ) ) . Returns ( new ServerResponse < IEnumerable < Exam > > ( true , new [ ] { exam } ) ) ;
334+ server . Setup ( s => s . GetConfigurationFor ( It . IsAny < Exam > ( ) ) ) . Returns ( new ServerResponse < Uri > ( true , new Uri ( "file:///configuration.seb" ) ) ) ;
335+ server . Setup ( s => s . SendSelectedExam ( It . IsAny < Exam > ( ) ) ) . Returns ( new ServerResponse < string > ( true , browserExamKey ) ) ;
336+ serverDialog . Setup ( d => d . Show ( It . IsAny < IWindow > ( ) ) ) . Callback ( Assert . Fail ) ;
337+ uiFactory . Setup ( f => f . CreateExamSelectionDialog ( It . IsAny < IEnumerable < Exam > > ( ) ) ) . Returns ( examDialog . Object ) ;
338+ uiFactory . Setup ( f => f . CreateServerFailureDialog ( It . IsAny < string > ( ) , It . IsAny < bool > ( ) ) ) . Returns ( serverDialog . Object ) ;
339+
340+ var result = sut . Perform ( ) ;
341+
342+ Assert . AreEqual ( browserExamKey , context . Next . Settings . Browser . CustomBrowserExamKey ) ;
343+ Assert . AreEqual ( OperationResult . Success , result ) ;
344+
345+ }
346+
314347 [ TestMethod ]
315348 public void Repeat_MustCorrectlyInitializeServerSession ( )
316349 {
@@ -420,6 +453,43 @@ public void Repeat_MustFailIfSettingsCouldNotBeLoaded()
420453 Assert . AreEqual ( SessionMode . Server , context . Next . Settings . SessionMode ) ;
421454 }
422455
456+ [ TestMethod ]
457+ public void Repeat_MustFailIfFinalizationOfCurrentSessionFails ( )
458+ {
459+ var connection = new ConnectionInfo { Api = "some API" , ConnectionToken = "some token" , Oauth2Token = "some OAuth2 token" } ;
460+ var dialog = new Mock < IExamSelectionDialog > ( ) ;
461+ var exam = new Exam { Id = "some id" , LmsName = "some LMS" , Name = "some name" , Url = "some URL" } ;
462+ var examSettings = new AppSettings ( ) ;
463+ var initialSettings = context . Next . Settings ;
464+ var serverSettings = context . Next . Settings . Server ;
465+
466+ dialog
467+ . Setup ( d => d . Show ( It . IsAny < IWindow > ( ) ) )
468+ . Returns ( new ExamSelectionDialogResult { SelectedExam = exam , Success = true } ) ;
469+ repository
470+ . Setup ( c => c . TryLoadSettings ( It . IsAny < Uri > ( ) , out examSettings , It . IsAny < PasswordParameters > ( ) ) )
471+ . Returns ( LoadStatus . Success ) ;
472+ context . Current . Settings . SessionMode = SessionMode . Server ;
473+ context . Next . Settings . SessionMode = SessionMode . Server ;
474+ fileSystem . Setup ( f => f . Delete ( It . IsAny < string > ( ) ) ) ;
475+ server . Setup ( s => s . Connect ( ) ) . Returns ( new ServerResponse ( true ) ) ;
476+ server . Setup ( s => s . Disconnect ( ) ) . Returns ( new ServerResponse ( false ) ) ;
477+ server . Setup ( s => s . Initialize ( It . IsAny < ServerSettings > ( ) ) ) ;
478+ server . Setup ( s => s . GetConnectionInfo ( ) ) . Returns ( connection ) ;
479+ server . Setup ( s => s . SendSelectedExam ( It . IsAny < Exam > ( ) ) ) . Returns ( new ServerResponse < string > ( true , default ) ) ;
480+ server
481+ . Setup ( s => s . GetAvailableExams ( It . IsAny < string > ( ) ) )
482+ . Returns ( new ServerResponse < IEnumerable < Exam > > ( true , default ) ) ;
483+ server
484+ . Setup ( s => s . GetConfigurationFor ( It . IsAny < Exam > ( ) ) )
485+ . Returns ( new ServerResponse < Uri > ( true , new Uri ( "file:///configuration.seb" ) ) ) ;
486+ uiFactory . Setup ( f => f . CreateExamSelectionDialog ( It . IsAny < IEnumerable < Exam > > ( ) ) ) . Returns ( dialog . Object ) ;
487+
488+ var result = sut . Repeat ( ) ;
489+
490+ Assert . AreEqual ( OperationResult . Failed , result ) ;
491+ }
492+
423493 [ TestMethod ]
424494 public void Repeat_MustCorrectlyAbort ( )
425495 {
0 commit comments