SEBWIN-596: Ensured open server connection gets closed when session start failed.
This commit is contained in:
parent
2d34ed30eb
commit
cb3cee7e4e
2 changed files with 17 additions and 2 deletions
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue