SEBWIN-296: Fixed broken unit tests.
This commit is contained in:
parent
3b28c8ff7f
commit
1013d1e6bc
3 changed files with 20 additions and 2 deletions
|
@ -42,6 +42,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication
|
||||||
{
|
{
|
||||||
var token = Guid.NewGuid();
|
var token = Guid.NewGuid();
|
||||||
|
|
||||||
|
sut.AllowConnection = true;
|
||||||
sut.StartupToken = token;
|
sut.StartupToken = token;
|
||||||
|
|
||||||
var response = sut.Connect(token);
|
var response = sut.Connect(token);
|
||||||
|
@ -55,6 +56,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication
|
||||||
{
|
{
|
||||||
var token = Guid.NewGuid();
|
var token = Guid.NewGuid();
|
||||||
|
|
||||||
|
sut.AllowConnection = true;
|
||||||
sut.StartupToken = token;
|
sut.StartupToken = token;
|
||||||
|
|
||||||
var response1 = sut.Connect(token);
|
var response1 = sut.Connect(token);
|
||||||
|
@ -78,6 +80,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication
|
||||||
var disconnected = false;
|
var disconnected = false;
|
||||||
var token = Guid.NewGuid();
|
var token = Guid.NewGuid();
|
||||||
|
|
||||||
|
sut.AllowConnection = true;
|
||||||
sut.StartupToken = token;
|
sut.StartupToken = token;
|
||||||
sut.ClientDisconnected += () => disconnected = true;
|
sut.ClientDisconnected += () => disconnected = true;
|
||||||
|
|
||||||
|
@ -92,10 +95,15 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void MustAllowReconnectionAfterDisconnection()
|
public void MustAllowReconnectionAfterDisconnection()
|
||||||
{
|
{
|
||||||
var token = sut.StartupToken = Guid.NewGuid();
|
var token = Guid.NewGuid();
|
||||||
|
|
||||||
|
sut.AllowConnection = true;
|
||||||
|
sut.StartupToken = token;
|
||||||
|
|
||||||
var response = sut.Connect(token);
|
var response = sut.Connect(token);
|
||||||
|
|
||||||
sut.Disconnect(new DisconnectionMessage { CommunicationToken = response.CommunicationToken.Value });
|
sut.Disconnect(new DisconnectionMessage { CommunicationToken = response.CommunicationToken.Value });
|
||||||
|
sut.AllowConnection = true;
|
||||||
sut.StartupToken = token = Guid.NewGuid();
|
sut.StartupToken = token = Guid.NewGuid();
|
||||||
|
|
||||||
response = sut.Connect(token);
|
response = sut.Connect(token);
|
||||||
|
@ -108,6 +116,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication
|
||||||
{
|
{
|
||||||
var clientReady = false;
|
var clientReady = false;
|
||||||
|
|
||||||
|
sut.AllowConnection = true;
|
||||||
sut.ClientReady += () => clientReady = true;
|
sut.ClientReady += () => clientReady = true;
|
||||||
sut.StartupToken = Guid.Empty;
|
sut.StartupToken = Guid.Empty;
|
||||||
|
|
||||||
|
@ -126,6 +135,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication
|
||||||
{
|
{
|
||||||
var shutdownRequested = false;
|
var shutdownRequested = false;
|
||||||
|
|
||||||
|
sut.AllowConnection = true;
|
||||||
sut.ShutdownRequested += () => shutdownRequested = true;
|
sut.ShutdownRequested += () => shutdownRequested = true;
|
||||||
sut.StartupToken = Guid.Empty;
|
sut.StartupToken = Guid.Empty;
|
||||||
|
|
||||||
|
@ -142,6 +152,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void MustReturnUnknownMessageAsDefault()
|
public void MustReturnUnknownMessageAsDefault()
|
||||||
{
|
{
|
||||||
|
sut.AllowConnection = true;
|
||||||
sut.StartupToken = Guid.Empty;
|
sut.StartupToken = Guid.Empty;
|
||||||
|
|
||||||
var token = sut.Connect(Guid.Empty).CommunicationToken.Value;
|
var token = sut.Connect(Guid.Empty).CommunicationToken.Value;
|
||||||
|
|
|
@ -13,6 +13,7 @@ using SafeExamBrowser.Contracts.Communication.Data;
|
||||||
using SafeExamBrowser.Contracts.Communication.Hosts;
|
using SafeExamBrowser.Contracts.Communication.Hosts;
|
||||||
using SafeExamBrowser.Contracts.Communication.Proxies;
|
using SafeExamBrowser.Contracts.Communication.Proxies;
|
||||||
using SafeExamBrowser.Contracts.Configuration;
|
using SafeExamBrowser.Contracts.Configuration;
|
||||||
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||||
using SafeExamBrowser.Contracts.Core.OperationModel;
|
using SafeExamBrowser.Contracts.Core.OperationModel;
|
||||||
using SafeExamBrowser.Contracts.Logging;
|
using SafeExamBrowser.Contracts.Logging;
|
||||||
using SafeExamBrowser.Contracts.WindowsApi;
|
using SafeExamBrowser.Contracts.WindowsApi;
|
||||||
|
@ -34,7 +35,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||||
private Mock<IRuntimeHost> runtimeHost;
|
private Mock<IRuntimeHost> runtimeHost;
|
||||||
private Mock<ISessionConfiguration> session;
|
private Mock<ISessionConfiguration> session;
|
||||||
private SessionContext sessionContext;
|
private SessionContext sessionContext;
|
||||||
|
private Settings settings;
|
||||||
private ClientOperation sut;
|
private ClientOperation sut;
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
|
@ -50,6 +51,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||||
runtimeHost = new Mock<IRuntimeHost>();
|
runtimeHost = new Mock<IRuntimeHost>();
|
||||||
session = new Mock<ISessionConfiguration>();
|
session = new Mock<ISessionConfiguration>();
|
||||||
sessionContext = new SessionContext();
|
sessionContext = new SessionContext();
|
||||||
|
settings = new Settings();
|
||||||
terminated = new Action(() =>
|
terminated = new Action(() =>
|
||||||
{
|
{
|
||||||
runtimeHost.Raise(h => h.ClientDisconnected += null);
|
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.AppConfig).Returns(appConfig);
|
||||||
|
session.SetupGet(s => s.Settings).Returns(settings);
|
||||||
sessionContext.Current = session.Object;
|
sessionContext.Current = session.Object;
|
||||||
sessionContext.Next = session.Object;
|
sessionContext.Next = session.Object;
|
||||||
proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny<string>())).Returns(proxy.Object);
|
proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny<string>())).Returns(proxy.Object);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using Moq;
|
||||||
using SafeExamBrowser.Contracts.Configuration;
|
using SafeExamBrowser.Contracts.Configuration;
|
||||||
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||||
using SafeExamBrowser.Contracts.Core.OperationModel;
|
using SafeExamBrowser.Contracts.Core.OperationModel;
|
||||||
using SafeExamBrowser.Contracts.Logging;
|
using SafeExamBrowser.Contracts.Logging;
|
||||||
using SafeExamBrowser.Runtime.Operations;
|
using SafeExamBrowser.Runtime.Operations;
|
||||||
|
@ -21,6 +22,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||||
private Mock<ISessionConfiguration> currentSession;
|
private Mock<ISessionConfiguration> currentSession;
|
||||||
private Mock<ILogger> logger;
|
private Mock<ILogger> logger;
|
||||||
private Mock<ISessionConfiguration> nextSession;
|
private Mock<ISessionConfiguration> nextSession;
|
||||||
|
private Settings nextSettings;
|
||||||
private SessionContext sessionContext;
|
private SessionContext sessionContext;
|
||||||
|
|
||||||
private SessionActivationOperation sut;
|
private SessionActivationOperation sut;
|
||||||
|
@ -31,8 +33,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||||
currentSession = new Mock<ISessionConfiguration>();
|
currentSession = new Mock<ISessionConfiguration>();
|
||||||
logger = new Mock<ILogger>();
|
logger = new Mock<ILogger>();
|
||||||
nextSession = new Mock<ISessionConfiguration>();
|
nextSession = new Mock<ISessionConfiguration>();
|
||||||
|
nextSettings = new Settings();
|
||||||
sessionContext = new SessionContext();
|
sessionContext = new SessionContext();
|
||||||
|
|
||||||
|
nextSession.SetupGet(s => s.Settings).Returns(nextSettings);
|
||||||
sessionContext.Current = currentSession.Object;
|
sessionContext.Current = currentSession.Object;
|
||||||
sessionContext.Next = nextSession.Object;
|
sessionContext.Next = nextSession.Object;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue