diff --git a/SafeExamBrowser.Runtime.UnitTests/Operations/ServerOperationTests.cs b/SafeExamBrowser.Runtime.UnitTests/Operations/ServerOperationTests.cs index 47409789..ee49e561 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Operations/ServerOperationTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Operations/ServerOperationTests.cs @@ -591,7 +591,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations } [TestMethod] - public void Revert_MustDisconnectFromServer() + public void Revert_MustDisconnectFromServerWhenSessionRunning() { context.Current.Settings.SessionMode = SessionMode.Server; server.Setup(s => s.Disconnect()).Returns(new ServerResponse(true)); @@ -604,6 +604,21 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations Assert.AreEqual(OperationResult.Success, result); } + [TestMethod] + public void Revert_MustDisconnectFromServerWhenSessionStartFailed() + { + context.Current = default; + context.Next.Settings.SessionMode = SessionMode.Server; + server.Setup(s => s.Disconnect()).Returns(new ServerResponse(true)); + + var result = sut.Revert(); + + fileSystem.VerifyNoOtherCalls(); + server.Verify(s => s.Disconnect(), Times.Once); + + Assert.AreEqual(OperationResult.Success, result); + } + [TestMethod] public void Revert_MustFailWhenDisconnectionUnsuccesful() { diff --git a/SafeExamBrowser.Runtime/Operations/ServerOperation.cs b/SafeExamBrowser.Runtime/Operations/ServerOperation.cs index 26945b69..ca12a094 100644 --- a/SafeExamBrowser.Runtime/Operations/ServerOperation.cs +++ b/SafeExamBrowser.Runtime/Operations/ServerOperation.cs @@ -122,7 +122,7 @@ namespace SafeExamBrowser.Runtime.Operations { var result = OperationResult.Success; - if (Context.Current?.Settings.SessionMode == SessionMode.Server) + if (Context.Current?.Settings.SessionMode == SessionMode.Server || Context.Next.Settings.SessionMode == SessionMode.Server) { logger.Info("Finalizing server..."); StatusChanged?.Invoke(TextKey.OperationStatus_FinalizeServer);