diff --git a/SafeExamBrowser.Runtime.UnitTests/Communication/RuntimeHostTests.cs b/SafeExamBrowser.Runtime.UnitTests/Communication/RuntimeHostTests.cs index 74f851ba..dbe9ee8a 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Communication/RuntimeHostTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Communication/RuntimeHostTests.cs @@ -42,6 +42,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication { var token = Guid.NewGuid(); + sut.AllowConnection = true; sut.StartupToken = token; var response = sut.Connect(token); @@ -55,6 +56,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication { var token = Guid.NewGuid(); + sut.AllowConnection = true; sut.StartupToken = token; var response1 = sut.Connect(token); @@ -78,6 +80,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication var disconnected = false; var token = Guid.NewGuid(); + sut.AllowConnection = true; sut.StartupToken = token; sut.ClientDisconnected += () => disconnected = true; @@ -92,10 +95,15 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication [TestMethod] public void MustAllowReconnectionAfterDisconnection() { - var token = sut.StartupToken = Guid.NewGuid(); + var token = Guid.NewGuid(); + + sut.AllowConnection = true; + sut.StartupToken = token; + var response = sut.Connect(token); sut.Disconnect(new DisconnectionMessage { CommunicationToken = response.CommunicationToken.Value }); + sut.AllowConnection = true; sut.StartupToken = token = Guid.NewGuid(); response = sut.Connect(token); @@ -108,6 +116,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication { var clientReady = false; + sut.AllowConnection = true; sut.ClientReady += () => clientReady = true; sut.StartupToken = Guid.Empty; @@ -126,6 +135,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication { var shutdownRequested = false; + sut.AllowConnection = true; sut.ShutdownRequested += () => shutdownRequested = true; sut.StartupToken = Guid.Empty; @@ -142,6 +152,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication [TestMethod] public void MustReturnUnknownMessageAsDefault() { + sut.AllowConnection = true; sut.StartupToken = Guid.Empty; var token = sut.Connect(Guid.Empty).CommunicationToken.Value; diff --git a/SafeExamBrowser.Runtime.UnitTests/Operations/ClientOperationTests.cs b/SafeExamBrowser.Runtime.UnitTests/Operations/ClientOperationTests.cs index 6ec34b9c..d8594ff2 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Operations/ClientOperationTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Operations/ClientOperationTests.cs @@ -13,6 +13,7 @@ using SafeExamBrowser.Contracts.Communication.Data; using SafeExamBrowser.Contracts.Communication.Hosts; using SafeExamBrowser.Contracts.Communication.Proxies; using SafeExamBrowser.Contracts.Configuration; +using SafeExamBrowser.Contracts.Configuration.Settings; using SafeExamBrowser.Contracts.Core.OperationModel; using SafeExamBrowser.Contracts.Logging; using SafeExamBrowser.Contracts.WindowsApi; @@ -34,7 +35,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations private Mock runtimeHost; private Mock session; private SessionContext sessionContext; - + private Settings settings; private ClientOperation sut; [TestInitialize] @@ -50,6 +51,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations runtimeHost = new Mock(); session = new Mock(); sessionContext = new SessionContext(); + settings = new Settings(); terminated = new Action(() => { runtimeHost.Raise(h => h.ClientDisconnected += null); @@ -57,6 +59,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations }); session.SetupGet(s => s.AppConfig).Returns(appConfig); + session.SetupGet(s => s.Settings).Returns(settings); sessionContext.Current = session.Object; sessionContext.Next = session.Object; proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny())).Returns(proxy.Object); diff --git a/SafeExamBrowser.Runtime.UnitTests/Operations/SessionActivationOperationTests.cs b/SafeExamBrowser.Runtime.UnitTests/Operations/SessionActivationOperationTests.cs index 284bdd92..2fbc58f9 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Operations/SessionActivationOperationTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Operations/SessionActivationOperationTests.cs @@ -9,6 +9,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using SafeExamBrowser.Contracts.Configuration; +using SafeExamBrowser.Contracts.Configuration.Settings; using SafeExamBrowser.Contracts.Core.OperationModel; using SafeExamBrowser.Contracts.Logging; using SafeExamBrowser.Runtime.Operations; @@ -21,6 +22,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations private Mock currentSession; private Mock logger; private Mock nextSession; + private Settings nextSettings; private SessionContext sessionContext; private SessionActivationOperation sut; @@ -31,8 +33,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations currentSession = new Mock(); logger = new Mock(); nextSession = new Mock(); + nextSettings = new Settings(); sessionContext = new SessionContext(); + nextSession.SetupGet(s => s.Settings).Returns(nextSettings); sessionContext.Current = currentSession.Object; sessionContext.Next = nextSession.Object;