Update Safe Exam Browser Patch to 3.10.0.826
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using SafeExamBrowser.Communication.Contracts.Data;
|
||||
using SafeExamBrowser.Communication.Contracts.Events;
|
||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||
using SafeExamBrowser.Communication.Contracts.Proxies;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Runtime.Communication;
|
||||
using SafeExamBrowser.Server.Contracts.Data;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.Settings.Security;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Communication
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientBridgeTests
|
||||
{
|
||||
private Mock<IClientProxy> clientProxy;
|
||||
private RuntimeContext context;
|
||||
private Mock<IRuntimeHost> runtimeHost;
|
||||
private SessionConfiguration currentSession;
|
||||
private AppSettings currentSettings;
|
||||
private ClientBridge sut;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
clientProxy = new Mock<IClientProxy>();
|
||||
context = new RuntimeContext();
|
||||
runtimeHost = new Mock<IRuntimeHost>();
|
||||
|
||||
currentSession = new SessionConfiguration();
|
||||
currentSettings = new AppSettings();
|
||||
currentSession.Settings = currentSettings;
|
||||
|
||||
context.ClientProxy = clientProxy.Object;
|
||||
context.Current = currentSession;
|
||||
|
||||
sut = new ClientBridge(runtimeHost.Object, context);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MustRequestServerExamSelectionCorrectly()
|
||||
{
|
||||
var exams = new[] { new Exam { Id = "abc1234" } };
|
||||
var examSelectionReceived = new Action<IEnumerable<(string, string, string, string)>, Guid>((e, id) =>
|
||||
{
|
||||
runtimeHost.Raise(r => r.ExamSelectionReceived += null, new ExamSelectionReplyEventArgs
|
||||
{
|
||||
RequestId = id,
|
||||
SelectedExamId = "abc1234",
|
||||
Success = true
|
||||
});
|
||||
});
|
||||
|
||||
currentSettings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
||||
clientProxy
|
||||
.Setup(c => c.RequestExamSelection(It.IsAny<IEnumerable<(string, string, string, string)>>(), It.IsAny<Guid>()))
|
||||
.Returns(new CommunicationResult(true))
|
||||
.Callback(examSelectionReceived);
|
||||
|
||||
sut.TryAskForExamSelection(exams, out var exam);
|
||||
|
||||
clientProxy.Verify(c => c.RequestExamSelection(It.IsAny<IEnumerable<(string, string, string, string)>>(), It.IsAny<Guid>()), Times.Once);
|
||||
|
||||
Assert.IsTrue(sut.IsRequired());
|
||||
Assert.AreEqual("abc1234", exam.Id);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MustRequestPasswordCorrectly()
|
||||
{
|
||||
var passwordReceived = new Action<PasswordRequestPurpose, Guid>((p, id) =>
|
||||
{
|
||||
runtimeHost.Raise(r => r.PasswordReceived += null, new PasswordReplyEventArgs { Password = "test", RequestId = id, Success = true });
|
||||
});
|
||||
|
||||
currentSettings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
||||
clientProxy
|
||||
.Setup(c => c.RequestPassword(It.IsAny<PasswordRequestPurpose>(), It.IsAny<Guid>()))
|
||||
.Returns(new CommunicationResult(true))
|
||||
.Callback(passwordReceived);
|
||||
|
||||
sut.TryGetPassword(default, out var password);
|
||||
|
||||
clientProxy.Verify(c => c.RequestPassword(It.IsAny<PasswordRequestPurpose>(), It.IsAny<Guid>()), Times.Once);
|
||||
|
||||
Assert.IsTrue(sut.IsRequired());
|
||||
Assert.AreEqual("test", password);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MustRequestServerFailureActionCorrectly()
|
||||
{
|
||||
var failureActionReceived = new Action<string, bool, Guid>((m, f, id) =>
|
||||
{
|
||||
runtimeHost.Raise(r => r.ServerFailureActionReceived += null, new ServerFailureActionReplyEventArgs
|
||||
{
|
||||
RequestId = id,
|
||||
Fallback = true
|
||||
});
|
||||
});
|
||||
|
||||
currentSettings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
||||
clientProxy
|
||||
.Setup(c => c.RequestServerFailureAction(It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<Guid>()))
|
||||
.Returns(new CommunicationResult(true))
|
||||
.Callback(failureActionReceived);
|
||||
|
||||
sut.TryAskForServerFailureAction(default, default, out var abort, out var fallback, out var retry);
|
||||
|
||||
clientProxy.Verify(c => c.RequestServerFailureAction(It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<Guid>()), Times.Once);
|
||||
|
||||
Assert.IsTrue(sut.IsRequired());
|
||||
Assert.IsFalse(abort);
|
||||
Assert.IsTrue(fallback);
|
||||
Assert.IsFalse(retry);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MustShowMessageBoxCorrectly()
|
||||
{
|
||||
var replyReceived = new Action<string, string, int, int, Guid>((m, t, a, i, id) =>
|
||||
{
|
||||
runtimeHost.Raise(r => r.MessageBoxReplyReceived += null, new MessageBoxReplyEventArgs
|
||||
{
|
||||
RequestId = id,
|
||||
Result = (int) MessageBoxResult.Yes
|
||||
});
|
||||
});
|
||||
|
||||
currentSettings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
||||
clientProxy
|
||||
.Setup(c => c.ShowMessage(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<Guid>()))
|
||||
.Callback(replyReceived)
|
||||
.Returns(new CommunicationResult(true));
|
||||
|
||||
var result = sut.ShowMessageBox(default, default, default, default);
|
||||
|
||||
clientProxy.Verify(c => c.ShowMessage(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<Guid>()), Times.Once);
|
||||
|
||||
Assert.IsTrue(sut.IsRequired());
|
||||
Assert.AreEqual(MessageBoxResult.Yes, result);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
<linker>
|
||||
<assembly fullname="System.Diagnostics.DiagnosticSource">
|
||||
<type fullname="System.Diagnostics.Metrics.MetricsEventSource">
|
||||
<!-- Used by System.Private.CoreLib via reflection to init the EventSource -->
|
||||
<method name="GetInstance" />
|
||||
</type>
|
||||
</assembly>
|
||||
</linker>
|
@@ -16,9 +16,13 @@ using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||
using SafeExamBrowser.Communication.Contracts.Proxies;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Runtime.Operations;
|
||||
using SafeExamBrowser.Runtime.Communication;
|
||||
using SafeExamBrowser.Runtime.Operations.Session;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
using SafeExamBrowser.WindowsApi.Contracts;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
@@ -29,20 +33,24 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
private Action clientReady;
|
||||
private Action terminated;
|
||||
private AppConfig appConfig;
|
||||
private Dependencies dependencies;
|
||||
private Mock<IClientProxy> proxy;
|
||||
private Mock<ILogger> logger;
|
||||
private Mock<IProcess> process;
|
||||
private Mock<IProcessFactory> processFactory;
|
||||
private Mock<IProxyFactory> proxyFactory;
|
||||
private RuntimeContext runtimeContext;
|
||||
private Mock<IRuntimeHost> runtimeHost;
|
||||
private SessionConfiguration session;
|
||||
private SessionContext sessionContext;
|
||||
private AppSettings settings;
|
||||
private ClientOperation sut;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
runtimeContext = new RuntimeContext();
|
||||
runtimeHost = new Mock<IRuntimeHost>();
|
||||
|
||||
appConfig = new AppConfig();
|
||||
clientReady = new Action(() => runtimeHost.Raise(h => h.ClientReady += null));
|
||||
logger = new Mock<ILogger>();
|
||||
@@ -50,9 +58,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
processFactory = new Mock<IProcessFactory>();
|
||||
proxy = new Mock<IClientProxy>();
|
||||
proxyFactory = new Mock<IProxyFactory>();
|
||||
runtimeHost = new Mock<IRuntimeHost>();
|
||||
session = new SessionConfiguration();
|
||||
sessionContext = new SessionContext();
|
||||
settings = new AppSettings();
|
||||
terminated = new Action(() =>
|
||||
{
|
||||
@@ -63,11 +69,19 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
appConfig.ClientLogFilePath = "";
|
||||
session.AppConfig = appConfig;
|
||||
session.Settings = settings;
|
||||
sessionContext.Current = session;
|
||||
sessionContext.Next = session;
|
||||
runtimeContext.Current = session;
|
||||
runtimeContext.Next = session;
|
||||
|
||||
dependencies = new Dependencies(
|
||||
new ClientBridge(Mock.Of<IRuntimeHost>(), runtimeContext),
|
||||
logger.Object,
|
||||
Mock.Of<IMessageBox>(),
|
||||
Mock.Of<IRuntimeWindow>(),
|
||||
runtimeContext,
|
||||
Mock.Of<IText>());
|
||||
proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny<string>(), It.IsAny<Interlocutor>())).Returns(proxy.Object);
|
||||
|
||||
sut = new ClientOperation(logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, sessionContext, 0);
|
||||
sut = new ClientOperation(dependencies, processFactory.Object, proxyFactory.Object, runtimeHost.Object, 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -84,8 +98,8 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
result = sut.Perform();
|
||||
|
||||
Assert.AreEqual(process.Object, sessionContext.ClientProcess);
|
||||
Assert.AreEqual(proxy.Object, sessionContext.ClientProxy);
|
||||
Assert.AreEqual(process.Object, runtimeContext.ClientProcess);
|
||||
Assert.AreEqual(proxy.Object, runtimeContext.ClientProxy);
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
}
|
||||
|
||||
@@ -100,7 +114,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var terminateClient = new Action(() => Task.Delay(100).ContinueWith(_ => process.Raise(p => p.Terminated += null, 0)));
|
||||
|
||||
processFactory.Setup(f => f.StartNew(It.IsAny<string>(), It.IsAny<string[]>())).Returns(process.Object).Callback(terminateClient);
|
||||
sut = new ClientOperation(logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, sessionContext, ONE_SECOND);
|
||||
sut = new ClientOperation(dependencies, processFactory.Object, proxyFactory.Object, runtimeHost.Object, ONE_SECOND);
|
||||
|
||||
before = DateTime.Now;
|
||||
result = sut.Perform();
|
||||
@@ -120,8 +134,8 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
result = sut.Perform();
|
||||
|
||||
Assert.IsNotNull(sessionContext.ClientProcess);
|
||||
Assert.IsNotNull(sessionContext.ClientProxy);
|
||||
Assert.IsNotNull(runtimeContext.ClientProcess);
|
||||
Assert.IsNotNull(runtimeContext.ClientProxy);
|
||||
Assert.AreEqual(OperationResult.Failed, result);
|
||||
}
|
||||
|
||||
@@ -139,8 +153,8 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
result = sut.Perform();
|
||||
|
||||
Assert.IsNotNull(sessionContext.ClientProcess);
|
||||
Assert.IsNotNull(sessionContext.ClientProxy);
|
||||
Assert.IsNotNull(runtimeContext.ClientProcess);
|
||||
Assert.IsNotNull(runtimeContext.ClientProxy);
|
||||
Assert.AreEqual(OperationResult.Failed, result);
|
||||
}
|
||||
|
||||
@@ -158,8 +172,8 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
result = sut.Repeat();
|
||||
|
||||
Assert.AreEqual(process.Object, sessionContext.ClientProcess);
|
||||
Assert.AreEqual(proxy.Object, sessionContext.ClientProxy);
|
||||
Assert.AreEqual(process.Object, runtimeContext.ClientProcess);
|
||||
Assert.AreEqual(proxy.Object, runtimeContext.ClientProxy);
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
}
|
||||
|
||||
@@ -175,8 +189,8 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
proxy.Verify(p => p.Disconnect(), Times.Once);
|
||||
process.Verify(p => p.TryKill(It.IsAny<int>()), Times.Never);
|
||||
|
||||
Assert.IsNull(sessionContext.ClientProcess);
|
||||
Assert.IsNull(sessionContext.ClientProxy);
|
||||
Assert.IsNull(runtimeContext.ClientProcess);
|
||||
Assert.IsNull(runtimeContext.ClientProxy);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -189,8 +203,8 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
process.Verify(p => p.TryKill(It.IsAny<int>()), Times.AtLeastOnce);
|
||||
|
||||
Assert.IsNull(sessionContext.ClientProcess);
|
||||
Assert.IsNull(sessionContext.ClientProxy);
|
||||
Assert.IsNull(runtimeContext.ClientProcess);
|
||||
Assert.IsNull(runtimeContext.ClientProxy);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -201,8 +215,8 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
process.Verify(p => p.TryKill(It.IsAny<int>()), Times.Exactly(5));
|
||||
|
||||
Assert.IsNotNull(sessionContext.ClientProcess);
|
||||
Assert.IsNotNull(sessionContext.ClientProxy);
|
||||
Assert.IsNotNull(runtimeContext.ClientProcess);
|
||||
Assert.IsNotNull(runtimeContext.ClientProxy);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -216,8 +230,8 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
proxy.Verify(p => p.Disconnect(), Times.Never);
|
||||
process.Verify(p => p.TryKill(It.IsAny<int>()), Times.Never);
|
||||
|
||||
Assert.IsNull(sessionContext.ClientProcess);
|
||||
Assert.IsNull(sessionContext.ClientProxy);
|
||||
Assert.IsNull(runtimeContext.ClientProcess);
|
||||
Assert.IsNull(runtimeContext.ClientProxy);
|
||||
}
|
||||
|
||||
private void PerformNormally()
|
||||
|
@@ -14,56 +14,58 @@ using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||
using SafeExamBrowser.Communication.Contracts.Proxies;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Runtime.Communication;
|
||||
using SafeExamBrowser.Runtime.Operations.Session;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
using SafeExamBrowser.WindowsApi.Contracts;
|
||||
using SafeExamBrowser.Runtime.Operations;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientTerminationOperationTests
|
||||
{
|
||||
private Action clientReady;
|
||||
private Action terminated;
|
||||
private AppConfig appConfig;
|
||||
private Mock<IClientProxy> proxy;
|
||||
private Mock<ILogger> logger;
|
||||
private Mock<IProcess> process;
|
||||
private Mock<IProcessFactory> processFactory;
|
||||
private Mock<IProxyFactory> proxyFactory;
|
||||
private Mock<IRuntimeHost> runtimeHost;
|
||||
private SessionConfiguration session;
|
||||
private SessionContext sessionContext;
|
||||
|
||||
private RuntimeContext runtimeContext;
|
||||
private ClientTerminationOperation sut;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
runtimeContext = new RuntimeContext();
|
||||
runtimeHost = new Mock<IRuntimeHost>();
|
||||
|
||||
appConfig = new AppConfig();
|
||||
clientReady = new Action(() => runtimeHost.Raise(h => h.ClientReady += null));
|
||||
logger = new Mock<ILogger>();
|
||||
process = new Mock<IProcess>();
|
||||
processFactory = new Mock<IProcessFactory>();
|
||||
proxy = new Mock<IClientProxy>();
|
||||
proxyFactory = new Mock<IProxyFactory>();
|
||||
runtimeHost = new Mock<IRuntimeHost>();
|
||||
session = new SessionConfiguration();
|
||||
sessionContext = new SessionContext();
|
||||
terminated = new Action(() =>
|
||||
{
|
||||
runtimeHost.Raise(h => h.ClientDisconnected += null);
|
||||
process.Raise(p => p.Terminated += null, 0);
|
||||
});
|
||||
|
||||
session.AppConfig = appConfig;
|
||||
sessionContext.ClientProcess = process.Object;
|
||||
sessionContext.ClientProxy = proxy.Object;
|
||||
sessionContext.Current = session;
|
||||
sessionContext.Next = session;
|
||||
runtimeContext.ClientProcess = process.Object;
|
||||
runtimeContext.ClientProxy = proxy.Object;
|
||||
runtimeContext.Current = session;
|
||||
runtimeContext.Next = session;
|
||||
proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny<string>(), It.IsAny<Interlocutor>())).Returns(proxy.Object);
|
||||
|
||||
sut = new ClientTerminationOperation(logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, sessionContext, 0);
|
||||
var dependencies = new Dependencies(
|
||||
new ClientBridge(Mock.Of<IRuntimeHost>(), runtimeContext),
|
||||
Mock.Of<ILogger>(),
|
||||
Mock.Of<IMessageBox>(),
|
||||
Mock.Of<IRuntimeWindow>(),
|
||||
runtimeContext,
|
||||
Mock.Of<IText>());
|
||||
|
||||
sut = new ClientTerminationOperation(dependencies, processFactory.Object, proxyFactory.Object, runtimeHost.Object, 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -81,10 +83,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
proxy.Verify(p => p.InitiateShutdown(), Times.Once);
|
||||
proxy.Verify(p => p.Disconnect(), Times.Once);
|
||||
process.Verify(p => p.TryKill(default(int)), Times.Never);
|
||||
process.Verify(p => p.TryKill(default), Times.Never);
|
||||
|
||||
Assert.IsNull(sessionContext.ClientProcess);
|
||||
Assert.IsNull(sessionContext.ClientProxy);
|
||||
Assert.IsNull(runtimeContext.ClientProcess);
|
||||
Assert.IsNull(runtimeContext.ClientProxy);
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
}
|
||||
|
||||
@@ -92,7 +94,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
public void MustDoNothingOnRepeatIfNoClientRunning()
|
||||
{
|
||||
process.SetupGet(p => p.HasTerminated).Returns(true);
|
||||
sessionContext.ClientProcess = process.Object;
|
||||
runtimeContext.ClientProcess = process.Object;
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
|
@@ -11,14 +11,22 @@ using System.IO;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using SafeExamBrowser.Communication.Contracts.Data;
|
||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||
using SafeExamBrowser.Communication.Contracts.Proxies;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Configuration.Contracts.Cryptography;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Runtime.Operations;
|
||||
using SafeExamBrowser.Runtime.Operations.Events;
|
||||
using SafeExamBrowser.Runtime.Communication;
|
||||
using SafeExamBrowser.Runtime.Operations.Session;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.Settings.Security;
|
||||
using SafeExamBrowser.SystemComponents.Contracts;
|
||||
using SafeExamBrowser.UserInterface.Contracts;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows.Data;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
@@ -28,13 +36,17 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
private const string FILE_NAME = "SebClientSettings.seb";
|
||||
|
||||
private AppConfig appConfig;
|
||||
private RuntimeContext context;
|
||||
private Dependencies dependencies;
|
||||
private SessionConfiguration currentSession;
|
||||
private SessionConfiguration nextSession;
|
||||
|
||||
private Mock<IFileSystem> fileSystem;
|
||||
private Mock<IHashAlgorithm> hashAlgorithm;
|
||||
private Mock<ILogger> logger;
|
||||
private Mock<IConfigurationRepository> repository;
|
||||
private SessionConfiguration currentSession;
|
||||
private SessionConfiguration nextSession;
|
||||
private SessionContext sessionContext;
|
||||
private Mock<IMessageBox> messageBox;
|
||||
private Mock<IUserInterfaceFactory> uiFactory;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
@@ -45,15 +57,26 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
logger = new Mock<ILogger>();
|
||||
repository = new Mock<IConfigurationRepository>();
|
||||
currentSession = new SessionConfiguration();
|
||||
messageBox = new Mock<IMessageBox>();
|
||||
nextSession = new SessionConfiguration();
|
||||
sessionContext = new SessionContext();
|
||||
context = new RuntimeContext();
|
||||
uiFactory = new Mock<IUserInterfaceFactory>();
|
||||
|
||||
dependencies = new Dependencies(
|
||||
new ClientBridge(Mock.Of<IRuntimeHost>(), context),
|
||||
logger.Object,
|
||||
messageBox.Object,
|
||||
Mock.Of<IRuntimeWindow>(),
|
||||
context,
|
||||
Mock.Of<IText>());
|
||||
|
||||
appConfig.AppDataFilePath = $@"C:\Not\Really\AppData\File.xml";
|
||||
appConfig.ProgramDataFilePath = $@"C:\Not\Really\ProgramData\File.xml";
|
||||
currentSession.AppConfig = appConfig;
|
||||
currentSession.Settings = new AppSettings();
|
||||
nextSession.AppConfig = appConfig;
|
||||
sessionContext.Current = currentSession;
|
||||
sessionContext.Next = nextSession;
|
||||
context.Current = currentSession;
|
||||
context.Next = nextSession;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -68,7 +91,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "blubb.exe", url }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
var sut = new ConfigurationOperation(new[] { "abc.exe", url }, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
var resource = new Uri(url);
|
||||
|
||||
@@ -86,7 +109,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
|
||||
var sut = new ConfigurationOperation(null, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
var sut = new ConfigurationOperation(null, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
repository.Verify(r => r.TryLoadSettings(It.Is<Uri>(u => u.Equals(location)), out settings, It.IsAny<PasswordParameters>()), Times.Once);
|
||||
@@ -102,7 +125,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
appConfig.AppDataFilePath = location;
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
|
||||
var sut = new ConfigurationOperation(null, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
var sut = new ConfigurationOperation(null, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
repository.Verify(r => r.TryLoadSettings(It.Is<Uri>(u => u.Equals(location)), out settings, It.IsAny<PasswordParameters>()), Times.Once);
|
||||
@@ -118,7 +141,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
nextSession.Settings = settings;
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.LoadWithBrowser);
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "blubb.exe", url }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
var sut = new ConfigurationOperation(new[] { "abc.exe", url }, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
Assert.IsFalse(settings.Browser.DeleteCacheOnShutdown);
|
||||
@@ -135,7 +158,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
repository.Setup(r => r.LoadDefaultSettings()).Returns(defaultSettings);
|
||||
|
||||
var sut = new ConfigurationOperation(null, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
var sut = new ConfigurationOperation(null, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
repository.Verify(r => r.LoadDefaultSettings(), Times.Once);
|
||||
@@ -150,20 +173,16 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var settings = new AppSettings();
|
||||
var url = @"http://www.safeexambrowser.org/whatever.seb";
|
||||
|
||||
sessionContext.Current = null;
|
||||
context.Current = null;
|
||||
settings.ConfigurationMode = ConfigurationMode.ConfigureClient;
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
repository.Setup(r => r.ConfigureClientWith(It.IsAny<Uri>(), It.IsAny<PasswordParameters>())).Returns(SaveStatus.Success);
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "blubb.exe", url }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
sut.ActionRequired += args =>
|
||||
{
|
||||
if (args is ConfigurationCompletedEventArgs c)
|
||||
{
|
||||
c.AbortStartup = true;
|
||||
}
|
||||
};
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Returns(MessageBoxResult.Yes);
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "abc.exe", url }, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
Assert.AreEqual(OperationResult.Aborted, result);
|
||||
@@ -179,15 +198,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
repository.Setup(r => r.ConfigureClientWith(It.IsAny<Uri>(), It.IsAny<PasswordParameters>())).Returns(SaveStatus.Success);
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "blubb.exe", url }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
sut.ActionRequired += args =>
|
||||
{
|
||||
if (args is ConfigurationCompletedEventArgs c)
|
||||
{
|
||||
c.AbortStartup = false;
|
||||
}
|
||||
};
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Returns(MessageBoxResult.No);
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "abc.exe", url }, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
@@ -204,15 +219,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
repository.Setup(r => r.ConfigureClientWith(It.IsAny<Uri>(), It.IsAny<PasswordParameters>())).Returns(SaveStatus.UnexpectedError);
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "blubb.exe", url }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
sut.ActionRequired += args =>
|
||||
{
|
||||
if (args is ClientConfigurationErrorMessageArgs)
|
||||
{
|
||||
informed = true;
|
||||
}
|
||||
};
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => informed = true);
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "abc.exe", url }, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
Assert.AreEqual(OperationResult.Failed, result);
|
||||
@@ -227,15 +238,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
settings.ConfigurationMode = ConfigurationMode.Exam;
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
|
||||
var sut = new ConfigurationOperation(null, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
sut.ActionRequired += args =>
|
||||
{
|
||||
if (args is ConfigurationCompletedEventArgs c)
|
||||
{
|
||||
Assert.Fail();
|
||||
}
|
||||
};
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(Assert.Fail);
|
||||
|
||||
var sut = new ConfigurationOperation(null, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
@@ -249,14 +256,14 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
repository.Setup(r => r.LoadDefaultSettings()).Returns(defaultSettings);
|
||||
|
||||
var sut = new ConfigurationOperation(null, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
var sut = new ConfigurationOperation(null, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
result = sut.Perform();
|
||||
|
||||
repository.Verify(r => r.LoadDefaultSettings(), Times.Once);
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
Assert.AreSame(defaultSettings, nextSession.Settings);
|
||||
|
||||
sut = new ConfigurationOperation(new string[] { }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
sut = new ConfigurationOperation(new string[] { }, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
result = sut.Perform();
|
||||
|
||||
repository.Verify(r => r.LoadDefaultSettings(), Times.Exactly(2));
|
||||
@@ -268,7 +275,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
public void Perform_MustNotFailWithInvalidUri()
|
||||
{
|
||||
var uri = @"an/invalid\uri.'*%yolo/()你好";
|
||||
var sut = new ConfigurationOperation(new[] { "blubb.exe", uri }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
var sut = new ConfigurationOperation(new[] { "abc.exe", uri }, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
@@ -278,6 +285,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
public void Perform_MustOnlyAllowToEnterAdminPasswordFiveTimes()
|
||||
{
|
||||
var count = 0;
|
||||
var dialog = new Mock<IPasswordDialog>();
|
||||
var localSettings = new AppSettings();
|
||||
var settings = new AppSettings { ConfigurationMode = ConfigurationMode.ConfigureClient };
|
||||
var url = @"http://www.safeexambrowser.org/whatever.seb";
|
||||
@@ -285,21 +293,14 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
appConfig.AppDataFilePath = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), nameof(Operations), "Testdata", FILE_NAME);
|
||||
localSettings.Security.AdminPasswordHash = "1234";
|
||||
settings.Security.AdminPasswordHash = "9876";
|
||||
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
repository.Setup(r => r.TryLoadSettings(It.Is<Uri>(u => u.LocalPath.Contains(FILE_NAME)), out localSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
nextSession.Settings = settings;
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "blubb.exe", url }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
sut.ActionRequired += args =>
|
||||
{
|
||||
if (args is PasswordRequiredEventArgs p && p.Purpose == PasswordRequestPurpose.LocalAdministrator)
|
||||
{
|
||||
count++;
|
||||
p.Success = true;
|
||||
}
|
||||
};
|
||||
dialog.Setup(d => d.Show(It.IsAny<IWindow>())).Callback(() => count++).Returns(new PasswordDialogResult { Success = true });
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
repository.Setup(r => r.TryLoadSettings(It.Is<Uri>(u => u.LocalPath.Contains(FILE_NAME)), out localSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
uiFactory.Setup(f => f.CreatePasswordDialog(It.IsAny<string>(), It.IsAny<string>())).Returns(dialog.Object);
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "abc.exe", url }, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
Assert.AreEqual(5, count);
|
||||
@@ -310,21 +311,15 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
public void Perform_MustOnlyAllowToEnterSettingsPasswordFiveTimes()
|
||||
{
|
||||
var count = 0;
|
||||
var dialog = new Mock<IPasswordDialog>();
|
||||
var settings = default(AppSettings);
|
||||
var url = @"http://www.safeexambrowser.org/whatever.seb";
|
||||
|
||||
dialog.Setup(d => d.Show(It.IsAny<IWindow>())).Callback(() => count++).Returns(new PasswordDialogResult { Success = true });
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.PasswordNeeded);
|
||||
uiFactory.Setup(f => f.CreatePasswordDialog(It.IsAny<string>(), It.IsAny<string>())).Returns(dialog.Object);
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "blubb.exe", url }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
sut.ActionRequired += args =>
|
||||
{
|
||||
if (args is PasswordRequiredEventArgs p && p.Purpose == PasswordRequestPurpose.Settings)
|
||||
{
|
||||
count++;
|
||||
p.Success = true;
|
||||
}
|
||||
};
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "abc.exe", url }, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
repository.Verify(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.IsAny<PasswordParameters>()), Times.Exactly(6));
|
||||
@@ -336,6 +331,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
[TestMethod]
|
||||
public void Perform_MustSucceedIfAdminPasswordCorrect()
|
||||
{
|
||||
var dialog = new Mock<IPasswordDialog>();
|
||||
var password = "test";
|
||||
var currentSettings = new AppSettings { ConfigurationMode = ConfigurationMode.ConfigureClient };
|
||||
var nextSettings = new AppSettings { ConfigurationMode = ConfigurationMode.ConfigureClient };
|
||||
@@ -344,21 +340,15 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
currentSettings.Security.AdminPasswordHash = "1234";
|
||||
nextSession.Settings = nextSettings;
|
||||
nextSettings.Security.AdminPasswordHash = "9876";
|
||||
|
||||
dialog.Setup(d => d.Show(It.IsAny<IWindow>())).Returns(new PasswordDialogResult { Password = password, Success = true });
|
||||
hashAlgorithm.Setup(h => h.GenerateHashFor(It.Is<string>(p => p == password))).Returns(currentSettings.Security.AdminPasswordHash);
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out currentSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
repository.Setup(r => r.TryLoadSettings(It.Is<Uri>(u => u.AbsoluteUri == url), out nextSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
repository.Setup(r => r.ConfigureClientWith(It.IsAny<Uri>(), It.IsAny<PasswordParameters>())).Returns(SaveStatus.Success);
|
||||
uiFactory.Setup(f => f.CreatePasswordDialog(It.IsAny<string>(), It.IsAny<string>())).Returns(dialog.Object);
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "blubb.exe", url }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
sut.ActionRequired += args =>
|
||||
{
|
||||
if (args is PasswordRequiredEventArgs p && p.Purpose == PasswordRequestPurpose.LocalAdministrator)
|
||||
{
|
||||
p.Password = password;
|
||||
p.Success = true;
|
||||
}
|
||||
};
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "abc.exe", url }, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
repository.Verify(r => r.ConfigureClientWith(It.IsAny<Uri>(), It.IsAny<PasswordParameters>()), Times.Once);
|
||||
@@ -379,16 +369,9 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out currentSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
repository.Setup(r => r.TryLoadSettings(It.Is<Uri>(u => u.AbsoluteUri == url), out nextSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
repository.Setup(r => r.ConfigureClientWith(It.IsAny<Uri>(), It.IsAny<PasswordParameters>())).Returns(SaveStatus.Success);
|
||||
uiFactory.Setup(f => f.CreatePasswordDialog(It.IsAny<string>(), It.IsAny<string>())).Callback(Assert.Fail);
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "blubb.exe", url }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
sut.ActionRequired += args =>
|
||||
{
|
||||
if (args is PasswordRequiredEventArgs)
|
||||
{
|
||||
Assert.Fail();
|
||||
}
|
||||
};
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "abc.exe", url }, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
hashAlgorithm.Verify(h => h.GenerateHashFor(It.IsAny<string>()), Times.Never);
|
||||
@@ -399,23 +382,17 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
[TestMethod]
|
||||
public void Perform_MustSucceedIfSettingsPasswordCorrect()
|
||||
{
|
||||
var dialog = new Mock<IPasswordDialog>();
|
||||
var password = "test";
|
||||
var settings = new AppSettings { ConfigurationMode = ConfigurationMode.Exam };
|
||||
var url = @"http://www.safeexambrowser.org/whatever.seb";
|
||||
|
||||
dialog.Setup(d => d.Show(It.IsAny<IWindow>())).Returns(new PasswordDialogResult { Password = password, Success = true });
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.PasswordNeeded);
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.Is<PasswordParameters>(p => p.Password == password))).Returns(LoadStatus.Success);
|
||||
uiFactory.Setup(f => f.CreatePasswordDialog(It.IsAny<string>(), It.IsAny<string>())).Returns(dialog.Object);
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "blubb.exe", url }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
sut.ActionRequired += args =>
|
||||
{
|
||||
if (args is PasswordRequiredEventArgs p)
|
||||
{
|
||||
p.Password = password;
|
||||
p.Success = true;
|
||||
}
|
||||
};
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "abc.exe", url }, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
repository.Verify(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.Is<PasswordParameters>(p => p.Password == password)), Times.AtLeastOnce);
|
||||
@@ -443,7 +420,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.Is<PasswordParameters>(p => p.IsHash == true && p.Password == settings.Security.AdminPasswordHash)))
|
||||
.Returns(LoadStatus.Success);
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "blubb.exe", url }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
var sut = new ConfigurationOperation(new[] { "abc.exe", url }, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
repository.Verify(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.Is<PasswordParameters>(p => p.Password == settings.Security.AdminPasswordHash)), Times.AtLeastOnce);
|
||||
@@ -454,29 +431,25 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
[TestMethod]
|
||||
public void Perform_MustAbortAskingForAdminPasswordIfDecidedByUser()
|
||||
{
|
||||
var dialog = new Mock<IPasswordDialog>();
|
||||
var password = "test";
|
||||
var currentSettings = new AppSettings { ConfigurationMode = ConfigurationMode.ConfigureClient };
|
||||
var nextSettings = new AppSettings { ConfigurationMode = ConfigurationMode.ConfigureClient };
|
||||
var url = @"http://www.safeexambrowser.org/whatever.seb";
|
||||
|
||||
appConfig.AppDataFilePath = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), nameof(Operations), "Testdata", FILE_NAME);
|
||||
currentSession.Settings = currentSettings;
|
||||
currentSettings.Security.AdminPasswordHash = "1234";
|
||||
nextSession.Settings = nextSettings;
|
||||
nextSettings.Security.AdminPasswordHash = "9876";
|
||||
|
||||
dialog.Setup(d => d.Show(It.IsAny<IWindow>())).Returns(new PasswordDialogResult { Success = false });
|
||||
hashAlgorithm.Setup(h => h.GenerateHashFor(It.Is<string>(p => p == password))).Returns(currentSettings.Security.AdminPasswordHash);
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out currentSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
repository.Setup(r => r.TryLoadSettings(It.Is<Uri>(u => u.AbsoluteUri == url), out nextSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
uiFactory.Setup(f => f.CreatePasswordDialog(It.IsAny<string>(), It.IsAny<string>())).Returns(dialog.Object);
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "blubb.exe", url }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
sut.ActionRequired += args =>
|
||||
{
|
||||
if (args is PasswordRequiredEventArgs p && p.Purpose == PasswordRequestPurpose.LocalAdministrator)
|
||||
{
|
||||
p.Success = false;
|
||||
}
|
||||
};
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "abc.exe", url }, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
repository.Verify(r => r.ConfigureClientWith(It.IsAny<Uri>(), It.IsAny<PasswordParameters>()), Times.Never);
|
||||
@@ -487,20 +460,15 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
[TestMethod]
|
||||
public void Perform_MustAbortAskingForSettingsPasswordIfDecidedByUser()
|
||||
{
|
||||
var dialog = new Mock<IPasswordDialog>();
|
||||
var settings = default(AppSettings);
|
||||
var url = @"http://www.safeexambrowser.org/whatever.seb";
|
||||
|
||||
dialog.Setup(d => d.Show(It.IsAny<IWindow>())).Returns(new PasswordDialogResult { Success = false });
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.PasswordNeeded);
|
||||
uiFactory.Setup(f => f.CreatePasswordDialog(It.IsAny<string>(), It.IsAny<string>())).Returns(dialog.Object);
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "blubb.exe", url }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
sut.ActionRequired += args =>
|
||||
{
|
||||
if (args is PasswordRequiredEventArgs p)
|
||||
{
|
||||
p.Success = false;
|
||||
}
|
||||
};
|
||||
|
||||
var sut = new ConfigurationOperation(new[] { "abc.exe", url }, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Perform();
|
||||
|
||||
Assert.AreEqual(OperationResult.Aborted, result);
|
||||
@@ -515,10 +483,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var settings = new AppSettings { ConfigurationMode = ConfigurationMode.Exam };
|
||||
|
||||
currentSession.Settings = currentSettings;
|
||||
sessionContext.ReconfigurationFilePath = resource.LocalPath;
|
||||
context.ReconfigurationFilePath = resource.LocalPath;
|
||||
repository.Setup(r => r.TryLoadSettings(It.Is<Uri>(u => u.Equals(resource)), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
|
||||
var sut = new ConfigurationOperation(null, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
var sut = new ConfigurationOperation(null, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Repeat();
|
||||
|
||||
fileSystem.Verify(f => f.Delete(It.Is<string>(s => s == resource.LocalPath)), Times.Once);
|
||||
@@ -537,11 +505,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var settings = new AppSettings { ConfigurationMode = ConfigurationMode.ConfigureClient };
|
||||
|
||||
currentSession.Settings = currentSettings;
|
||||
sessionContext.ReconfigurationFilePath = resource.LocalPath;
|
||||
context.ReconfigurationFilePath = resource.LocalPath;
|
||||
repository.Setup(r => r.TryLoadSettings(It.Is<Uri>(u => u.Equals(resource)), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
repository.Setup(r => r.ConfigureClientWith(It.Is<Uri>(u => u.Equals(resource)), It.IsAny<PasswordParameters>())).Returns(SaveStatus.Success);
|
||||
|
||||
var sut = new ConfigurationOperation(null, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
var sut = new ConfigurationOperation(null, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Repeat();
|
||||
|
||||
fileSystem.Verify(f => f.Delete(It.Is<string>(s => s == resource.LocalPath)), Times.Once);
|
||||
@@ -563,12 +531,12 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var order = 0;
|
||||
|
||||
currentSession.Settings = currentSettings;
|
||||
sessionContext.ReconfigurationFilePath = resource.LocalPath;
|
||||
context.ReconfigurationFilePath = resource.LocalPath;
|
||||
fileSystem.Setup(f => f.Delete(It.IsAny<string>())).Callback(() => delete = ++order);
|
||||
repository.Setup(r => r.TryLoadSettings(It.Is<Uri>(u => u.Equals(resource)), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
repository.Setup(r => r.ConfigureClientWith(It.Is<Uri>(u => u.Equals(resource)), It.IsAny<PasswordParameters>())).Returns(SaveStatus.Success).Callback(() => configure = ++order);
|
||||
|
||||
var sut = new ConfigurationOperation(null, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
var sut = new ConfigurationOperation(null, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Repeat();
|
||||
|
||||
fileSystem.Verify(f => f.Delete(It.Is<string>(s => s == resource.LocalPath)), Times.Once);
|
||||
@@ -586,17 +554,17 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var resource = new Uri("file:///C:/does/not/exist.txt");
|
||||
var settings = default(AppSettings);
|
||||
|
||||
sessionContext.ReconfigurationFilePath = null;
|
||||
context.ReconfigurationFilePath = null;
|
||||
repository.Setup(r => r.TryLoadSettings(It.IsAny<Uri>(), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
|
||||
var sut = new ConfigurationOperation(null, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
var sut = new ConfigurationOperation(null, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Repeat();
|
||||
|
||||
fileSystem.Verify(f => f.Delete(It.Is<string>(s => s == resource.LocalPath)), Times.Never);
|
||||
repository.Verify(r => r.TryLoadSettings(It.Is<Uri>(u => u.Equals(resource)), out settings, It.IsAny<PasswordParameters>()), Times.Never);
|
||||
Assert.AreEqual(OperationResult.Failed, result);
|
||||
|
||||
sessionContext.ReconfigurationFilePath = resource.LocalPath;
|
||||
context.ReconfigurationFilePath = resource.LocalPath;
|
||||
result = sut.Repeat();
|
||||
|
||||
fileSystem.Verify(f => f.Delete(It.Is<string>(s => s == resource.LocalPath)), Times.Never);
|
||||
@@ -608,33 +576,52 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
public void Repeat_MustAbortForSettingsPasswordIfWishedByUser()
|
||||
{
|
||||
var currentSettings = new AppSettings();
|
||||
var dialog = new Mock<IPasswordDialog>();
|
||||
var location = Path.GetDirectoryName(GetType().Assembly.Location);
|
||||
var resource = new Uri(Path.Combine(location, nameof(Operations), "Testdata", FILE_NAME));
|
||||
var settings = new AppSettings { ConfigurationMode = ConfigurationMode.ConfigureClient };
|
||||
|
||||
currentSession.Settings = currentSettings;
|
||||
sessionContext.ReconfigurationFilePath = resource.LocalPath;
|
||||
context.ReconfigurationFilePath = resource.LocalPath;
|
||||
|
||||
dialog.Setup(d => d.Show(It.IsAny<IWindow>())).Returns(new PasswordDialogResult { Success = false });
|
||||
repository.Setup(r => r.TryLoadSettings(It.Is<Uri>(u => u.Equals(resource)), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.PasswordNeeded);
|
||||
uiFactory.Setup(f => f.CreatePasswordDialog(It.IsAny<string>(), It.IsAny<string>())).Returns(dialog.Object);
|
||||
|
||||
var sut = new ConfigurationOperation(null, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
sut.ActionRequired += args =>
|
||||
{
|
||||
if (args is PasswordRequiredEventArgs p)
|
||||
{
|
||||
p.Success = false;
|
||||
}
|
||||
};
|
||||
|
||||
var sut = new ConfigurationOperation(null, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Repeat();
|
||||
|
||||
fileSystem.Verify(f => f.Delete(It.Is<string>(s => s == resource.LocalPath)), Times.Once);
|
||||
Assert.AreEqual(OperationResult.Aborted, result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Repeat_MustNotWaitForPasswordViaClientIfCommunicationHasFailed()
|
||||
{
|
||||
var clientProxy = new Mock<IClientProxy>();
|
||||
var currentSettings = new AppSettings();
|
||||
var location = Path.GetDirectoryName(GetType().Assembly.Location);
|
||||
var resource = new Uri(Path.Combine(location, nameof(Operations), "Testdata", FILE_NAME));
|
||||
var settings = new AppSettings { ConfigurationMode = ConfigurationMode.ConfigureClient };
|
||||
|
||||
context.ClientProxy = clientProxy.Object;
|
||||
context.ReconfigurationFilePath = resource.LocalPath;
|
||||
currentSession.Settings = currentSettings;
|
||||
currentSettings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
||||
clientProxy.Setup(c => c.RequestPassword(It.IsAny<PasswordRequestPurpose>(), It.IsAny<Guid>())).Returns(new CommunicationResult(false));
|
||||
repository.Setup(r => r.TryLoadSettings(It.Is<Uri>(u => u.Equals(resource)), out settings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.PasswordNeeded);
|
||||
|
||||
var sut = new ConfigurationOperation(null, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Repeat();
|
||||
|
||||
clientProxy.Verify(c => c.RequestPassword(It.IsAny<PasswordRequestPurpose>(), It.IsAny<Guid>()), Times.Once);
|
||||
Assert.AreEqual(OperationResult.Aborted, result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Revert_MustDoNothing()
|
||||
{
|
||||
var sut = new ConfigurationOperation(null, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||
var sut = new ConfigurationOperation(null, dependencies, fileSystem.Object, hashAlgorithm.Object, repository.Object, uiFactory.Object);
|
||||
var result = sut.Revert();
|
||||
|
||||
fileSystem.VerifyNoOtherCalls();
|
||||
|
@@ -8,35 +8,47 @@
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Runtime.Operations;
|
||||
using SafeExamBrowser.Runtime.Operations.Events;
|
||||
using SafeExamBrowser.Runtime.Communication;
|
||||
using SafeExamBrowser.Runtime.Operations.Session;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
[TestClass]
|
||||
public class DisclaimerOperationTests
|
||||
{
|
||||
private Mock<ILogger> logger;
|
||||
private RuntimeContext context;
|
||||
private Mock<IMessageBox> messageBox;
|
||||
private AppSettings settings;
|
||||
private SessionContext context;
|
||||
|
||||
private DisclaimerOperation sut;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
context = new SessionContext();
|
||||
logger = new Mock<ILogger>();
|
||||
context = new RuntimeContext();
|
||||
messageBox = new Mock<IMessageBox>();
|
||||
settings = new AppSettings();
|
||||
|
||||
context.Next = new SessionConfiguration();
|
||||
context.Next.Settings = settings;
|
||||
sut = new DisclaimerOperation(logger.Object, context);
|
||||
|
||||
var dependencies = new Dependencies(
|
||||
new ClientBridge(Mock.Of<IRuntimeHost>(), context),
|
||||
Mock.Of<ILogger>(),
|
||||
messageBox.Object,
|
||||
Mock.Of<IRuntimeWindow>(),
|
||||
context,
|
||||
Mock.Of<IText>());
|
||||
|
||||
sut = new DisclaimerOperation(dependencies);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -45,15 +57,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var count = 0;
|
||||
|
||||
settings.Proctoring.ScreenProctoring.Enabled = true;
|
||||
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is MessageEventArgs m)
|
||||
{
|
||||
count++;
|
||||
m.Result = MessageBoxResult.Ok;
|
||||
}
|
||||
};
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => count++)
|
||||
.Returns(MessageBoxResult.Ok);
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
@@ -67,15 +74,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var disclaimerShown = false;
|
||||
|
||||
settings.Proctoring.ScreenProctoring.Enabled = true;
|
||||
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is MessageEventArgs m)
|
||||
{
|
||||
disclaimerShown = true;
|
||||
m.Result = MessageBoxResult.Cancel;
|
||||
}
|
||||
};
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => disclaimerShown = true)
|
||||
.Returns(MessageBoxResult.Cancel);
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
@@ -88,14 +90,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
var disclaimerShown = false;
|
||||
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is MessageEventArgs m)
|
||||
{
|
||||
disclaimerShown = true;
|
||||
m.Result = MessageBoxResult.Cancel;
|
||||
}
|
||||
};
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => disclaimerShown = true)
|
||||
.Returns(MessageBoxResult.Cancel);
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
@@ -109,15 +107,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var count = 0;
|
||||
|
||||
settings.Proctoring.ScreenProctoring.Enabled = true;
|
||||
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is MessageEventArgs m)
|
||||
{
|
||||
count++;
|
||||
m.Result = MessageBoxResult.Ok;
|
||||
}
|
||||
};
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => count++)
|
||||
.Returns(MessageBoxResult.Ok);
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
@@ -131,15 +124,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var disclaimerShown = false;
|
||||
|
||||
settings.Proctoring.ScreenProctoring.Enabled = true;
|
||||
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is MessageEventArgs m)
|
||||
{
|
||||
disclaimerShown = true;
|
||||
m.Result = MessageBoxResult.Cancel;
|
||||
}
|
||||
};
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => disclaimerShown = true)
|
||||
.Returns(MessageBoxResult.Cancel);
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
@@ -152,14 +140,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
var disclaimerShown = false;
|
||||
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is MessageEventArgs m)
|
||||
{
|
||||
disclaimerShown = true;
|
||||
m.Result = MessageBoxResult.Cancel;
|
||||
}
|
||||
};
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => disclaimerShown = true)
|
||||
.Returns(MessageBoxResult.Cancel);
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
@@ -172,14 +156,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
var disclaimerShown = false;
|
||||
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is MessageEventArgs m)
|
||||
{
|
||||
disclaimerShown = true;
|
||||
m.Result = MessageBoxResult.Cancel;
|
||||
}
|
||||
};
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => disclaimerShown = true)
|
||||
.Returns(MessageBoxResult.Cancel);
|
||||
|
||||
var result = sut.Revert();
|
||||
|
||||
|
@@ -8,24 +8,27 @@
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Monitoring.Contracts.Display;
|
||||
using SafeExamBrowser.Runtime.Operations;
|
||||
using SafeExamBrowser.Runtime.Operations.Events;
|
||||
using SafeExamBrowser.Runtime.Communication;
|
||||
using SafeExamBrowser.Runtime.Operations.Session;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.Settings.Monitoring;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
[TestClass]
|
||||
public class DisplayMonitorOperationTests
|
||||
{
|
||||
private SessionContext context;
|
||||
private RuntimeContext context;
|
||||
private Mock<IDisplayMonitor> displayMonitor;
|
||||
private Mock<ILogger> logger;
|
||||
private Mock<IMessageBox> messageBox;
|
||||
private AppSettings settings;
|
||||
private Mock<IText> text;
|
||||
|
||||
@@ -34,15 +37,24 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
context = new SessionContext();
|
||||
context = new RuntimeContext();
|
||||
displayMonitor = new Mock<IDisplayMonitor>();
|
||||
logger = new Mock<ILogger>();
|
||||
messageBox = new Mock<IMessageBox>();
|
||||
settings = new AppSettings();
|
||||
text = new Mock<IText>();
|
||||
|
||||
context.Next = new SessionConfiguration();
|
||||
context.Next.Settings = settings;
|
||||
sut = new DisplayMonitorOperation(displayMonitor.Object, logger.Object, context, text.Object);
|
||||
|
||||
var dependencies = new Dependencies(
|
||||
new ClientBridge(Mock.Of<IRuntimeHost>(), context),
|
||||
Mock.Of<ILogger>(),
|
||||
messageBox.Object,
|
||||
Mock.Of<IRuntimeWindow>(),
|
||||
context,
|
||||
text.Object);
|
||||
|
||||
sut = new DisplayMonitorOperation(dependencies, displayMonitor.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -62,13 +74,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var messageShown = false;
|
||||
|
||||
displayMonitor.Setup(m => m.ValidateConfiguration(It.IsAny<DisplaySettings>())).Returns(new ValidationResult { IsAllowed = false });
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is MessageEventArgs)
|
||||
{
|
||||
messageShown = true;
|
||||
}
|
||||
};
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => messageShown = true);
|
||||
text.Setup(t => t.Get(It.IsAny<TextKey>())).Returns(string.Empty);
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
@@ -95,13 +104,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var messageShown = false;
|
||||
|
||||
displayMonitor.Setup(m => m.ValidateConfiguration(It.IsAny<DisplaySettings>())).Returns(new ValidationResult { IsAllowed = false });
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is MessageEventArgs)
|
||||
{
|
||||
messageShown = true;
|
||||
}
|
||||
};
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => messageShown = true);
|
||||
text.Setup(t => t.Get(It.IsAny<TextKey>())).Returns(string.Empty);
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
|
@@ -8,12 +8,17 @@
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Runtime.Operations;
|
||||
using SafeExamBrowser.Runtime.Communication;
|
||||
using SafeExamBrowser.Runtime.Operations.Session;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.Settings.Security;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
using SafeExamBrowser.WindowsApi.Contracts;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
@@ -23,37 +28,45 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
private SessionConfiguration currentSession;
|
||||
private AppSettings currentSettings;
|
||||
private Dependencies dependencies;
|
||||
private SessionConfiguration nextSession;
|
||||
private AppSettings nextSettings;
|
||||
private RuntimeContext context;
|
||||
|
||||
private Mock<IDesktopFactory> desktopFactory;
|
||||
private Mock<IDesktopMonitor> desktopMonitor;
|
||||
private Mock<IExplorerShell> explorerShell;
|
||||
private Mock<ILogger> logger;
|
||||
private SessionConfiguration nextSession;
|
||||
private AppSettings nextSettings;
|
||||
private Mock<IProcessFactory> processFactory;
|
||||
private SessionContext sessionContext;
|
||||
|
||||
private KioskModeOperation sut;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
context = new RuntimeContext();
|
||||
currentSession = new SessionConfiguration();
|
||||
currentSettings = new AppSettings();
|
||||
desktopFactory = new Mock<IDesktopFactory>();
|
||||
desktopMonitor = new Mock<IDesktopMonitor>();
|
||||
explorerShell = new Mock<IExplorerShell>();
|
||||
logger = new Mock<ILogger>();
|
||||
nextSession = new SessionConfiguration();
|
||||
nextSettings = new AppSettings();
|
||||
processFactory = new Mock<IProcessFactory>();
|
||||
sessionContext = new SessionContext();
|
||||
|
||||
currentSession.Settings = currentSettings;
|
||||
nextSession.Settings = nextSettings;
|
||||
sessionContext.Current = currentSession;
|
||||
sessionContext.Next = nextSession;
|
||||
context.Current = currentSession;
|
||||
context.Next = nextSession;
|
||||
|
||||
sut = new KioskModeOperation(desktopFactory.Object, desktopMonitor.Object, explorerShell.Object, logger.Object, processFactory.Object, sessionContext);
|
||||
dependencies = new Dependencies(
|
||||
new ClientBridge(Mock.Of<IRuntimeHost>(), context),
|
||||
Mock.Of<ILogger>(),
|
||||
Mock.Of<IMessageBox>(),
|
||||
Mock.Of<IRuntimeWindow>(),
|
||||
context,
|
||||
Mock.Of<IText>());
|
||||
|
||||
sut = new KioskModeOperation(dependencies, desktopFactory.Object, desktopMonitor.Object, explorerShell.Object, processFactory.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@@ -8,22 +8,26 @@
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Monitoring.Contracts;
|
||||
using SafeExamBrowser.Runtime.Operations;
|
||||
using SafeExamBrowser.Runtime.Operations.Events;
|
||||
using SafeExamBrowser.Runtime.Communication;
|
||||
using SafeExamBrowser.Runtime.Operations.Session;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
[TestClass]
|
||||
public class RemoteSessionOperationTests
|
||||
{
|
||||
private SessionContext context;
|
||||
private RuntimeContext context;
|
||||
private Mock<IRemoteSessionDetector> detector;
|
||||
private Mock<ILogger> logger;
|
||||
private Mock<IMessageBox> messageBox;
|
||||
private AppSettings settings;
|
||||
|
||||
private RemoteSessionOperation sut;
|
||||
@@ -31,14 +35,23 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
context = new SessionContext();
|
||||
context = new RuntimeContext();
|
||||
detector = new Mock<IRemoteSessionDetector>();
|
||||
logger = new Mock<ILogger>();
|
||||
messageBox = new Mock<IMessageBox>();
|
||||
settings = new AppSettings();
|
||||
|
||||
context.Next = new SessionConfiguration();
|
||||
context.Next.Settings = settings;
|
||||
sut = new RemoteSessionOperation(detector.Object, logger.Object, context);
|
||||
|
||||
var dependencies = new Dependencies(
|
||||
new ClientBridge(Mock.Of<IRuntimeHost>(), context),
|
||||
Mock.Of<ILogger>(),
|
||||
messageBox.Object,
|
||||
Mock.Of<IRuntimeWindow>(),
|
||||
context,
|
||||
Mock.Of<IText>());
|
||||
|
||||
sut = new RemoteSessionOperation(dependencies, detector.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -48,13 +61,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
detector.Setup(d => d.IsRemoteSession()).Returns(true);
|
||||
settings.Service.DisableRemoteConnections = true;
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is MessageEventArgs)
|
||||
{
|
||||
messageShown = true;
|
||||
}
|
||||
};
|
||||
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => messageShown = true);
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
@@ -71,13 +81,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
detector.Setup(d => d.IsRemoteSession()).Returns(true);
|
||||
settings.Service.DisableRemoteConnections = false;
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is MessageEventArgs)
|
||||
{
|
||||
messageShown = true;
|
||||
}
|
||||
};
|
||||
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => messageShown = true);
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
@@ -94,13 +101,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
detector.Setup(d => d.IsRemoteSession()).Returns(false);
|
||||
settings.Service.DisableRemoteConnections = true;
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is MessageEventArgs)
|
||||
{
|
||||
messageShown = true;
|
||||
}
|
||||
};
|
||||
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => messageShown = true);
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
@@ -117,13 +121,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
detector.Setup(d => d.IsRemoteSession()).Returns(true);
|
||||
settings.Service.DisableRemoteConnections = true;
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is MessageEventArgs)
|
||||
{
|
||||
messageShown = true;
|
||||
}
|
||||
};
|
||||
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => messageShown = true);
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
@@ -140,13 +141,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
detector.Setup(d => d.IsRemoteSession()).Returns(true);
|
||||
settings.Service.DisableRemoteConnections = false;
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is MessageEventArgs)
|
||||
{
|
||||
messageShown = true;
|
||||
}
|
||||
};
|
||||
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => messageShown = true);
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
@@ -163,13 +161,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
detector.Setup(d => d.IsRemoteSession()).Returns(false);
|
||||
settings.Service.DisableRemoteConnections = true;
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is MessageEventArgs)
|
||||
{
|
||||
messageShown = true;
|
||||
}
|
||||
};
|
||||
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => messageShown = true);
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
@@ -186,13 +181,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
detector.Setup(d => d.IsRemoteSession()).Returns(true);
|
||||
settings.Service.DisableRemoteConnections = false;
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is MessageEventArgs)
|
||||
{
|
||||
messageShown = true;
|
||||
}
|
||||
};
|
||||
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => messageShown = true);
|
||||
|
||||
var result = sut.Revert();
|
||||
|
||||
|
@@ -10,40 +10,45 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Configuration.Contracts.Cryptography;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Runtime.Operations;
|
||||
using SafeExamBrowser.Runtime.Operations.Events;
|
||||
using SafeExamBrowser.Runtime.Communication;
|
||||
using SafeExamBrowser.Runtime.Operations.Session;
|
||||
using SafeExamBrowser.Server.Contracts;
|
||||
using SafeExamBrowser.Server.Contracts.Data;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.Settings.Server;
|
||||
using SafeExamBrowser.SystemComponents.Contracts;
|
||||
using SafeExamBrowser.UserInterface.Contracts;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows.Data;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
[TestClass]
|
||||
public class ServerOperationTests
|
||||
{
|
||||
private SessionContext context;
|
||||
private RuntimeContext context;
|
||||
private Mock<IFileSystem> fileSystem;
|
||||
private Mock<ILogger> logger;
|
||||
private Mock<IConfigurationRepository> repository;
|
||||
private Mock<IServerProxy> server;
|
||||
private Mock<IConfigurationRepository> configuration;
|
||||
private Mock<IUserInterfaceFactory> uiFactory;
|
||||
|
||||
private ServerOperation sut;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
configuration = new Mock<IConfigurationRepository>();
|
||||
context = new SessionContext();
|
||||
context = new RuntimeContext();
|
||||
fileSystem = new Mock<IFileSystem>();
|
||||
logger = new Mock<ILogger>();
|
||||
repository = new Mock<IConfigurationRepository>();
|
||||
server = new Mock<IServerProxy>();
|
||||
uiFactory = new Mock<IUserInterfaceFactory>();
|
||||
|
||||
context.Current = new SessionConfiguration();
|
||||
context.Current.AppConfig = new AppConfig();
|
||||
@@ -52,7 +57,15 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
context.Next.AppConfig = new AppConfig();
|
||||
context.Next.Settings = new AppSettings();
|
||||
|
||||
sut = new ServerOperation(new string[0], configuration.Object, fileSystem.Object, logger.Object, context, server.Object);
|
||||
var dependencies = new Dependencies(
|
||||
new ClientBridge(Mock.Of<IRuntimeHost>(), context),
|
||||
Mock.Of<ILogger>(),
|
||||
Mock.Of<IMessageBox>(),
|
||||
Mock.Of<IRuntimeWindow>(),
|
||||
context,
|
||||
Mock.Of<IText>());
|
||||
|
||||
sut = new ServerOperation(dependencies, fileSystem.Object, repository.Object, server.Object, uiFactory.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -62,6 +75,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var connection = new ConnectionInfo { Api = "some API", ConnectionToken = "some token", Oauth2Token = "some OAuth2 token" };
|
||||
var counter = 0;
|
||||
var delete = 0;
|
||||
var dialog = new Mock<IExamSelectionDialog>();
|
||||
var exam = new Exam { Id = "some id", LmsName = "some LMS", Name = "some name", Url = "some URL" };
|
||||
var examSelection = 0;
|
||||
var examSettings = new AppSettings();
|
||||
@@ -72,7 +86,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var initialSettings = context.Next.Settings;
|
||||
var serverSettings = context.Next.Settings.Server;
|
||||
|
||||
configuration
|
||||
dialog
|
||||
.Setup(d => d.Show(It.IsAny<IWindow>()))
|
||||
.Returns(new ExamSelectionDialogResult { SelectedExam = exam, Success = true })
|
||||
.Callback(() => examSelection = ++counter);
|
||||
repository
|
||||
.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>()))
|
||||
.Returns(LoadStatus.Success);
|
||||
context.Next.Settings.SessionMode = SessionMode.Server;
|
||||
@@ -83,21 +101,13 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
server.Setup(s => s.SendSelectedExam(It.IsAny<Exam>())).Returns(new ServerResponse<string>(true, default));
|
||||
server
|
||||
.Setup(s => s.GetAvailableExams(It.IsAny<string>()))
|
||||
.Returns(new ServerResponse<IEnumerable<Exam>>(true, default(IEnumerable<Exam>)))
|
||||
.Returns(new ServerResponse<IEnumerable<Exam>>(true, default))
|
||||
.Callback(() => getExams = ++counter);
|
||||
server
|
||||
.Setup(s => s.GetConfigurationFor(It.IsAny<Exam>()))
|
||||
.Returns(new ServerResponse<Uri>(true, new Uri("file:///configuration.seb")))
|
||||
.Callback(() => getConfiguration = ++counter);
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is ExamSelectionEventArgs e)
|
||||
{
|
||||
e.Success = true;
|
||||
e.SelectedExam = exam;
|
||||
examSelection = ++counter;
|
||||
}
|
||||
};
|
||||
uiFactory.Setup(f => f.CreateExamSelectionDialog(It.IsAny<IEnumerable<Exam>>())).Returns(dialog.Object);
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
@@ -131,26 +141,21 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
[TestMethod]
|
||||
public void Perform_MustFailIfSettingsCouldNotBeLoaded()
|
||||
{
|
||||
var dialog = new Mock<IExamSelectionDialog>();
|
||||
var connection = new ConnectionInfo { Api = "some API", ConnectionToken = "some token", Oauth2Token = "some OAuth2 token" };
|
||||
var exam = new Exam { Id = "some id", LmsName = "some LMS", Name = "some name", Url = "some URL" };
|
||||
var examSettings = new AppSettings();
|
||||
var initialSettings = context.Next.Settings;
|
||||
|
||||
configuration.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.UnexpectedError);
|
||||
dialog.Setup(d => d.Show(It.IsAny<IWindow>())).Returns(new ExamSelectionDialogResult { SelectedExam = exam, Success = true });
|
||||
repository.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.UnexpectedError);
|
||||
context.Next.Settings.SessionMode = SessionMode.Server;
|
||||
server.Setup(s => s.Connect()).Returns(new ServerResponse(true));
|
||||
server.Setup(s => s.Initialize(It.IsAny<ServerSettings>()));
|
||||
server.Setup(s => s.GetConnectionInfo()).Returns(connection);
|
||||
server.Setup(s => s.GetAvailableExams(It.IsAny<string>())).Returns(new ServerResponse<IEnumerable<Exam>>(true, default(IEnumerable<Exam>)));
|
||||
server.Setup(s => s.GetAvailableExams(It.IsAny<string>())).Returns(new ServerResponse<IEnumerable<Exam>>(true, default));
|
||||
server.Setup(s => s.GetConfigurationFor(It.IsAny<Exam>())).Returns(new ServerResponse<Uri>(true, new Uri("file:///configuration.seb")));
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is ExamSelectionEventArgs e)
|
||||
{
|
||||
e.Success = true;
|
||||
e.SelectedExam = exam;
|
||||
}
|
||||
};
|
||||
uiFactory.Setup(f => f.CreateExamSelectionDialog(It.IsAny<IEnumerable<Exam>>())).Returns(dialog.Object);
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
@@ -177,30 +182,25 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
var connection = new ConnectionInfo { Api = "some API", ConnectionToken = "some token", Oauth2Token = "some OAuth2 token" };
|
||||
var exam = new Exam { Id = "some id", LmsName = "some LMS", Name = "some name", Url = "some URL" };
|
||||
var examDialog = new Mock<IExamSelectionDialog>();
|
||||
var examSettings = new AppSettings();
|
||||
var messageShown = false;
|
||||
var serverDialog = new Mock<IServerFailureDialog>();
|
||||
|
||||
configuration.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
examDialog.Setup(d => d.Show(It.IsAny<IWindow>())).Returns(new ExamSelectionDialogResult { SelectedExam = exam, Success = true });
|
||||
repository.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
context.Next.Settings.SessionMode = SessionMode.Server;
|
||||
server.Setup(s => s.Connect()).Returns(new ServerResponse(true));
|
||||
server.Setup(s => s.Initialize(It.IsAny<ServerSettings>()));
|
||||
server.Setup(s => s.GetConnectionInfo()).Returns(connection);
|
||||
server.Setup(s => s.GetAvailableExams(It.IsAny<string>())).Returns(new ServerResponse<IEnumerable<Exam>>(true, default(IEnumerable<Exam>)));
|
||||
server.Setup(s => s.GetConfigurationFor(It.IsAny<Exam>())).Returns(new ServerResponse<Uri>(false, default(Uri)));
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is ExamSelectionEventArgs e)
|
||||
{
|
||||
e.Success = true;
|
||||
e.SelectedExam = exam;
|
||||
}
|
||||
|
||||
if (args is ServerFailureEventArgs s)
|
||||
{
|
||||
s.Abort = true;
|
||||
messageShown = true;
|
||||
}
|
||||
};
|
||||
server.Setup(s => s.GetAvailableExams(It.IsAny<string>())).Returns(new ServerResponse<IEnumerable<Exam>>(true, default));
|
||||
server.Setup(s => s.GetConfigurationFor(It.IsAny<Exam>())).Returns(new ServerResponse<Uri>(false, default));
|
||||
serverDialog
|
||||
.Setup(d => d.Show(It.IsAny<IWindow>()))
|
||||
.Returns(new ServerFailureDialogResult { Abort = true })
|
||||
.Callback(() => messageShown = true);
|
||||
uiFactory.Setup(f => f.CreateExamSelectionDialog(It.IsAny<IEnumerable<Exam>>())).Returns(examDialog.Object);
|
||||
uiFactory.Setup(f => f.CreateServerFailureDialog(It.IsAny<string>(), It.IsAny<bool>())).Returns(serverDialog.Object);
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
@@ -220,30 +220,25 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
var connection = new ConnectionInfo { Api = "some API", ConnectionToken = "some token", Oauth2Token = "some OAuth2 token" };
|
||||
var exam = new Exam { Id = "some id", LmsName = "some LMS", Name = "some name", Url = "some URL" };
|
||||
var examDialog = new Mock<IExamSelectionDialog>();
|
||||
var examSettings = new AppSettings();
|
||||
var messageShown = false;
|
||||
var serverDialog = new Mock<IServerFailureDialog>();
|
||||
|
||||
configuration.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
examDialog.Setup(d => d.Show(It.IsAny<IWindow>())).Returns(new ExamSelectionDialogResult { SelectedExam = exam, Success = true });
|
||||
repository.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
context.Next.Settings.SessionMode = SessionMode.Server;
|
||||
server.Setup(s => s.Connect()).Returns(new ServerResponse(true));
|
||||
server.Setup(s => s.Initialize(It.IsAny<ServerSettings>()));
|
||||
server.Setup(s => s.GetConnectionInfo()).Returns(connection);
|
||||
server.Setup(s => s.GetAvailableExams(It.IsAny<string>())).Returns(new ServerResponse<IEnumerable<Exam>>(true, default(IEnumerable<Exam>)));
|
||||
server.Setup(s => s.GetConfigurationFor(It.IsAny<Exam>())).Returns(new ServerResponse<Uri>(false, default(Uri)));
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is ExamSelectionEventArgs e)
|
||||
{
|
||||
e.Success = true;
|
||||
e.SelectedExam = exam;
|
||||
}
|
||||
|
||||
if (args is ServerFailureEventArgs s)
|
||||
{
|
||||
s.Fallback = true;
|
||||
messageShown = true;
|
||||
}
|
||||
};
|
||||
server.Setup(s => s.GetAvailableExams(It.IsAny<string>())).Returns(new ServerResponse<IEnumerable<Exam>>(true, default));
|
||||
server.Setup(s => s.GetConfigurationFor(It.IsAny<Exam>())).Returns(new ServerResponse<Uri>(false, default));
|
||||
serverDialog
|
||||
.Setup(d => d.Show(It.IsAny<IWindow>()))
|
||||
.Returns(new ServerFailureDialogResult { Fallback = true })
|
||||
.Callback(() => messageShown = true);
|
||||
uiFactory.Setup(f => f.CreateExamSelectionDialog(It.IsAny<IEnumerable<Exam>>())).Returns(examDialog.Object);
|
||||
uiFactory.Setup(f => f.CreateServerFailureDialog(It.IsAny<string>(), It.IsAny<bool>())).Returns(serverDialog.Object);
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
@@ -266,8 +261,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var exam = new Exam { Id = "some id", LmsName = "some LMS", Name = "some name", Url = "some URL" };
|
||||
var examSettings = new AppSettings();
|
||||
var serverSettings = context.Next.Settings.Server;
|
||||
var examDialog = new Mock<IExamSelectionDialog>();
|
||||
var serverDialog = new Mock<IServerFailureDialog>();
|
||||
|
||||
configuration.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
examDialog.Setup(d => d.Show(It.IsAny<IWindow>())).Callback(Assert.Fail);
|
||||
repository.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
context.Next.Settings.SessionMode = SessionMode.Server;
|
||||
context.Next.Settings.Server.ExamId = "some id";
|
||||
fileSystem.Setup(f => f.Delete(It.IsAny<string>()));
|
||||
@@ -277,7 +275,9 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
server.Setup(s => s.GetAvailableExams(It.IsAny<string>())).Returns(new ServerResponse<IEnumerable<Exam>>(true, new[] { exam }));
|
||||
server.Setup(s => s.GetConfigurationFor(It.IsAny<Exam>())).Returns(new ServerResponse<Uri>(true, new Uri("file:///configuration.seb")));
|
||||
server.Setup(s => s.SendSelectedExam(It.IsAny<Exam>())).Returns(new ServerResponse<string>(true, default));
|
||||
sut.ActionRequired += (args) => Assert.Fail();
|
||||
serverDialog.Setup(d => d.Show(It.IsAny<IWindow>())).Callback(Assert.Fail);
|
||||
uiFactory.Setup(f => f.CreateExamSelectionDialog(It.IsAny<IEnumerable<Exam>>())).Returns(examDialog.Object);
|
||||
uiFactory.Setup(f => f.CreateServerFailureDialog(It.IsAny<string>(), It.IsAny<bool>())).Returns(serverDialog.Object);
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
@@ -298,13 +298,13 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var initialSettings = context.Next.Settings;
|
||||
|
||||
context.Next.Settings.SessionMode = SessionMode.Normal;
|
||||
sut.ActionRequired += (_) => Assert.Fail();
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
configuration.VerifyNoOtherCalls();
|
||||
repository.VerifyNoOtherCalls();
|
||||
fileSystem.VerifyNoOtherCalls();
|
||||
server.VerifyNoOtherCalls();
|
||||
uiFactory.VerifyNoOtherCalls();
|
||||
|
||||
Assert.AreSame(initialSettings, context.Next.Settings);
|
||||
Assert.AreEqual(SessionMode.Normal, context.Next.Settings.SessionMode);
|
||||
@@ -318,6 +318,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var connection = new ConnectionInfo { Api = "some API", ConnectionToken = "some token", Oauth2Token = "some OAuth2 token" };
|
||||
var counter = 0;
|
||||
var delete = 0;
|
||||
var dialog = new Mock<IExamSelectionDialog>();
|
||||
var exam = new Exam { Id = "some id", LmsName = "some LMS", Name = "some name", Url = "some URL" };
|
||||
var examSelection = 0;
|
||||
var examSettings = new AppSettings();
|
||||
@@ -328,7 +329,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var initialSettings = context.Next.Settings;
|
||||
var serverSettings = context.Next.Settings.Server;
|
||||
|
||||
configuration
|
||||
dialog
|
||||
.Setup(d => d.Show(It.IsAny<IWindow>()))
|
||||
.Returns(new ExamSelectionDialogResult { SelectedExam = exam, Success = true })
|
||||
.Callback(() => examSelection = ++counter);
|
||||
repository
|
||||
.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>()))
|
||||
.Returns(LoadStatus.Success);
|
||||
context.Next.Settings.SessionMode = SessionMode.Server;
|
||||
@@ -339,21 +344,13 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
server.Setup(s => s.SendSelectedExam(It.IsAny<Exam>())).Returns(new ServerResponse<string>(true, default));
|
||||
server
|
||||
.Setup(s => s.GetAvailableExams(It.IsAny<string>()))
|
||||
.Returns(new ServerResponse<IEnumerable<Exam>>(true, default(IEnumerable<Exam>)))
|
||||
.Returns(new ServerResponse<IEnumerable<Exam>>(true, default))
|
||||
.Callback(() => getExams = ++counter);
|
||||
server
|
||||
.Setup(s => s.GetConfigurationFor(It.IsAny<Exam>()))
|
||||
.Returns(new ServerResponse<Uri>(true, new Uri("file:///configuration.seb")))
|
||||
.Callback(() => getConfiguration = ++counter);
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is ExamSelectionEventArgs e)
|
||||
{
|
||||
e.Success = true;
|
||||
e.SelectedExam = exam;
|
||||
examSelection = ++counter;
|
||||
}
|
||||
};
|
||||
uiFactory.Setup(f => f.CreateExamSelectionDialog(It.IsAny<IEnumerable<Exam>>())).Returns(dialog.Object);
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
@@ -391,22 +388,17 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var exam = new Exam { Id = "some id", LmsName = "some LMS", Name = "some name", Url = "some URL" };
|
||||
var examSettings = new AppSettings();
|
||||
var initialSettings = context.Next.Settings;
|
||||
var dialog = new Mock<IExamSelectionDialog>();
|
||||
|
||||
configuration.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.UnexpectedError);
|
||||
dialog.Setup(d => d.Show(It.IsAny<IWindow>())).Returns(new ExamSelectionDialogResult { SelectedExam = exam, Success = true });
|
||||
repository.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.UnexpectedError);
|
||||
context.Next.Settings.SessionMode = SessionMode.Server;
|
||||
server.Setup(s => s.Connect()).Returns(new ServerResponse(true));
|
||||
server.Setup(s => s.Initialize(It.IsAny<ServerSettings>()));
|
||||
server.Setup(s => s.GetConnectionInfo()).Returns(connection);
|
||||
server.Setup(s => s.GetAvailableExams(It.IsAny<string>())).Returns(new ServerResponse<IEnumerable<Exam>>(true, default(IEnumerable<Exam>)));
|
||||
server.Setup(s => s.GetAvailableExams(It.IsAny<string>())).Returns(new ServerResponse<IEnumerable<Exam>>(true, default));
|
||||
server.Setup(s => s.GetConfigurationFor(It.IsAny<Exam>())).Returns(new ServerResponse<Uri>(true, new Uri("file:///configuration.seb")));
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is ExamSelectionEventArgs e)
|
||||
{
|
||||
e.Success = true;
|
||||
e.SelectedExam = exam;
|
||||
}
|
||||
};
|
||||
uiFactory.Setup(f => f.CreateExamSelectionDialog(It.IsAny<IEnumerable<Exam>>())).Returns(dialog.Object);
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
@@ -435,28 +427,25 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var exam = new Exam { Id = "some id", LmsName = "some LMS", Name = "some name", Url = "some URL" };
|
||||
var examSettings = new AppSettings();
|
||||
var messageShown = false;
|
||||
var examDialog = new Mock<IExamSelectionDialog>();
|
||||
var serverDialog = new Mock<IServerFailureDialog>();
|
||||
|
||||
configuration.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
examDialog
|
||||
.Setup(d => d.Show(It.IsAny<IWindow>()))
|
||||
.Returns(new ExamSelectionDialogResult { SelectedExam = exam, Success = true });
|
||||
repository.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
context.Next.Settings.SessionMode = SessionMode.Server;
|
||||
server.Setup(s => s.Connect()).Returns(new ServerResponse(true));
|
||||
server.Setup(s => s.Initialize(It.IsAny<ServerSettings>()));
|
||||
server.Setup(s => s.GetConnectionInfo()).Returns(connection);
|
||||
server.Setup(s => s.GetAvailableExams(It.IsAny<string>())).Returns(new ServerResponse<IEnumerable<Exam>>(true, default(IEnumerable<Exam>)));
|
||||
server.Setup(s => s.GetConfigurationFor(It.IsAny<Exam>())).Returns(new ServerResponse<Uri>(false, default(Uri)));
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is ExamSelectionEventArgs e)
|
||||
{
|
||||
e.Success = true;
|
||||
e.SelectedExam = exam;
|
||||
}
|
||||
|
||||
if (args is ServerFailureEventArgs s)
|
||||
{
|
||||
s.Abort = true;
|
||||
messageShown = true;
|
||||
}
|
||||
};
|
||||
server.Setup(s => s.GetAvailableExams(It.IsAny<string>())).Returns(new ServerResponse<IEnumerable<Exam>>(true, default));
|
||||
server.Setup(s => s.GetConfigurationFor(It.IsAny<Exam>())).Returns(new ServerResponse<Uri>(false, default));
|
||||
serverDialog
|
||||
.Setup(d => d.Show(It.IsAny<IWindow>()))
|
||||
.Returns(new ServerFailureDialogResult { Abort = true })
|
||||
.Callback(() => messageShown = true);
|
||||
uiFactory.Setup(f => f.CreateExamSelectionDialog(It.IsAny<IEnumerable<Exam>>())).Returns(examDialog.Object);
|
||||
uiFactory.Setup(f => f.CreateServerFailureDialog(It.IsAny<string>(), It.IsAny<bool>())).Returns(serverDialog.Object);
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
@@ -478,28 +467,23 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var exam = new Exam { Id = "some id", LmsName = "some LMS", Name = "some name", Url = "some URL" };
|
||||
var examSettings = new AppSettings();
|
||||
var messageShown = false;
|
||||
var examDialog = new Mock<IExamSelectionDialog>();
|
||||
var serverDialog = new Mock<IServerFailureDialog>();
|
||||
|
||||
configuration.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
examDialog.Setup(d => d.Show(It.IsAny<IWindow>())).Returns(new ExamSelectionDialogResult { SelectedExam = exam, Success = true });
|
||||
repository.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
context.Next.Settings.SessionMode = SessionMode.Server;
|
||||
server.Setup(s => s.Connect()).Returns(new ServerResponse(true));
|
||||
server.Setup(s => s.Initialize(It.IsAny<ServerSettings>()));
|
||||
server.Setup(s => s.GetConnectionInfo()).Returns(connection);
|
||||
server.Setup(s => s.GetAvailableExams(It.IsAny<string>())).Returns(new ServerResponse<IEnumerable<Exam>>(true, default(IEnumerable<Exam>)));
|
||||
server.Setup(s => s.GetConfigurationFor(It.IsAny<Exam>())).Returns(new ServerResponse<Uri>(false, default(Uri)));
|
||||
sut.ActionRequired += (args) =>
|
||||
{
|
||||
if (args is ExamSelectionEventArgs e)
|
||||
{
|
||||
e.Success = true;
|
||||
e.SelectedExam = exam;
|
||||
}
|
||||
|
||||
if (args is ServerFailureEventArgs s)
|
||||
{
|
||||
s.Fallback = true;
|
||||
messageShown = true;
|
||||
}
|
||||
};
|
||||
server.Setup(s => s.GetAvailableExams(It.IsAny<string>())).Returns(new ServerResponse<IEnumerable<Exam>>(true, default));
|
||||
server.Setup(s => s.GetConfigurationFor(It.IsAny<Exam>())).Returns(new ServerResponse<Uri>(false, default));
|
||||
serverDialog
|
||||
.Setup(d => d.Show(It.IsAny<IWindow>()))
|
||||
.Returns(new ServerFailureDialogResult { Fallback = true })
|
||||
.Callback(() => messageShown = true);
|
||||
uiFactory.Setup(f => f.CreateExamSelectionDialog(It.IsAny<IEnumerable<Exam>>())).Returns(examDialog.Object);
|
||||
uiFactory.Setup(f => f.CreateServerFailureDialog(It.IsAny<string>(), It.IsAny<bool>())).Returns(serverDialog.Object);
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
@@ -515,6 +499,83 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Repeat_MustCorrectlyReconfigureServerSession()
|
||||
{
|
||||
var connect = 0;
|
||||
var connection = new ConnectionInfo { Api = "some API", ConnectionToken = "some token", Oauth2Token = "some OAuth2 token" };
|
||||
var counter = 0;
|
||||
var delete = 0;
|
||||
var dialog = new Mock<IExamSelectionDialog>();
|
||||
var disconnect = 0;
|
||||
var exam = new Exam { Id = "some id", LmsName = "some LMS", Name = "some name", Url = "some URL" };
|
||||
var examSelection = 0;
|
||||
var examSettings = new AppSettings();
|
||||
var getConfiguration = 0;
|
||||
var getConnection = 0;
|
||||
var getExams = 0;
|
||||
var initialize = 0;
|
||||
var initialSettings = context.Next.Settings;
|
||||
var serverSettings = context.Next.Settings.Server;
|
||||
|
||||
dialog
|
||||
.Setup(d => d.Show(It.IsAny<IWindow>()))
|
||||
.Returns(new ExamSelectionDialogResult { SelectedExam = exam, Success = true })
|
||||
.Callback(() => examSelection = ++counter);
|
||||
repository
|
||||
.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>()))
|
||||
.Returns(LoadStatus.Success);
|
||||
context.Current.Settings.SessionMode = SessionMode.Server;
|
||||
context.Next.Settings.SessionMode = SessionMode.Server;
|
||||
fileSystem.Setup(f => f.Delete(It.IsAny<string>())).Callback(() => delete = ++counter);
|
||||
server.Setup(s => s.Connect()).Returns(new ServerResponse(true)).Callback(() => connect = ++counter);
|
||||
server.Setup(s => s.Disconnect()).Returns(new ServerResponse(true)).Callback(() => disconnect = ++counter);
|
||||
server.Setup(s => s.Initialize(It.IsAny<ServerSettings>())).Callback(() => initialize = ++counter);
|
||||
server.Setup(s => s.GetConnectionInfo()).Returns(connection).Callback(() => getConnection = ++counter);
|
||||
server.Setup(s => s.SendSelectedExam(It.IsAny<Exam>())).Returns(new ServerResponse<string>(true, default));
|
||||
server
|
||||
.Setup(s => s.GetAvailableExams(It.IsAny<string>()))
|
||||
.Returns(new ServerResponse<IEnumerable<Exam>>(true, default))
|
||||
.Callback(() => getExams = ++counter);
|
||||
server
|
||||
.Setup(s => s.GetConfigurationFor(It.IsAny<Exam>()))
|
||||
.Returns(new ServerResponse<Uri>(true, new Uri("file:///configuration.seb")))
|
||||
.Callback(() => getConfiguration = ++counter);
|
||||
uiFactory.Setup(f => f.CreateExamSelectionDialog(It.IsAny<IEnumerable<Exam>>())).Returns(dialog.Object);
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
|
||||
fileSystem.Verify(f => f.Delete(It.IsAny<string>()), Times.Once);
|
||||
server.Verify(s => s.Connect(), Times.Once);
|
||||
server.Verify(s => s.Disconnect(), Times.Once);
|
||||
server.Verify(s => s.Initialize(It.IsAny<ServerSettings>()), Times.Once);
|
||||
server.Verify(s => s.GetAvailableExams(It.IsAny<string>()), Times.Once);
|
||||
server.Verify(s => s.GetConfigurationFor(It.Is<Exam>(e => e == exam)), Times.Once);
|
||||
server.Verify(s => s.GetConnectionInfo(), Times.Once);
|
||||
server.Verify(s => s.SendSelectedExam(It.Is<Exam>(e => e == exam)), Times.Once);
|
||||
|
||||
Assert.AreEqual(1, disconnect);
|
||||
Assert.AreEqual(2, initialize);
|
||||
Assert.AreEqual(3, connect);
|
||||
Assert.AreEqual(4, getExams);
|
||||
Assert.AreEqual(5, examSelection);
|
||||
Assert.AreEqual(6, getConfiguration);
|
||||
Assert.AreEqual(7, getConnection);
|
||||
Assert.AreEqual(8, delete);
|
||||
Assert.AreEqual(connection.Api, context.Next.AppConfig.ServerApi);
|
||||
Assert.AreEqual(connection.ConnectionToken, context.Next.AppConfig.ServerConnectionToken);
|
||||
Assert.AreEqual(connection.Oauth2Token, context.Next.AppConfig.ServerOauth2Token);
|
||||
Assert.AreEqual(exam.Id, context.Next.AppConfig.ServerExamId);
|
||||
Assert.AreEqual(exam.Url, context.Next.Settings.Browser.StartUrl);
|
||||
Assert.AreSame(examSettings, context.Next.Settings);
|
||||
Assert.AreSame(serverSettings, context.Next.Settings.Server);
|
||||
Assert.AreNotSame(initialSettings, context.Next.Settings);
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
Assert.AreEqual(SessionMode.Server, context.Next.Settings.SessionMode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Repeat_MustAutomaticallySelectExam()
|
||||
{
|
||||
@@ -522,8 +583,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var exam = new Exam { Id = "some id", LmsName = "some LMS", Name = "some name", Url = "some URL" };
|
||||
var examSettings = new AppSettings();
|
||||
var serverSettings = context.Next.Settings.Server;
|
||||
var dialog = new Mock<IExamSelectionDialog>();
|
||||
|
||||
configuration.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
dialog.Setup(d => d.Show(It.IsAny<IWindow>())).Callback(Assert.Fail);
|
||||
repository.Setup(c => c.TryLoadSettings(It.IsAny<Uri>(), out examSettings, It.IsAny<PasswordParameters>())).Returns(LoadStatus.Success);
|
||||
context.Next.Settings.SessionMode = SessionMode.Server;
|
||||
context.Next.Settings.Server.ExamId = "some id";
|
||||
fileSystem.Setup(f => f.Delete(It.IsAny<string>()));
|
||||
@@ -533,7 +596,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
server.Setup(s => s.GetAvailableExams(It.IsAny<string>())).Returns(new ServerResponse<IEnumerable<Exam>>(true, new[] { exam }));
|
||||
server.Setup(s => s.GetConfigurationFor(It.IsAny<Exam>())).Returns(new ServerResponse<Uri>(true, new Uri("file:///configuration.seb")));
|
||||
server.Setup(s => s.SendSelectedExam(It.IsAny<Exam>())).Returns(new ServerResponse<string>(true, default));
|
||||
sut.ActionRequired += (args) => Assert.Fail();
|
||||
uiFactory.Setup(f => f.CreateExamSelectionDialog(It.IsAny<IEnumerable<Exam>>())).Returns(dialog.Object);
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
@@ -548,36 +611,6 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Repeat_MustNotAllowToReconfigureServerSession()
|
||||
{
|
||||
var args = default(ActionRequiredEventArgs);
|
||||
|
||||
context.Current.AppConfig.ServerApi = "api";
|
||||
context.Current.AppConfig.ServerConnectionToken = "token";
|
||||
context.Current.AppConfig.ServerExamId = "id";
|
||||
context.Current.AppConfig.ServerOauth2Token = "oauth2";
|
||||
context.Current.Settings.SessionMode = SessionMode.Server;
|
||||
context.Next.Settings.SessionMode = SessionMode.Server;
|
||||
|
||||
sut.ActionRequired += (a) =>
|
||||
{
|
||||
args = a;
|
||||
};
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
configuration.VerifyNoOtherCalls();
|
||||
fileSystem.VerifyNoOtherCalls();
|
||||
server.VerifyNoOtherCalls();
|
||||
|
||||
Assert.IsNull(context.Next.AppConfig.ServerApi);
|
||||
Assert.IsNull(context.Next.AppConfig.ServerConnectionToken);
|
||||
Assert.IsNull(context.Next.AppConfig.ServerOauth2Token);
|
||||
Assert.IsInstanceOfType(args, typeof(MessageEventArgs));
|
||||
Assert.AreEqual(OperationResult.Aborted, result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Repeat_MustDoNothingIfNormalSession()
|
||||
{
|
||||
@@ -585,13 +618,13 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
context.Current.Settings.SessionMode = SessionMode.Normal;
|
||||
context.Next.Settings.SessionMode = SessionMode.Normal;
|
||||
sut.ActionRequired += (_) => Assert.Fail();
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
configuration.VerifyNoOtherCalls();
|
||||
repository.VerifyNoOtherCalls();
|
||||
fileSystem.VerifyNoOtherCalls();
|
||||
server.VerifyNoOtherCalls();
|
||||
uiFactory.VerifyNoOtherCalls();
|
||||
|
||||
Assert.AreSame(initialSettings, context.Next.Settings);
|
||||
Assert.AreEqual(SessionMode.Normal, context.Next.Settings.SessionMode);
|
||||
@@ -646,13 +679,13 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
public void Revert_MustDoNothingIfNormalSession()
|
||||
{
|
||||
context.Current.Settings.SessionMode = SessionMode.Normal;
|
||||
sut.ActionRequired += (_) => Assert.Fail();
|
||||
|
||||
var result = sut.Revert();
|
||||
|
||||
configuration.VerifyNoOtherCalls();
|
||||
repository.VerifyNoOtherCalls();
|
||||
fileSystem.VerifyNoOtherCalls();
|
||||
server.VerifyNoOtherCalls();
|
||||
uiFactory.VerifyNoOtherCalls();
|
||||
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
}
|
||||
|
@@ -14,25 +14,29 @@ using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||
using SafeExamBrowser.Communication.Contracts.Proxies;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Runtime.Operations;
|
||||
using SafeExamBrowser.Runtime.Operations.Events;
|
||||
using SafeExamBrowser.Runtime.Communication;
|
||||
using SafeExamBrowser.Runtime.Operations.Session;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.Settings.Service;
|
||||
using SafeExamBrowser.SystemComponents.Contracts;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
[TestClass]
|
||||
public class ServiceOperationTests
|
||||
{
|
||||
private SessionContext context;
|
||||
private Mock<ILogger> logger;
|
||||
private RuntimeContext context;
|
||||
private Dependencies dependencies;
|
||||
private Mock<IMessageBox> messageBox;
|
||||
private Mock<IRuntimeHost> runtimeHost;
|
||||
private Mock<IServiceProxy> service;
|
||||
private EventWaitHandle serviceEvent;
|
||||
private Mock<IUserInfo> userInfo;
|
||||
|
||||
private ServiceOperation sut;
|
||||
|
||||
[TestInitialize]
|
||||
@@ -40,11 +44,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
var serviceEventName = $"{nameof(SafeExamBrowser)}-{nameof(ServiceOperationTests)}";
|
||||
|
||||
logger = new Mock<ILogger>();
|
||||
context = new RuntimeContext();
|
||||
messageBox = new Mock<IMessageBox>();
|
||||
runtimeHost = new Mock<IRuntimeHost>();
|
||||
service = new Mock<IServiceProxy>();
|
||||
serviceEvent = new EventWaitHandle(false, EventResetMode.AutoReset, serviceEventName);
|
||||
context = new SessionContext();
|
||||
userInfo = new Mock<IUserInfo>();
|
||||
|
||||
context.Current = new SessionConfiguration();
|
||||
@@ -56,7 +60,15 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
context.Next.AppConfig.ServiceEventName = serviceEventName;
|
||||
context.Next.Settings = new AppSettings();
|
||||
|
||||
sut = new ServiceOperation(logger.Object, runtimeHost.Object, service.Object, context, 0, userInfo.Object);
|
||||
dependencies = new Dependencies(
|
||||
new ClientBridge(Mock.Of<IRuntimeHost>(), context),
|
||||
Mock.Of<ILogger>(),
|
||||
messageBox.Object,
|
||||
Mock.Of<IRuntimeWindow>(),
|
||||
context,
|
||||
Mock.Of<IText>());
|
||||
|
||||
sut = new ServiceOperation(dependencies, runtimeHost.Object, service.Object, 0, userInfo.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -137,7 +149,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
service.Setup(s => s.Connect(null, true)).Returns(true);
|
||||
service.Setup(s => s.StartSession(It.IsAny<ServiceConfiguration>())).Returns(new CommunicationResult(true));
|
||||
|
||||
sut = new ServiceOperation(logger.Object, runtimeHost.Object, service.Object, context, TIMEOUT, userInfo.Object);
|
||||
sut = new ServiceOperation(dependencies, runtimeHost.Object, service.Object, TIMEOUT, userInfo.Object);
|
||||
|
||||
before = DateTime.Now;
|
||||
var result = sut.Perform();
|
||||
@@ -183,9 +195,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var errorShown = false;
|
||||
|
||||
context.Next.Settings.Service.Policy = ServicePolicy.Mandatory;
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => errorShown = true);
|
||||
service.SetupGet(s => s.IsConnected).Returns(false);
|
||||
service.Setup(s => s.Connect(null, true)).Returns(false);
|
||||
sut.ActionRequired += (args) => errorShown = args is MessageEventArgs m && m.Icon == MessageBoxIcon.Error;
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
@@ -213,9 +227,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var warningShown = false;
|
||||
|
||||
context.Next.Settings.Service.Policy = ServicePolicy.Warn;
|
||||
messageBox
|
||||
.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()))
|
||||
.Callback(() => warningShown = true);
|
||||
service.SetupGet(s => s.IsConnected).Returns(false);
|
||||
service.Setup(s => s.Connect(null, true)).Returns(false);
|
||||
sut.ActionRequired += (args) => warningShown = args is MessageEventArgs m && m.Icon == MessageBoxIcon.Warning;
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
@@ -264,9 +280,9 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
service.Verify(s => s.RunSystemConfigurationUpdate(), Times.Never);
|
||||
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
Assert.IsTrue(start1 == 1);
|
||||
Assert.IsTrue(stop1 == 2);
|
||||
Assert.IsTrue(start2 == 3);
|
||||
Assert.AreEqual(1, start1);
|
||||
Assert.AreEqual(2, stop1);
|
||||
Assert.AreEqual(3, start2);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -358,7 +374,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var before = default(DateTime);
|
||||
|
||||
service.Setup(s => s.StopSession(It.IsAny<Guid>())).Returns(new CommunicationResult(true));
|
||||
sut = new ServiceOperation(logger.Object, runtimeHost.Object, service.Object, context, TIMEOUT, userInfo.Object);
|
||||
sut = new ServiceOperation(dependencies, runtimeHost.Object, service.Object, TIMEOUT, userInfo.Object);
|
||||
|
||||
PerformNormally();
|
||||
|
||||
@@ -458,7 +474,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var before = default(DateTime);
|
||||
|
||||
service.Setup(s => s.StopSession(It.IsAny<Guid>())).Returns(new CommunicationResult(true));
|
||||
sut = new ServiceOperation(logger.Object, runtimeHost.Object, service.Object, context, TIMEOUT, userInfo.Object);
|
||||
sut = new ServiceOperation(dependencies, runtimeHost.Object, service.Object, TIMEOUT, userInfo.Object);
|
||||
|
||||
PerformNormally();
|
||||
|
||||
@@ -537,8 +553,8 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
PerformNormally();
|
||||
|
||||
context.Current.SessionId = default(Guid);
|
||||
context.Next.SessionId = default(Guid);
|
||||
context.Current.SessionId = default;
|
||||
context.Next.SessionId = default;
|
||||
service.Setup(s => s.StopSession(It.Is<Guid>(id => id == sessionId))).Returns(new CommunicationResult(true)).Callback(() => serviceEvent.Set());
|
||||
service.Setup(s => s.RunSystemConfigurationUpdate()).Returns(new CommunicationResult(true));
|
||||
service.Setup(s => s.Disconnect()).Returns(true);
|
||||
@@ -546,7 +562,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var result = sut.Revert();
|
||||
|
||||
service.Verify(s => s.StopSession(It.Is<Guid>(id => id == sessionId)), Times.Once);
|
||||
service.Verify(s => s.StopSession(It.Is<Guid>(id => id == default(Guid))), Times.Never);
|
||||
service.Verify(s => s.StopSession(It.Is<Guid>(id => id == default)), Times.Never);
|
||||
service.Verify(s => s.Disconnect(), Times.Once);
|
||||
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
|
@@ -8,12 +8,17 @@
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Runtime.Operations;
|
||||
using SafeExamBrowser.Runtime.Communication;
|
||||
using SafeExamBrowser.Runtime.Operations.Session;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.Settings.Logging;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
@@ -24,8 +29,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
private Mock<ILogger> logger;
|
||||
private SessionConfiguration nextSession;
|
||||
private AppSettings nextSettings;
|
||||
private SessionContext sessionContext;
|
||||
|
||||
private RuntimeContext runtimeContext;
|
||||
private SessionActivationOperation sut;
|
||||
|
||||
[TestInitialize]
|
||||
@@ -35,25 +39,33 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
logger = new Mock<ILogger>();
|
||||
nextSession = new SessionConfiguration();
|
||||
nextSettings = new AppSettings();
|
||||
sessionContext = new SessionContext();
|
||||
runtimeContext = new RuntimeContext();
|
||||
|
||||
nextSession.Settings = nextSettings;
|
||||
sessionContext.Current = currentSession;
|
||||
sessionContext.Next = nextSession;
|
||||
runtimeContext.Current = currentSession;
|
||||
runtimeContext.Next = nextSession;
|
||||
|
||||
sut = new SessionActivationOperation(logger.Object, sessionContext);
|
||||
var dependencies = new Dependencies(
|
||||
new ClientBridge(Mock.Of<IRuntimeHost>(), runtimeContext),
|
||||
logger.Object,
|
||||
Mock.Of<IMessageBox>(),
|
||||
Mock.Of<IRuntimeWindow>(),
|
||||
runtimeContext,
|
||||
Mock.Of<IText>());
|
||||
|
||||
sut = new SessionActivationOperation(dependencies);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Perform_MustCorrectlyActivateFirstSession()
|
||||
{
|
||||
sessionContext.Current = null;
|
||||
runtimeContext.Current = null;
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
Assert.AreSame(sessionContext.Current, nextSession);
|
||||
Assert.IsNull(sessionContext.Next);
|
||||
Assert.AreSame(runtimeContext.Current, nextSession);
|
||||
Assert.IsNull(runtimeContext.Next);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -72,8 +84,8 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
var result = sut.Repeat();
|
||||
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
Assert.AreSame(sessionContext.Current, nextSession);
|
||||
Assert.IsNull(sessionContext.Next);
|
||||
Assert.AreSame(runtimeContext.Current, nextSession);
|
||||
Assert.IsNull(runtimeContext.Next);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@@ -12,9 +12,13 @@ using Moq;
|
||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Runtime.Operations;
|
||||
using SafeExamBrowser.Runtime.Communication;
|
||||
using SafeExamBrowser.Runtime.Operations.Session;
|
||||
using SafeExamBrowser.SystemComponents.Contracts;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
@@ -22,12 +26,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
public class SessionInitializationOperationTests
|
||||
{
|
||||
private AppConfig appConfig;
|
||||
private Mock<IConfigurationRepository> configuration;
|
||||
private RuntimeContext context;
|
||||
private Mock<IFileSystem> fileSystem;
|
||||
private Mock<ILogger> logger;
|
||||
private Mock<IRuntimeHost> runtimeHost;
|
||||
private Mock<IConfigurationRepository> repository;
|
||||
private SessionConfiguration session;
|
||||
private SessionContext sessionContext;
|
||||
|
||||
private SessionInitializationOperation sut;
|
||||
|
||||
@@ -35,18 +38,25 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
public void Initialize()
|
||||
{
|
||||
appConfig = new AppConfig();
|
||||
configuration = new Mock<IConfigurationRepository>();
|
||||
context = new RuntimeContext();
|
||||
repository = new Mock<IConfigurationRepository>();
|
||||
fileSystem = new Mock<IFileSystem>();
|
||||
logger = new Mock<ILogger>();
|
||||
runtimeHost = new Mock<IRuntimeHost>();
|
||||
session = new SessionConfiguration();
|
||||
sessionContext = new SessionContext();
|
||||
|
||||
configuration.Setup(c => c.InitializeSessionConfiguration()).Returns(session);
|
||||
context.Next = session;
|
||||
repository.Setup(c => c.InitializeSessionConfiguration()).Returns(session);
|
||||
session.AppConfig = appConfig;
|
||||
sessionContext.Next = session;
|
||||
|
||||
sut = new SessionInitializationOperation(configuration.Object, fileSystem.Object, logger.Object, runtimeHost.Object, sessionContext);
|
||||
var dependencies = new Dependencies(
|
||||
new ClientBridge(Mock.Of<IRuntimeHost>(), context),
|
||||
logger.Object,
|
||||
Mock.Of<IMessageBox>(),
|
||||
Mock.Of<IRuntimeWindow>(),
|
||||
context,
|
||||
Mock.Of<IText>());
|
||||
|
||||
sut = new SessionInitializationOperation(dependencies, fileSystem.Object, repository.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -59,11 +69,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
var result = sut.Perform();
|
||||
|
||||
configuration.Verify(c => c.InitializeSessionConfiguration(), Times.Once);
|
||||
repository.Verify(c => c.InitializeSessionConfiguration(), Times.Once);
|
||||
fileSystem.Verify(f => f.CreateDirectory(It.Is<string>(s => s == appConfig.TemporaryDirectory)), Times.Once);
|
||||
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
Assert.IsNull(sessionContext.Current);
|
||||
Assert.IsNull(context.Current);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -74,15 +84,15 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
|
||||
appConfig.TemporaryDirectory = @"C:\Some\Random\Path";
|
||||
session.ClientAuthenticationToken = token;
|
||||
sessionContext.Current = currentSession;
|
||||
context.Current = currentSession;
|
||||
|
||||
var result = sut.Repeat();
|
||||
|
||||
configuration.Verify(c => c.InitializeSessionConfiguration(), Times.Once);
|
||||
repository.Verify(c => c.InitializeSessionConfiguration(), Times.Once);
|
||||
fileSystem.Verify(f => f.CreateDirectory(It.Is<string>(s => s == appConfig.TemporaryDirectory)), Times.Once);
|
||||
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
Assert.AreSame(currentSession,sessionContext.Current);
|
||||
Assert.AreSame(currentSession, context.Current);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -90,10 +100,9 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
var result = sut.Revert();
|
||||
|
||||
configuration.VerifyNoOtherCalls();
|
||||
repository.VerifyNoOtherCalls();
|
||||
fileSystem.VerifyNoOtherCalls();
|
||||
logger.VerifyNoOtherCalls();
|
||||
runtimeHost.VerifyNoOtherCalls();
|
||||
|
||||
Assert.AreEqual(OperationResult.Success, result);
|
||||
}
|
||||
|
@@ -8,35 +8,49 @@
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Monitoring.Contracts;
|
||||
using SafeExamBrowser.Runtime.Operations;
|
||||
using SafeExamBrowser.Runtime.Communication;
|
||||
using SafeExamBrowser.Runtime.Operations.Session;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.Settings.Security;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
[TestClass]
|
||||
public class VirtualMachineOperationTests
|
||||
{
|
||||
private RuntimeContext context;
|
||||
private Mock<IVirtualMachineDetector> detector;
|
||||
private Mock<ILogger> logger;
|
||||
private SessionContext context;
|
||||
|
||||
private VirtualMachineOperation sut;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
context = new RuntimeContext();
|
||||
detector = new Mock<IVirtualMachineDetector>();
|
||||
logger = new Mock<ILogger>();
|
||||
context = new SessionContext();
|
||||
|
||||
context.Next = new SessionConfiguration();
|
||||
context.Next.Settings = new AppSettings();
|
||||
|
||||
sut = new VirtualMachineOperation(detector.Object, logger.Object, context);
|
||||
var dependencies = new Dependencies(
|
||||
new ClientBridge(Mock.Of<IRuntimeHost>(), context),
|
||||
logger.Object,
|
||||
Mock.Of<IMessageBox>(),
|
||||
Mock.Of<IRuntimeWindow>(),
|
||||
context,
|
||||
Mock.Of<IText>());
|
||||
|
||||
sut = new VirtualMachineOperation(dependencies, detector.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2025 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using SafeExamBrowser.Communication.Contracts.Proxies;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Runtime.Responsibilities;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
using SafeExamBrowser.WindowsApi.Contracts;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Responsibilities
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientResponsibilityTests
|
||||
{
|
||||
private Mock<IRuntimeWindow> runtimeWindow;
|
||||
private Mock<ILogger> logger;
|
||||
private Mock<IMessageBox> messageBox;
|
||||
private RuntimeContext context;
|
||||
private Mock<Action> shutdown;
|
||||
private Mock<IProcess> clientProcess;
|
||||
private Mock<IClientProxy> clientProxy;
|
||||
|
||||
private ClientResponsibility sut;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
clientProcess = new Mock<IProcess>();
|
||||
clientProxy = new Mock<IClientProxy>();
|
||||
context = new RuntimeContext();
|
||||
logger = new Mock<ILogger>();
|
||||
messageBox = new Mock<IMessageBox>();
|
||||
runtimeWindow = new Mock<IRuntimeWindow>();
|
||||
shutdown = new Mock<Action>();
|
||||
|
||||
context.ClientProcess = clientProcess.Object;
|
||||
context.ClientProxy = clientProxy.Object;
|
||||
|
||||
sut = new ClientResponsibility(logger.Object, messageBox.Object, context, runtimeWindow.Object, shutdown.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClientProcess_MustShutdownWhenClientTerminated()
|
||||
{
|
||||
sut.Assume(RuntimeTask.RegisterSessionEvents);
|
||||
clientProcess.Raise(c => c.Terminated += null, -1);
|
||||
|
||||
messageBox.Verify(m => m.Show(
|
||||
It.IsAny<TextKey>(),
|
||||
It.IsAny<TextKey>(),
|
||||
It.IsAny<MessageBoxAction>(),
|
||||
It.Is<MessageBoxIcon>(i => i == MessageBoxIcon.Error),
|
||||
It.IsAny<IWindow>()), Times.Once);
|
||||
shutdown.Verify(s => s(), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClientProxy_MustShutdownWhenConnectionLost()
|
||||
{
|
||||
sut.Assume(RuntimeTask.RegisterSessionEvents);
|
||||
clientProxy.Raise(c => c.ConnectionLost += null);
|
||||
|
||||
messageBox.Verify(m => m.Show(
|
||||
It.IsAny<TextKey>(),
|
||||
It.IsAny<TextKey>(),
|
||||
It.IsAny<MessageBoxAction>(),
|
||||
It.Is<MessageBoxIcon>(i => i == MessageBoxIcon.Error),
|
||||
It.IsAny<IWindow>()), Times.Once);
|
||||
shutdown.Verify(s => s(), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 2025 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using SafeExamBrowser.Communication.Contracts.Events;
|
||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||
using SafeExamBrowser.Communication.Contracts.Proxies;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Core.Contracts.ResponsibilityModel;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Runtime.Responsibilities;
|
||||
using SafeExamBrowser.Settings;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Responsibilities
|
||||
{
|
||||
[TestClass]
|
||||
public class CommunicationResponsibilityTests
|
||||
{
|
||||
private Mock<IClientProxy> clientProxy;
|
||||
private RuntimeContext context;
|
||||
private SessionConfiguration currentSession;
|
||||
private AppSettings currentSettings;
|
||||
private Mock<ILogger> logger;
|
||||
private Mock<IResponsibilityCollection<RuntimeTask>> responsibilities;
|
||||
private SessionConfiguration nextSession;
|
||||
private AppSettings nextSettings;
|
||||
private Mock<IRuntimeHost> runtimeHost;
|
||||
private Mock<Action> shutdown;
|
||||
|
||||
private CommunicationResponsibility sut;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
clientProxy = new Mock<IClientProxy>();
|
||||
context = new RuntimeContext();
|
||||
logger = new Mock<ILogger>();
|
||||
responsibilities = new Mock<IResponsibilityCollection<RuntimeTask>>();
|
||||
runtimeHost = new Mock<IRuntimeHost>();
|
||||
shutdown = new Mock<Action>();
|
||||
|
||||
currentSession = new SessionConfiguration();
|
||||
currentSettings = new AppSettings();
|
||||
nextSession = new SessionConfiguration();
|
||||
nextSettings = new AppSettings();
|
||||
|
||||
currentSession.Settings = currentSettings;
|
||||
nextSession.Settings = nextSettings;
|
||||
|
||||
context.ClientProxy = clientProxy.Object;
|
||||
context.Current = currentSession;
|
||||
context.Next = nextSession;
|
||||
context.Responsibilities = responsibilities.Object;
|
||||
|
||||
sut = new CommunicationResponsibility(logger.Object, context, runtimeHost.Object, shutdown.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Communication_MustProvideClientConfigurationUponRequest()
|
||||
{
|
||||
var args = new ClientConfigurationEventArgs();
|
||||
var nextAppConfig = new AppConfig();
|
||||
var nextSessionId = Guid.NewGuid();
|
||||
var nextSettings = new AppSettings();
|
||||
|
||||
nextSession.AppConfig = nextAppConfig;
|
||||
nextSession.SessionId = nextSessionId;
|
||||
nextSession.Settings = nextSettings;
|
||||
|
||||
sut.Assume(RuntimeTask.RegisterEvents);
|
||||
runtimeHost.Raise(r => r.ClientConfigurationNeeded += null, args);
|
||||
|
||||
Assert.AreSame(nextAppConfig, args.ClientConfiguration.AppConfig);
|
||||
Assert.AreEqual(nextSessionId, args.ClientConfiguration.SessionId);
|
||||
Assert.AreSame(nextSettings, args.ClientConfiguration.Settings);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Communication_MustStartNewSessionUponRequest()
|
||||
{
|
||||
var args = new ReconfigurationEventArgs { ConfigurationPath = "C:\\Some\\File\\Path.seb" };
|
||||
|
||||
sut.Assume(RuntimeTask.RegisterEvents);
|
||||
runtimeHost.Raise(r => r.ReconfigurationRequested += null, args);
|
||||
|
||||
responsibilities.Verify(r => r.Delegate(RuntimeTask.StartSession));
|
||||
Assert.AreEqual(context.ReconfigurationFilePath, args.ConfigurationPath);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Communication_MustShutdownUponRequest()
|
||||
{
|
||||
sut.Assume(RuntimeTask.RegisterEvents);
|
||||
runtimeHost.Raise(r => r.ShutdownRequested += null);
|
||||
shutdown.Verify(s => s(), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2025 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using SafeExamBrowser.Communication.Contracts.Proxies;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Core.Contracts.ResponsibilityModel;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Runtime.Responsibilities;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.Settings.Service;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Responsibilities
|
||||
{
|
||||
[TestClass]
|
||||
public class ServiceResponsibilityTests
|
||||
{
|
||||
private RuntimeContext context;
|
||||
private Mock<ILogger> logger;
|
||||
private Mock<IMessageBox> messageBox;
|
||||
private Mock<IResponsibilityCollection<RuntimeTask>> responsibilities;
|
||||
private Mock<IRuntimeWindow> runtimeWindow;
|
||||
private Mock<IServiceProxy> serviceProxy;
|
||||
private Mock<Action> shutdown;
|
||||
private SessionConfiguration currentSession;
|
||||
private AppSettings currentSettings;
|
||||
private ServiceResponsibility sut;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
context = new RuntimeContext();
|
||||
logger = new Mock<ILogger>();
|
||||
messageBox = new Mock<IMessageBox>();
|
||||
responsibilities = new Mock<IResponsibilityCollection<RuntimeTask>>();
|
||||
runtimeWindow = new Mock<IRuntimeWindow>();
|
||||
serviceProxy = new Mock<IServiceProxy>();
|
||||
shutdown = new Mock<Action>();
|
||||
|
||||
currentSession = new SessionConfiguration();
|
||||
currentSettings = new AppSettings();
|
||||
currentSession.Settings = currentSettings;
|
||||
|
||||
context.Current = currentSession;
|
||||
context.Responsibilities = responsibilities.Object;
|
||||
|
||||
sut = new ServiceResponsibility(logger.Object, messageBox.Object, context, runtimeWindow.Object, serviceProxy.Object, shutdown.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ServiceProxy_MustShutdownWhenConnectionLostAndMandatory()
|
||||
{
|
||||
currentSettings.Service.Policy = ServicePolicy.Mandatory;
|
||||
|
||||
sut.Assume(RuntimeTask.RegisterSessionEvents);
|
||||
serviceProxy.Raise(c => c.ConnectionLost += null);
|
||||
|
||||
messageBox.Verify(m => m.Show(
|
||||
It.IsAny<TextKey>(),
|
||||
It.IsAny<TextKey>(),
|
||||
It.IsAny<MessageBoxAction>(),
|
||||
It.Is<MessageBoxIcon>(i => i == MessageBoxIcon.Error),
|
||||
It.IsAny<IWindow>()), Times.Once);
|
||||
responsibilities.Verify(r => r.Delegate(RuntimeTask.StopSession), Times.Once);
|
||||
shutdown.Verify(s => s(), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ServiceProxy_MustNotShutdownWhenConnectionLostAndNotMandatory()
|
||||
{
|
||||
currentSettings.Service.Policy = ServicePolicy.Optional;
|
||||
|
||||
sut.Assume(RuntimeTask.RegisterSessionEvents);
|
||||
serviceProxy.Raise(c => c.ConnectionLost += null);
|
||||
|
||||
messageBox.Verify(m => m.Show(
|
||||
It.IsAny<TextKey>(),
|
||||
It.IsAny<TextKey>(),
|
||||
It.IsAny<MessageBoxAction>(),
|
||||
It.Is<MessageBoxIcon>(i => i == MessageBoxIcon.Error),
|
||||
It.IsAny<IWindow>()), Times.Never);
|
||||
responsibilities.Verify(r => r.Delegate(RuntimeTask.StopSession), Times.Never);
|
||||
shutdown.Verify(s => s(), Times.Never);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using SafeExamBrowser.Communication.Contracts.Proxies;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||
using SafeExamBrowser.Core.Contracts.ResponsibilityModel;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Runtime.Responsibilities;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.Settings.Security;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Responsibilities
|
||||
{
|
||||
[TestClass]
|
||||
public class SessionResponsibilityTests
|
||||
{
|
||||
private AppConfig appConfig;
|
||||
private Mock<IClientProxy> clientProxy;
|
||||
private Mock<ILogger> logger;
|
||||
private Mock<IMessageBox> messageBox;
|
||||
private Mock<IResponsibilityCollection<RuntimeTask>> responsibilities;
|
||||
private RuntimeContext context;
|
||||
private Mock<IRuntimeWindow> runtimeWindow;
|
||||
private Mock<IRepeatableOperationSequence> sessionSequence;
|
||||
private Mock<Action> shutdown;
|
||||
private Mock<IText> text;
|
||||
private SessionConfiguration currentSession;
|
||||
private AppSettings currentSettings;
|
||||
private SessionConfiguration nextSession;
|
||||
private AppSettings nextSettings;
|
||||
private SessionResponsibility sut;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
appConfig = new AppConfig();
|
||||
clientProxy = new Mock<IClientProxy>();
|
||||
context = new RuntimeContext();
|
||||
logger = new Mock<ILogger>();
|
||||
messageBox = new Mock<IMessageBox>();
|
||||
responsibilities = new Mock<IResponsibilityCollection<RuntimeTask>>();
|
||||
runtimeWindow = new Mock<IRuntimeWindow>();
|
||||
sessionSequence = new Mock<IRepeatableOperationSequence>();
|
||||
shutdown = new Mock<Action>();
|
||||
text = new Mock<IText>();
|
||||
|
||||
currentSession = new SessionConfiguration();
|
||||
currentSettings = new AppSettings();
|
||||
nextSession = new SessionConfiguration();
|
||||
nextSettings = new AppSettings();
|
||||
|
||||
currentSession.Settings = currentSettings;
|
||||
nextSession.Settings = nextSettings;
|
||||
|
||||
context.ClientProxy = clientProxy.Object;
|
||||
context.Current = currentSession;
|
||||
context.Next = nextSession;
|
||||
context.Responsibilities = responsibilities.Object;
|
||||
|
||||
sut = new SessionResponsibility(appConfig, logger.Object, messageBox.Object, context, runtimeWindow.Object, sessionSequence.Object, shutdown.Object, text.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MustHideRuntimeWindowWhenUsingDisableExplorerShell()
|
||||
{
|
||||
context.Current = default;
|
||||
currentSettings.Security.KioskMode = KioskMode.DisableExplorerShell;
|
||||
nextSettings.Security.KioskMode = KioskMode.DisableExplorerShell;
|
||||
sessionSequence.Setup(s => s.TryPerform()).Callback(() => context.Current = currentSession).Returns(OperationResult.Success);
|
||||
|
||||
sut.Assume(RuntimeTask.StartSession);
|
||||
|
||||
runtimeWindow.Verify(w => w.Hide(), Times.Once);
|
||||
runtimeWindow.Reset();
|
||||
sessionSequence.Reset();
|
||||
sessionSequence.Setup(s => s.TryRepeat()).Returns(OperationResult.Aborted);
|
||||
|
||||
sut.Assume(RuntimeTask.StartSession);
|
||||
|
||||
runtimeWindow.Verify(w => w.Hide(), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MustShowMessageBoxOnFailure()
|
||||
{
|
||||
context.Current = default;
|
||||
sessionSequence.Setup(b => b.TryPerform()).Callback(() => context.Current = currentSession).Returns(OperationResult.Failed);
|
||||
|
||||
sut.Assume(RuntimeTask.StartSession);
|
||||
|
||||
messageBox.Verify(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()), Times.AtLeastOnce);
|
||||
messageBox.Reset();
|
||||
sessionSequence.Reset();
|
||||
sessionSequence.Setup(b => b.TryRepeat()).Returns(OperationResult.Failed);
|
||||
|
||||
sut.Assume(RuntimeTask.StartSession);
|
||||
|
||||
messageBox.Verify(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()), Times.AtLeastOnce);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MustTerminateOnSessionStartFailure()
|
||||
{
|
||||
context.Current = default;
|
||||
sessionSequence.Setup(b => b.TryPerform()).Callback(() => context.Current = currentSession).Returns(OperationResult.Failed);
|
||||
|
||||
sut.Assume(RuntimeTask.StartSession);
|
||||
|
||||
sessionSequence.Verify(b => b.TryPerform(), Times.Once);
|
||||
sessionSequence.Verify(b => b.TryRepeat(), Times.Never);
|
||||
sessionSequence.Verify(b => b.TryRevert(), Times.Once);
|
||||
shutdown.Verify(s => s(), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MustNotTerminateOnSessionStartAbortion()
|
||||
{
|
||||
context.Current = default;
|
||||
sessionSequence.Setup(b => b.TryPerform()).Returns(OperationResult.Aborted);
|
||||
|
||||
sut.Assume(RuntimeTask.StartSession);
|
||||
|
||||
sessionSequence.Verify(b => b.TryPerform(), Times.Once);
|
||||
sessionSequence.Verify(b => b.TryRepeat(), Times.Never);
|
||||
sessionSequence.Verify(b => b.TryRevert(), Times.Never);
|
||||
shutdown.Verify(s => s(), Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MustInformClientAboutAbortedReconfiguration()
|
||||
{
|
||||
context.Current = default;
|
||||
sessionSequence.Setup(b => b.TryPerform()).Callback(() => context.Current = currentSession).Returns(OperationResult.Aborted);
|
||||
|
||||
sut.Assume(RuntimeTask.StartSession);
|
||||
|
||||
clientProxy.Verify(c => c.InformReconfigurationAborted(), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
@@ -6,583 +6,73 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using SafeExamBrowser.Communication.Contracts.Data;
|
||||
using SafeExamBrowser.Communication.Contracts.Events;
|
||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||
using SafeExamBrowser.Communication.Contracts.Proxies;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Core.Contracts.ResponsibilityModel;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Runtime.Operations.Events;
|
||||
using SafeExamBrowser.Server.Contracts.Data;
|
||||
using SafeExamBrowser.Runtime.Responsibilities;
|
||||
using SafeExamBrowser.Settings;
|
||||
using SafeExamBrowser.Settings.Security;
|
||||
using SafeExamBrowser.Settings.Service;
|
||||
using SafeExamBrowser.UserInterface.Contracts;
|
||||
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows.Data;
|
||||
using SafeExamBrowser.WindowsApi.Contracts;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests
|
||||
{
|
||||
[TestClass]
|
||||
public class RuntimeControllerTests
|
||||
{
|
||||
private AppConfig appConfig;
|
||||
private Mock<IOperationSequence> bootstrapSequence;
|
||||
private Mock<IProcess> clientProcess;
|
||||
private Mock<IClientProxy> clientProxy;
|
||||
private RuntimeContext context;
|
||||
private SessionConfiguration currentSession;
|
||||
private AppSettings currentSettings;
|
||||
private Mock<ILogger> logger;
|
||||
private Mock<IMessageBox> messageBox;
|
||||
private SessionConfiguration nextSession;
|
||||
private AppSettings nextSettings;
|
||||
private Mock<IRuntimeHost> runtimeHost;
|
||||
private Mock<IResponsibilityCollection<RuntimeTask>> responsibilities;
|
||||
private Mock<IRuntimeWindow> runtimeWindow;
|
||||
private Mock<IServiceProxy> service;
|
||||
private SessionContext sessionContext;
|
||||
private Mock<IRepeatableOperationSequence> sessionSequence;
|
||||
private Mock<Action> shutdown;
|
||||
private Mock<ISplashScreen> splashScreen;
|
||||
private Mock<IText> text;
|
||||
private Mock<IUserInterfaceFactory> uiFactory;
|
||||
|
||||
private RuntimeController sut;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
appConfig = new AppConfig();
|
||||
bootstrapSequence = new Mock<IOperationSequence>();
|
||||
clientProcess = new Mock<IProcess>();
|
||||
clientProxy = new Mock<IClientProxy>();
|
||||
context = new RuntimeContext();
|
||||
currentSession = new SessionConfiguration();
|
||||
currentSettings = new AppSettings();
|
||||
logger = new Mock<ILogger>();
|
||||
messageBox = new Mock<IMessageBox>();
|
||||
nextSession = new SessionConfiguration();
|
||||
nextSettings = new AppSettings();
|
||||
runtimeHost = new Mock<IRuntimeHost>();
|
||||
responsibilities = new Mock<IResponsibilityCollection<RuntimeTask>>();
|
||||
runtimeWindow = new Mock<IRuntimeWindow>();
|
||||
service = new Mock<IServiceProxy>();
|
||||
sessionContext = new SessionContext();
|
||||
sessionSequence = new Mock<IRepeatableOperationSequence>();
|
||||
shutdown = new Mock<Action>();
|
||||
splashScreen = new Mock<ISplashScreen>();
|
||||
text = new Mock<IText>();
|
||||
uiFactory = new Mock<IUserInterfaceFactory>();
|
||||
|
||||
currentSession.Settings = currentSettings;
|
||||
nextSession.Settings = nextSettings;
|
||||
|
||||
sessionContext.ClientProcess = clientProcess.Object;
|
||||
sessionContext.ClientProxy = clientProxy.Object;
|
||||
sessionContext.Current = currentSession;
|
||||
sessionContext.Next = nextSession;
|
||||
context.Current = currentSession;
|
||||
context.Next = nextSession;
|
||||
|
||||
uiFactory.Setup(u => u.CreateRuntimeWindow(It.IsAny<AppConfig>())).Returns(new Mock<IRuntimeWindow>().Object);
|
||||
uiFactory.Setup(u => u.CreateSplashScreen(It.IsAny<AppConfig>())).Returns(new Mock<ISplashScreen>().Object);
|
||||
|
||||
sut = new RuntimeController(
|
||||
appConfig,
|
||||
logger.Object,
|
||||
messageBox.Object,
|
||||
bootstrapSequence.Object,
|
||||
sessionSequence.Object,
|
||||
runtimeHost.Object,
|
||||
runtimeWindow.Object,
|
||||
service.Object,
|
||||
sessionContext,
|
||||
shutdown.Object,
|
||||
splashScreen.Object,
|
||||
text.Object,
|
||||
uiFactory.Object);
|
||||
sut = new RuntimeController(logger.Object, bootstrapSequence.Object, responsibilities.Object, context, runtimeWindow.Object, splashScreen.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClientProcess_MustShutdownWhenClientTerminated()
|
||||
{
|
||||
StartSession();
|
||||
clientProcess.Raise(c => c.Terminated += null, -1);
|
||||
|
||||
messageBox.Verify(m => m.Show(
|
||||
It.IsAny<TextKey>(),
|
||||
It.IsAny<TextKey>(),
|
||||
It.IsAny<MessageBoxAction>(),
|
||||
It.Is<MessageBoxIcon>(i => i == MessageBoxIcon.Error),
|
||||
It.IsAny<IWindow>()), Times.Once);
|
||||
sessionSequence.Verify(s => s.TryRevert(), Times.Once);
|
||||
shutdown.Verify(s => s(), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClientProxy_MustShutdownWhenConnectionLost()
|
||||
{
|
||||
StartSession();
|
||||
clientProxy.Raise(c => c.ConnectionLost += null);
|
||||
|
||||
messageBox.Verify(m => m.Show(
|
||||
It.IsAny<TextKey>(),
|
||||
It.IsAny<TextKey>(),
|
||||
It.IsAny<MessageBoxAction>(),
|
||||
It.Is<MessageBoxIcon>(i => i == MessageBoxIcon.Error),
|
||||
It.IsAny<IWindow>()), Times.Once);
|
||||
sessionSequence.Verify(s => s.TryRevert(), Times.Once);
|
||||
shutdown.Verify(s => s(), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Communication_MustProvideClientConfigurationUponRequest()
|
||||
{
|
||||
var args = new ClientConfigurationEventArgs();
|
||||
var nextAppConfig = new AppConfig();
|
||||
var nextSessionId = Guid.NewGuid();
|
||||
var nextSettings = new AppSettings();
|
||||
|
||||
nextSession.AppConfig = nextAppConfig;
|
||||
nextSession.SessionId = nextSessionId;
|
||||
nextSession.Settings = nextSettings;
|
||||
StartSession();
|
||||
|
||||
runtimeHost.Raise(r => r.ClientConfigurationNeeded += null, args);
|
||||
|
||||
Assert.AreSame(nextAppConfig, args.ClientConfiguration.AppConfig);
|
||||
Assert.AreEqual(nextSessionId, args.ClientConfiguration.SessionId);
|
||||
Assert.AreSame(nextSettings, args.ClientConfiguration.Settings);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Communication_MustStartNewSessionUponRequest()
|
||||
{
|
||||
var args = new ReconfigurationEventArgs { ConfigurationPath = "C:\\Some\\File\\Path.seb" };
|
||||
|
||||
StartSession();
|
||||
bootstrapSequence.Reset();
|
||||
sessionSequence.Reset();
|
||||
sessionSequence.Setup(s => s.TryRepeat()).Returns(OperationResult.Success);
|
||||
|
||||
runtimeHost.Raise(r => r.ReconfigurationRequested += null, args);
|
||||
|
||||
bootstrapSequence.VerifyNoOtherCalls();
|
||||
sessionSequence.Verify(s => s.TryPerform(), Times.Never);
|
||||
sessionSequence.Verify(s => s.TryRepeat(), Times.Once);
|
||||
sessionSequence.Verify(s => s.TryRevert(), Times.Never);
|
||||
|
||||
Assert.AreEqual(sessionContext.ReconfigurationFilePath, args.ConfigurationPath);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Communication_MustInformClientAboutAbortedReconfiguration()
|
||||
{
|
||||
StartSession();
|
||||
sessionSequence.Reset();
|
||||
sessionSequence.Setup(s => s.TryRepeat()).Returns(OperationResult.Aborted);
|
||||
|
||||
runtimeHost.Raise(r => r.ReconfigurationRequested += null, new ReconfigurationEventArgs());
|
||||
|
||||
clientProxy.Verify(c => c.InformReconfigurationAborted(), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Communication_MustShutdownUponRequest()
|
||||
{
|
||||
StartSession();
|
||||
bootstrapSequence.Reset();
|
||||
sessionSequence.Reset();
|
||||
|
||||
runtimeHost.Raise(r => r.ShutdownRequested += null);
|
||||
|
||||
bootstrapSequence.VerifyNoOtherCalls();
|
||||
sessionSequence.VerifyNoOtherCalls();
|
||||
shutdown.Verify(s => s(), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operations_MustAllowToAbortStartupForClientConfiguration()
|
||||
{
|
||||
var args = new ConfigurationCompletedEventArgs();
|
||||
|
||||
messageBox.Setup(m => m.Show(It.IsAny<TextKey>(), It.IsAny<TextKey>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>())).Returns(MessageBoxResult.Yes);
|
||||
|
||||
sut.TryStart();
|
||||
sessionSequence.Raise(s => s.ActionRequired += null, args);
|
||||
|
||||
Assert.IsTrue(args.AbortStartup);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operations_MustRequestServerExamSelectionViaDialogOnDefaultDesktop()
|
||||
{
|
||||
var args = new ExamSelectionEventArgs(Enumerable.Empty<Exam>());
|
||||
var examSelectionDialog = new Mock<IExamSelectionDialog>();
|
||||
var result = new ExamSelectionDialogResult { SelectedExam = new Exam(), Success = true };
|
||||
|
||||
currentSettings.Security.KioskMode = KioskMode.DisableExplorerShell;
|
||||
examSelectionDialog.Setup(p => p.Show(It.IsAny<IWindow>())).Returns(result);
|
||||
uiFactory.Setup(u => u.CreateExamSelectionDialog(It.IsAny<IEnumerable<Exam>>())).Returns(examSelectionDialog.Object);
|
||||
|
||||
sut.TryStart();
|
||||
sessionSequence.Raise(s => s.ActionRequired += null, args);
|
||||
|
||||
clientProxy.VerifyNoOtherCalls();
|
||||
examSelectionDialog.Verify(p => p.Show(It.IsAny<IWindow>()), Times.Once);
|
||||
uiFactory.Verify(u => u.CreateExamSelectionDialog(It.IsAny<IEnumerable<Exam>>()), Times.Once);
|
||||
|
||||
Assert.AreEqual(true, args.Success);
|
||||
Assert.AreEqual(result.SelectedExam, args.SelectedExam);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operations_MustRequestServerExamSelectionViaClientOnNewDesktop()
|
||||
{
|
||||
var args = new ExamSelectionEventArgs(new[] { new Exam { Id = "abc1234" } });
|
||||
var examSelectionReceived = new Action<IEnumerable<(string, string, string, string)>, Guid>((e, id) =>
|
||||
{
|
||||
runtimeHost.Raise(r => r.ExamSelectionReceived += null, new ExamSelectionReplyEventArgs
|
||||
{
|
||||
RequestId = id,
|
||||
SelectedExamId = "abc1234",
|
||||
Success = true
|
||||
});
|
||||
});
|
||||
|
||||
currentSettings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
||||
clientProxy
|
||||
.Setup(c => c.RequestExamSelection(It.IsAny<IEnumerable<(string, string, string, string)>>(), It.IsAny<Guid>()))
|
||||
.Returns(new CommunicationResult(true))
|
||||
.Callback(examSelectionReceived);
|
||||
|
||||
sut.TryStart();
|
||||
sessionSequence.Raise(s => s.ActionRequired += null, args);
|
||||
|
||||
clientProxy.Verify(c => c.RequestExamSelection(It.IsAny<IEnumerable<(string, string, string, string)>>(), It.IsAny<Guid>()), Times.Once);
|
||||
uiFactory.Verify(u => u.CreateExamSelectionDialog(It.IsAny<IEnumerable<Exam>>()), Times.Never);
|
||||
|
||||
Assert.AreEqual("abc1234", args.SelectedExam.Id);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operations_MustRequestPasswordViaDialogOnDefaultDesktop()
|
||||
{
|
||||
var args = new PasswordRequiredEventArgs();
|
||||
var passwordDialog = new Mock<IPasswordDialog>();
|
||||
var result = new PasswordDialogResult { Password = "test1234", Success = true };
|
||||
|
||||
currentSettings.Security.KioskMode = KioskMode.DisableExplorerShell;
|
||||
passwordDialog.Setup(p => p.Show(It.IsAny<IWindow>())).Returns(result);
|
||||
uiFactory.Setup(u => u.CreatePasswordDialog(It.IsAny<string>(), It.IsAny<string>())).Returns(passwordDialog.Object);
|
||||
|
||||
sut.TryStart();
|
||||
sessionSequence.Raise(s => s.ActionRequired += null, args);
|
||||
|
||||
clientProxy.VerifyNoOtherCalls();
|
||||
passwordDialog.Verify(p => p.Show(It.IsAny<IWindow>()), Times.Once);
|
||||
uiFactory.Verify(u => u.CreatePasswordDialog(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
|
||||
|
||||
Assert.AreEqual(true, args.Success);
|
||||
Assert.AreEqual(result.Password, args.Password);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operations_MustRequestPasswordViaClientOnNewDesktop()
|
||||
{
|
||||
var args = new PasswordRequiredEventArgs();
|
||||
var passwordReceived = new Action<PasswordRequestPurpose, Guid>((p, id) =>
|
||||
{
|
||||
runtimeHost.Raise(r => r.PasswordReceived += null, new PasswordReplyEventArgs { Password = "test", RequestId = id, Success = true });
|
||||
});
|
||||
|
||||
currentSettings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
||||
clientProxy.Setup(c => c.RequestPassword(It.IsAny<PasswordRequestPurpose>(), It.IsAny<Guid>())).Returns(new CommunicationResult(true)).Callback(passwordReceived);
|
||||
|
||||
sut.TryStart();
|
||||
sessionSequence.Raise(s => s.ActionRequired += null, args);
|
||||
|
||||
clientProxy.Verify(c => c.RequestPassword(It.IsAny<PasswordRequestPurpose>(), It.IsAny<Guid>()), Times.Once);
|
||||
uiFactory.Verify(u => u.CreatePasswordDialog(It.IsAny<string>(), It.IsAny<string>()), Times.Never);
|
||||
|
||||
Assert.AreEqual("test", args.Password);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operations_MustRequestServerFailureActionViaDialogOnDefaultDesktop()
|
||||
{
|
||||
var args = new ServerFailureEventArgs(default(string), default(bool));
|
||||
var failureDialog = new Mock<IServerFailureDialog>();
|
||||
var result = new ServerFailureDialogResult { Fallback = true, Success = true };
|
||||
|
||||
currentSettings.Security.KioskMode = KioskMode.DisableExplorerShell;
|
||||
failureDialog.Setup(p => p.Show(It.IsAny<IWindow>())).Returns(result);
|
||||
uiFactory.Setup(u => u.CreateServerFailureDialog(It.IsAny<string>(), It.IsAny<bool>())).Returns(failureDialog.Object);
|
||||
|
||||
sut.TryStart();
|
||||
sessionSequence.Raise(s => s.ActionRequired += null, args);
|
||||
|
||||
clientProxy.VerifyNoOtherCalls();
|
||||
failureDialog.Verify(p => p.Show(It.IsAny<IWindow>()), Times.Once);
|
||||
uiFactory.Verify(u => u.CreateServerFailureDialog(It.IsAny<string>(), It.IsAny<bool>()), Times.Once);
|
||||
|
||||
Assert.AreEqual(result.Abort, args.Abort);
|
||||
Assert.AreEqual(result.Fallback, args.Fallback);
|
||||
Assert.AreEqual(result.Retry, args.Retry);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operations_MustRequestServerFailureActionViaClientOnNewDesktop()
|
||||
{
|
||||
var args = new ServerFailureEventArgs(default(string), default(bool));
|
||||
var failureActionReceived = new Action<string, bool, Guid>((m, f, id) =>
|
||||
{
|
||||
runtimeHost.Raise(r => r.ServerFailureActionReceived += null, new ServerFailureActionReplyEventArgs
|
||||
{
|
||||
RequestId = id,
|
||||
Fallback = true
|
||||
});
|
||||
});
|
||||
|
||||
currentSettings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
||||
clientProxy
|
||||
.Setup(c => c.RequestServerFailureAction(It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<Guid>()))
|
||||
.Returns(new CommunicationResult(true))
|
||||
.Callback(failureActionReceived);
|
||||
|
||||
sut.TryStart();
|
||||
sessionSequence.Raise(s => s.ActionRequired += null, args);
|
||||
|
||||
clientProxy.Verify(c => c.RequestServerFailureAction(It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<Guid>()), Times.Once);
|
||||
uiFactory.Verify(u => u.CreateServerFailureDialog(It.IsAny<string>(), It.IsAny<bool>()), Times.Never);
|
||||
|
||||
Assert.IsFalse(args.Abort);
|
||||
Assert.IsTrue(args.Fallback);
|
||||
Assert.IsFalse(args.Retry);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operations_MustAbortAskingForPasswordViaClientIfDecidedByUser()
|
||||
{
|
||||
var args = new PasswordRequiredEventArgs();
|
||||
var passwordReceived = new Action<PasswordRequestPurpose, Guid>((p, id) =>
|
||||
{
|
||||
runtimeHost.Raise(r => r.PasswordReceived += null, new PasswordReplyEventArgs { RequestId = id, Success = false });
|
||||
});
|
||||
|
||||
currentSettings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
||||
clientProxy.Setup(c => c.RequestPassword(It.IsAny<PasswordRequestPurpose>(), It.IsAny<Guid>())).Returns(new CommunicationResult(true)).Callback(passwordReceived);
|
||||
|
||||
sut.TryStart();
|
||||
sessionSequence.Raise(s => s.ActionRequired += null, args);
|
||||
|
||||
clientProxy.Verify(c => c.RequestPassword(It.IsAny<PasswordRequestPurpose>(), It.IsAny<Guid>()), Times.Once);
|
||||
uiFactory.Verify(u => u.CreatePasswordDialog(It.IsAny<string>(), It.IsAny<string>()), Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operations_MustNotWaitForPasswordViaClientIfCommunicationHasFailed()
|
||||
{
|
||||
var args = new PasswordRequiredEventArgs();
|
||||
|
||||
currentSettings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
||||
clientProxy.Setup(c => c.RequestPassword(It.IsAny<PasswordRequestPurpose>(), It.IsAny<Guid>())).Returns(new CommunicationResult(false));
|
||||
|
||||
sut.TryStart();
|
||||
sessionSequence.Raise(s => s.ActionRequired += null, args);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operations_MustShowNormalMessageBoxOnDefaultDesktop()
|
||||
{
|
||||
var args = new MessageEventArgs
|
||||
{
|
||||
Icon = MessageBoxIcon.Question,
|
||||
Message = TextKey.MessageBox_ClientConfigurationQuestion,
|
||||
Title = TextKey.MessageBox_ClientConfigurationQuestionTitle
|
||||
};
|
||||
|
||||
StartSession();
|
||||
currentSettings.Security.KioskMode = KioskMode.DisableExplorerShell;
|
||||
|
||||
sessionSequence.Raise(s => s.ActionRequired += null, args);
|
||||
|
||||
messageBox.Verify(m => m.Show(
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<string>(),
|
||||
It.Is<MessageBoxAction>(a => a == MessageBoxAction.Ok),
|
||||
It.Is<MessageBoxIcon>(i => i == args.Icon),
|
||||
It.IsAny<IWindow>()), Times.Once);
|
||||
clientProxy.VerifyAdd(p => p.ConnectionLost += It.IsAny<CommunicationEventHandler>());
|
||||
clientProxy.VerifyNoOtherCalls();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operations_MustShowMessageBoxViaClientOnNewDesktop()
|
||||
{
|
||||
var args = new MessageEventArgs
|
||||
{
|
||||
Icon = MessageBoxIcon.Question,
|
||||
Message = TextKey.MessageBox_ClientConfigurationQuestion,
|
||||
Title = TextKey.MessageBox_ClientConfigurationQuestionTitle
|
||||
};
|
||||
var reply = new MessageBoxReplyEventArgs();
|
||||
|
||||
StartSession();
|
||||
currentSettings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
||||
|
||||
clientProxy.Setup(c => c.ShowMessage(
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<string>(),
|
||||
It.Is<int>(a => a == (int) MessageBoxAction.Ok),
|
||||
It.IsAny<int>(),
|
||||
It.IsAny<Guid>()))
|
||||
.Callback<string, string, int, int, Guid>((m, t, a, i, id) =>
|
||||
{
|
||||
runtimeHost.Raise(r => r.MessageBoxReplyReceived += null, new MessageBoxReplyEventArgs { RequestId = id });
|
||||
})
|
||||
.Returns(new CommunicationResult(true));
|
||||
|
||||
sessionSequence.Raise(s => s.ActionRequired += null, args);
|
||||
|
||||
messageBox.Verify(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()), Times.Never);
|
||||
clientProxy.Verify(c => c.ShowMessage(
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<string>(),
|
||||
It.Is<int>(a => a == (int) MessageBoxAction.Ok),
|
||||
It.Is<int>(i => i == (int) args.Icon),
|
||||
It.IsAny<Guid>()), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operations_MustUpdateProgress()
|
||||
{
|
||||
var args = new ProgressChangedEventArgs
|
||||
{
|
||||
CurrentValue = 23,
|
||||
IsIndeterminate = true,
|
||||
MaxValue = 150,
|
||||
Progress = true,
|
||||
Regress = true
|
||||
};
|
||||
|
||||
sut.TryStart();
|
||||
sessionSequence.Raise(o => o.ProgressChanged += null, args);
|
||||
|
||||
runtimeWindow.Verify(s => s.SetValue(It.Is<int>(i => i == args.CurrentValue)), Times.Once);
|
||||
runtimeWindow.Verify(s => s.SetIndeterminate(), Times.Exactly(2));
|
||||
runtimeWindow.Verify(s => s.SetMaxValue(It.Is<int>(i => i == args.MaxValue)), Times.Once);
|
||||
runtimeWindow.Verify(s => s.Progress(), Times.Once);
|
||||
runtimeWindow.Verify(s => s.Regress(), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operations_MustUpdateStatus()
|
||||
{
|
||||
var key = TextKey.OperationStatus_InitializeClipboard;
|
||||
|
||||
sut.TryStart();
|
||||
sessionSequence.Raise(o => o.StatusChanged += null, key);
|
||||
|
||||
runtimeWindow.Verify(s => s.UpdateStatus(It.Is<TextKey>(k => k == key), It.IsAny<bool>()), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Session_MustHideRuntimeWindowWhenUsingDisableExplorerShell()
|
||||
{
|
||||
currentSettings.Security.KioskMode = KioskMode.DisableExplorerShell;
|
||||
StartSession();
|
||||
runtimeWindow.Verify(w => w.Hide(), Times.AtLeastOnce);
|
||||
|
||||
runtimeWindow.Reset();
|
||||
sessionSequence.Reset();
|
||||
|
||||
sessionSequence.Setup(b => b.TryRepeat()).Returns(OperationResult.Aborted);
|
||||
runtimeHost.Raise(h => h.ReconfigurationRequested += null, new ReconfigurationEventArgs());
|
||||
runtimeWindow.Verify(w => w.Hide(), Times.AtLeastOnce);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Session_MustShowMessageBoxOnFailure()
|
||||
{
|
||||
bootstrapSequence.Setup(b => b.TryPerform()).Returns(OperationResult.Success);
|
||||
sessionSequence.Setup(b => b.TryPerform()).Returns(OperationResult.Failed);
|
||||
sessionContext.Current = null;
|
||||
sut.TryStart();
|
||||
messageBox.Verify(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()), Times.AtLeastOnce);
|
||||
|
||||
StartSession();
|
||||
messageBox.Reset();
|
||||
sessionSequence.Reset();
|
||||
|
||||
sessionSequence.Setup(b => b.TryRepeat()).Returns(OperationResult.Failed);
|
||||
runtimeHost.Raise(h => h.ReconfigurationRequested += null, new ReconfigurationEventArgs());
|
||||
messageBox.Verify(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()), Times.AtLeastOnce);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ServiceProxy_MustShutdownWhenConnectionLostAndMandatory()
|
||||
{
|
||||
currentSettings.Service.Policy = ServicePolicy.Mandatory;
|
||||
|
||||
StartSession();
|
||||
service.Raise(c => c.ConnectionLost += null);
|
||||
|
||||
messageBox.Verify(m => m.Show(
|
||||
It.IsAny<TextKey>(),
|
||||
It.IsAny<TextKey>(),
|
||||
It.IsAny<MessageBoxAction>(),
|
||||
It.Is<MessageBoxIcon>(i => i == MessageBoxIcon.Error),
|
||||
It.IsAny<IWindow>()), Times.Once);
|
||||
sessionSequence.Verify(s => s.TryRevert(), Times.Once);
|
||||
shutdown.Verify(s => s(), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ServiceProxy_MustNotShutdownWhenConnectionLostAndNotMandatory()
|
||||
{
|
||||
currentSettings.Service.Policy = ServicePolicy.Optional;
|
||||
|
||||
StartSession();
|
||||
service.Raise(c => c.ConnectionLost += null);
|
||||
|
||||
messageBox.Verify(m => m.Show(
|
||||
It.IsAny<TextKey>(),
|
||||
It.IsAny<TextKey>(),
|
||||
It.IsAny<MessageBoxAction>(),
|
||||
It.Is<MessageBoxIcon>(i => i == MessageBoxIcon.Error),
|
||||
It.IsAny<IWindow>()), Times.Never);
|
||||
sessionSequence.Verify(s => s.TryRevert(), Times.Never);
|
||||
shutdown.Verify(s => s(), Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Shutdown_MustRevertSessionThenBootstrapSequence()
|
||||
public void Shutdown_MustStopSessionThenRevertBootstrapSequence()
|
||||
{
|
||||
var order = 0;
|
||||
var bootstrap = 0;
|
||||
var session = 0;
|
||||
|
||||
sut.TryStart();
|
||||
|
||||
bootstrapSequence.Reset();
|
||||
sessionSequence.Reset();
|
||||
|
||||
bootstrapSequence.Setup(b => b.TryRevert()).Returns(OperationResult.Success).Callback(() => bootstrap = ++order);
|
||||
sessionSequence.Setup(b => b.TryRevert()).Returns(OperationResult.Success).Callback(() => session = ++order);
|
||||
responsibilities.Setup(r => r.Delegate(RuntimeTask.StopSession)).Callback(() => session = ++order);
|
||||
|
||||
sut.Terminate();
|
||||
|
||||
bootstrapSequence.Verify(b => b.TryPerform(), Times.Never);
|
||||
bootstrapSequence.Verify(b => b.TryRevert(), Times.Once);
|
||||
sessionSequence.Verify(b => b.TryPerform(), Times.Never);
|
||||
sessionSequence.Verify(b => b.TryRepeat(), Times.Never);
|
||||
sessionSequence.Verify(b => b.TryRevert(), Times.Once);
|
||||
responsibilities.Verify(r => r.Delegate(RuntimeTask.DeregisterEvents), Times.Once);
|
||||
responsibilities.Verify(r => r.Delegate(RuntimeTask.StopSession), Times.Once);
|
||||
|
||||
Assert.AreEqual(1, session);
|
||||
Assert.AreEqual(2, bootstrap);
|
||||
@@ -595,65 +85,38 @@ namespace SafeExamBrowser.Runtime.UnitTests
|
||||
var bootstrap = 0;
|
||||
var session = 0;
|
||||
|
||||
sut.TryStart();
|
||||
|
||||
bootstrapSequence.Reset();
|
||||
sessionSequence.Reset();
|
||||
|
||||
context.Current = default;
|
||||
bootstrapSequence.Setup(b => b.TryRevert()).Returns(OperationResult.Success).Callback(() => bootstrap = ++order);
|
||||
sessionSequence.Setup(b => b.TryRevert()).Returns(OperationResult.Success).Callback(() => session = ++order);
|
||||
sessionContext.Current = null;
|
||||
responsibilities.Setup(r => r.Delegate(RuntimeTask.StopSession)).Callback(() => session = ++order);
|
||||
|
||||
sut.Terminate();
|
||||
|
||||
bootstrapSequence.Verify(b => b.TryPerform(), Times.Never);
|
||||
bootstrapSequence.Verify(b => b.TryRevert(), Times.Once);
|
||||
sessionSequence.Verify(b => b.TryPerform(), Times.Never);
|
||||
sessionSequence.Verify(b => b.TryRepeat(), Times.Never);
|
||||
sessionSequence.Verify(b => b.TryRevert(), Times.Never);
|
||||
responsibilities.Verify(r => r.Delegate(RuntimeTask.DeregisterEvents), Times.Once);
|
||||
responsibilities.Verify(r => r.Delegate(RuntimeTask.StopSession), Times.Never);
|
||||
|
||||
Assert.AreEqual(0, session);
|
||||
Assert.AreEqual(1, bootstrap);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Shutdown_MustIndicateFailureToUser()
|
||||
{
|
||||
var order = 0;
|
||||
var bootstrap = 0;
|
||||
var session = 0;
|
||||
|
||||
sut.TryStart();
|
||||
|
||||
bootstrapSequence.Reset();
|
||||
sessionSequence.Reset();
|
||||
|
||||
bootstrapSequence.Setup(b => b.TryRevert()).Returns(OperationResult.Failed).Callback(() => bootstrap = ++order);
|
||||
sessionSequence.Setup(b => b.TryRevert()).Returns(OperationResult.Success).Callback(() => session = ++order);
|
||||
|
||||
sut.Terminate();
|
||||
|
||||
messageBox.Verify(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>(), It.IsAny<IWindow>()), Times.AtLeastOnce);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Startup_MustPerformBootstrapThenSessionSequence()
|
||||
public void Startup_MustPerformBootstrapSequenceThenStartSession()
|
||||
{
|
||||
var order = 0;
|
||||
var bootstrap = 0;
|
||||
var session = 0;
|
||||
|
||||
context.Current = default;
|
||||
bootstrapSequence.Setup(b => b.TryPerform()).Returns(OperationResult.Success).Callback(() => bootstrap = ++order);
|
||||
sessionSequence.Setup(b => b.TryPerform()).Returns(OperationResult.Success).Callback(() => { session = ++order; sessionContext.Current = currentSession; });
|
||||
sessionContext.Current = null;
|
||||
responsibilities.Setup(r => r.Delegate(RuntimeTask.StartSession)).Callback(() => { session = ++order; context.Current = currentSession; });
|
||||
|
||||
var success = sut.TryStart();
|
||||
|
||||
bootstrapSequence.Verify(b => b.TryPerform(), Times.Once);
|
||||
bootstrapSequence.Verify(b => b.TryRevert(), Times.Never);
|
||||
sessionSequence.Verify(b => b.TryPerform(), Times.Once);
|
||||
sessionSequence.Verify(b => b.TryRepeat(), Times.Never);
|
||||
sessionSequence.Verify(b => b.TryRevert(), Times.Never);
|
||||
responsibilities.Verify(r => r.Delegate(RuntimeTask.RegisterEvents), Times.Once);
|
||||
responsibilities.Verify(r => r.Delegate(RuntimeTask.StartSession), Times.Once);
|
||||
|
||||
Assert.IsTrue(success);
|
||||
Assert.AreEqual(1, bootstrap);
|
||||
@@ -661,113 +124,26 @@ namespace SafeExamBrowser.Runtime.UnitTests
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Startup_MustNotPerformSessionSequenceIfBootstrapFails()
|
||||
public void Startup_MustNotStartSessionIfBootstrapSequenceFails()
|
||||
{
|
||||
var order = 0;
|
||||
var bootstrap = 0;
|
||||
var session = 0;
|
||||
|
||||
context.Current = default;
|
||||
bootstrapSequence.Setup(b => b.TryPerform()).Returns(OperationResult.Failed).Callback(() => bootstrap = ++order);
|
||||
sessionSequence.Setup(b => b.TryPerform()).Returns(OperationResult.Success).Callback(() => { session = ++order; sessionContext.Current = currentSession; });
|
||||
sessionContext.Current = null;
|
||||
responsibilities.Setup(r => r.Delegate(RuntimeTask.StartSession)).Callback(() => session = ++order);
|
||||
|
||||
var success = sut.TryStart();
|
||||
|
||||
bootstrapSequence.Verify(b => b.TryPerform(), Times.Once);
|
||||
bootstrapSequence.Verify(b => b.TryRevert(), Times.Never);
|
||||
sessionSequence.Verify(b => b.TryPerform(), Times.Never);
|
||||
sessionSequence.Verify(b => b.TryRepeat(), Times.Never);
|
||||
sessionSequence.Verify(b => b.TryRevert(), Times.Never);
|
||||
responsibilities.Verify(r => r.Delegate(RuntimeTask.RegisterEvents), Times.Never);
|
||||
responsibilities.Verify(r => r.Delegate(RuntimeTask.StartSession), Times.Never);
|
||||
|
||||
Assert.IsFalse(success);
|
||||
Assert.AreEqual(1, bootstrap);
|
||||
Assert.AreEqual(0, session);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Startup_MustTerminateOnSessionStartFailure()
|
||||
{
|
||||
bootstrapSequence.Setup(b => b.TryPerform()).Returns(OperationResult.Success);
|
||||
sessionSequence.Setup(b => b.TryPerform()).Returns(OperationResult.Failed).Callback(() => sessionContext.Current = currentSession);
|
||||
sessionContext.Current = null;
|
||||
|
||||
var success = sut.TryStart();
|
||||
|
||||
bootstrapSequence.Verify(b => b.TryPerform(), Times.Once);
|
||||
bootstrapSequence.Verify(b => b.TryRevert(), Times.Never);
|
||||
sessionSequence.Verify(b => b.TryPerform(), Times.Once);
|
||||
sessionSequence.Verify(b => b.TryRepeat(), Times.Never);
|
||||
sessionSequence.Verify(b => b.TryRevert(), Times.Once);
|
||||
|
||||
shutdown.Verify(s => s(), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Startup_MustNotTerminateOnSessionStartAbortion()
|
||||
{
|
||||
bootstrapSequence.Setup(b => b.TryPerform()).Returns(OperationResult.Success);
|
||||
sessionSequence.Setup(b => b.TryPerform()).Returns(OperationResult.Aborted).Callback(() => sessionContext.Current = currentSession);
|
||||
sessionContext.Current = null;
|
||||
|
||||
var success = sut.TryStart();
|
||||
|
||||
bootstrapSequence.Verify(b => b.TryPerform(), Times.Once);
|
||||
bootstrapSequence.Verify(b => b.TryRevert(), Times.Never);
|
||||
sessionSequence.Verify(b => b.TryPerform(), Times.Once);
|
||||
sessionSequence.Verify(b => b.TryRepeat(), Times.Never);
|
||||
sessionSequence.Verify(b => b.TryRevert(), Times.Never);
|
||||
|
||||
shutdown.Verify(s => s(), Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Startup_MustUpdateProgressForBootstrapSequence()
|
||||
{
|
||||
var args = new ProgressChangedEventArgs
|
||||
{
|
||||
CurrentValue = 12,
|
||||
IsIndeterminate = true,
|
||||
MaxValue = 100,
|
||||
Progress = true,
|
||||
Regress = true
|
||||
};
|
||||
|
||||
bootstrapSequence
|
||||
.Setup(b => b.TryPerform())
|
||||
.Returns(OperationResult.Success)
|
||||
.Callback(() => { bootstrapSequence.Raise(s => s.ProgressChanged += null, args); });
|
||||
|
||||
var success = sut.TryStart();
|
||||
|
||||
splashScreen.Verify(s => s.SetValue(It.Is<int>(i => i == args.CurrentValue)), Times.Once);
|
||||
splashScreen.Verify(s => s.SetIndeterminate(), Times.Once);
|
||||
splashScreen.Verify(s => s.SetMaxValue(It.Is<int>(i => i == args.MaxValue)), Times.Once);
|
||||
splashScreen.Verify(s => s.Progress(), Times.Once);
|
||||
splashScreen.Verify(s => s.Regress(), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Startup_MustUpdateStatusForBootstrapSequence()
|
||||
{
|
||||
var key = TextKey.OperationStatus_InitializeBrowser;
|
||||
|
||||
bootstrapSequence
|
||||
.Setup(b => b.TryPerform())
|
||||
.Returns(OperationResult.Success)
|
||||
.Callback(() => { bootstrapSequence.Raise(s => s.StatusChanged += null, key); });
|
||||
|
||||
var success = sut.TryStart();
|
||||
|
||||
splashScreen.Verify(s => s.UpdateStatus(It.Is<TextKey>(k => k == key), true), Times.Once);
|
||||
}
|
||||
|
||||
private void StartSession()
|
||||
{
|
||||
bootstrapSequence.Setup(b => b.TryPerform()).Returns(OperationResult.Success);
|
||||
sessionSequence.Setup(b => b.TryPerform()).Returns(OperationResult.Success).Callback(() => sessionContext.Current = currentSession);
|
||||
sessionContext.Current = null;
|
||||
|
||||
sut.TryStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\MSTest.TestAdapter.3.7.2\build\net462\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.3.7.2\build\net462\MSTest.TestAdapter.props')" />
|
||||
<Import Project="..\packages\Microsoft.Testing.Extensions.Telemetry.1.5.2\build\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.props" Condition="Exists('..\packages\Microsoft.Testing.Extensions.Telemetry.1.5.2\build\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.props')" />
|
||||
<Import Project="..\packages\Microsoft.Testing.Platform.MSBuild.1.5.2\build\Microsoft.Testing.Platform.MSBuild.props" Condition="Exists('..\packages\Microsoft.Testing.Platform.MSBuild.1.5.2\build\Microsoft.Testing.Platform.MSBuild.props')" />
|
||||
<Import Project="..\packages\Microsoft.Testing.Platform.1.5.2\build\netstandard2.0\Microsoft.Testing.Platform.props" Condition="Exists('..\packages\Microsoft.Testing.Platform.1.5.2\build\netstandard2.0\Microsoft.Testing.Platform.props')" />
|
||||
<Import Project="..\packages\MSTest.TestAdapter.3.10.3\build\net462\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.3.10.3\build\net462\MSTest.TestAdapter.props')" />
|
||||
<Import Project="..\packages\Microsoft.Testing.Extensions.Telemetry.1.8.3\build\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.props" Condition="Exists('..\packages\Microsoft.Testing.Extensions.Telemetry.1.8.3\build\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.props')" />
|
||||
<Import Project="..\packages\Microsoft.Testing.Platform.MSBuild.1.8.3\build\Microsoft.Testing.Platform.MSBuild.props" Condition="Exists('..\packages\Microsoft.Testing.Platform.MSBuild.1.8.3\build\Microsoft.Testing.Platform.MSBuild.props')" />
|
||||
<Import Project="..\packages\Microsoft.Testing.Platform.1.8.3\build\netstandard2.0\Microsoft.Testing.Platform.props" Condition="Exists('..\packages\Microsoft.Testing.Platform.1.8.3\build\netstandard2.0\Microsoft.Testing.Platform.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
@@ -61,86 +61,88 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Castle.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Castle.Core.5.1.1\lib\net462\Castle.Core.dll</HintPath>
|
||||
<HintPath>..\packages\Castle.Core.5.2.1\lib\net462\Castle.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ApplicationInsights, Version=2.22.0.997, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ApplicationInsights.2.22.0\lib\net46\Microsoft.ApplicationInsights.dll</HintPath>
|
||||
<Reference Include="Microsoft.ApplicationInsights, Version=2.23.0.29, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.ApplicationInsights.2.23.0\lib\net46\Microsoft.ApplicationInsights.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.Testing.Extensions.MSBuild, Version=1.5.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Testing.Platform.MSBuild.1.5.2\lib\netstandard2.0\Microsoft.Testing.Extensions.MSBuild.dll</HintPath>
|
||||
<Reference Include="Microsoft.Testing.Extensions.MSBuild, Version=1.8.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Testing.Platform.MSBuild.1.8.3\lib\netstandard2.0\Microsoft.Testing.Extensions.MSBuild.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Testing.Extensions.Telemetry, Version=1.5.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Testing.Extensions.Telemetry.1.5.2\lib\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.dll</HintPath>
|
||||
<Reference Include="Microsoft.Testing.Extensions.Telemetry, Version=1.8.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Testing.Extensions.Telemetry.1.8.3\lib\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Testing.Extensions.TrxReport.Abstractions, Version=1.5.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Testing.Extensions.TrxReport.Abstractions.1.5.2\lib\netstandard2.0\Microsoft.Testing.Extensions.TrxReport.Abstractions.dll</HintPath>
|
||||
<Reference Include="Microsoft.Testing.Extensions.TrxReport.Abstractions, Version=1.8.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Testing.Extensions.TrxReport.Abstractions.1.8.3\lib\netstandard2.0\Microsoft.Testing.Extensions.TrxReport.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Testing.Extensions.VSTestBridge, Version=1.5.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Testing.Extensions.VSTestBridge.1.5.2\lib\netstandard2.0\Microsoft.Testing.Extensions.VSTestBridge.dll</HintPath>
|
||||
<Reference Include="Microsoft.Testing.Extensions.VSTestBridge, Version=1.8.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Testing.Extensions.VSTestBridge.1.8.3\lib\netstandard2.0\Microsoft.Testing.Extensions.VSTestBridge.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Testing.Platform, Version=1.5.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Testing.Platform.1.5.2\lib\netstandard2.0\Microsoft.Testing.Platform.dll</HintPath>
|
||||
<Reference Include="Microsoft.Testing.Platform, Version=1.8.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Testing.Platform.1.8.3\lib\netstandard2.0\Microsoft.Testing.Platform.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.TestPlatform.AdapterUtilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.TestPlatform.AdapterUtilities.17.14.1\lib\net462\Microsoft.TestPlatform.AdapterUtilities.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.TestPlatform.CoreUtilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.TestPlatform.ObjectModel.17.12.0\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.TestPlatform.ObjectModel.17.14.1\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.TestPlatform.PlatformAbstractions, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.TestPlatform.ObjectModel.17.12.0\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.TestPlatform.ObjectModel.17.14.1\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.TestPlatform.ObjectModel.17.12.0\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.TestPlatform.ObjectModel.17.14.1\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MSTest.TestFramework.3.7.2\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
|
||||
<HintPath>..\packages\MSTest.TestFramework.3.10.3\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MSTest.TestFramework.3.7.2\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
||||
<HintPath>..\packages\MSTest.TestFramework.3.10.3\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Moq, Version=4.20.72.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Moq.4.20.72\lib\net462\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NuGet.Frameworks, Version=6.12.1.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NuGet.Frameworks.6.12.1\lib\net472\NuGet.Frameworks.dll</HintPath>
|
||||
<Reference Include="NuGet.Frameworks, Version=6.14.0.116, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NuGet.Frameworks.6.14.0\lib\net472\NuGet.Frameworks.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll</HintPath>
|
||||
<Reference Include="System.Buffers, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Collections.Immutable, Version=9.0.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Collections.Immutable.9.0.1\lib\net462\System.Collections.Immutable.dll</HintPath>
|
||||
<Reference Include="System.Collections.Immutable, Version=9.0.0.8, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Collections.Immutable.9.0.8\lib\net462\System.Collections.Immutable.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Diagnostics.DiagnosticSource, Version=9.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.9.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||
<Reference Include="System.Diagnostics.DiagnosticSource, Version=9.0.0.8, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.9.0.8\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Memory, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll</HintPath>
|
||||
<Reference Include="System.Memory, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.6.3\lib\net462\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll</HintPath>
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Reflection.Metadata, Version=9.0.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Reflection.Metadata.9.0.1\lib\net462\System.Reflection.Metadata.dll</HintPath>
|
||||
<Reference Include="System.Reflection.Metadata, Version=9.0.0.8, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Reflection.Metadata.9.0.8\lib\net462\System.Reflection.Metadata.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime" />
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.6.0\lib\net462\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Communication\ClientBridgeTests.cs" />
|
||||
<Compile Include="Operations\ClientTerminationOperationTests.cs" />
|
||||
<Compile Include="Operations\ConfigurationOperationTests.cs" />
|
||||
<Compile Include="Operations\DisclaimerOperationTests.cs" />
|
||||
@@ -153,6 +155,10 @@
|
||||
<Compile Include="Operations\SessionActivationOperationTests.cs" />
|
||||
<Compile Include="Operations\SessionInitializationOperationTests.cs" />
|
||||
<Compile Include="Operations\VirtualMachineOperationTests.cs" />
|
||||
<Compile Include="Responsibilities\ClientResponsibilityTests.cs" />
|
||||
<Compile Include="Responsibilities\CommunicationResponsibilityTests.cs" />
|
||||
<Compile Include="Responsibilities\ServiceResponsibilityTests.cs" />
|
||||
<Compile Include="Responsibilities\SessionResponsibilityTests.cs" />
|
||||
<Compile Include="RuntimeControllerTests.cs" />
|
||||
<Compile Include="Communication\RuntimeHostTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@@ -227,11 +233,8 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Analyzer Include="..\packages\MSTest.Analyzers.3.7.2\analyzers\dotnet\cs\MSTest.Analyzers.CodeFixes.dll" />
|
||||
<Analyzer Include="..\packages\MSTest.Analyzers.3.7.2\analyzers\dotnet\cs\MSTest.Analyzers.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="ILLink\ILLink.Descriptors.LibraryBuild.xml" />
|
||||
<Analyzer Include="..\packages\MSTest.Analyzers.3.10.3\analyzers\dotnet\cs\MSTest.Analyzers.CodeFixes.dll" />
|
||||
<Analyzer Include="..\packages\MSTest.Analyzers.3.10.3\analyzers\dotnet\cs\MSTest.Analyzers.dll" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
@@ -239,13 +242,19 @@
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Testing.Platform.1.5.2\build\netstandard2.0\Microsoft.Testing.Platform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Testing.Platform.1.5.2\build\netstandard2.0\Microsoft.Testing.Platform.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Testing.Platform.MSBuild.1.5.2\build\Microsoft.Testing.Platform.MSBuild.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Testing.Platform.MSBuild.1.5.2\build\Microsoft.Testing.Platform.MSBuild.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Testing.Platform.MSBuild.1.5.2\build\Microsoft.Testing.Platform.MSBuild.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Testing.Platform.MSBuild.1.5.2\build\Microsoft.Testing.Platform.MSBuild.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Testing.Extensions.Telemetry.1.5.2\build\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Testing.Extensions.Telemetry.1.5.2\build\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.props'))" />
|
||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.3.7.2\build\net462\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.3.7.2\build\net462\MSTest.TestAdapter.props'))" />
|
||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.3.7.2\build\net462\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.3.7.2\build\net462\MSTest.TestAdapter.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Testing.Platform.1.8.3\build\netstandard2.0\Microsoft.Testing.Platform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Testing.Platform.1.8.3\build\netstandard2.0\Microsoft.Testing.Platform.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Testing.Platform.1.8.3\build\netstandard2.0\Microsoft.Testing.Platform.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Testing.Platform.1.8.3\build\netstandard2.0\Microsoft.Testing.Platform.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Testing.Platform.MSBuild.1.8.3\build\Microsoft.Testing.Platform.MSBuild.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Testing.Platform.MSBuild.1.8.3\build\Microsoft.Testing.Platform.MSBuild.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Testing.Platform.MSBuild.1.8.3\build\Microsoft.Testing.Platform.MSBuild.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Testing.Platform.MSBuild.1.8.3\build\Microsoft.Testing.Platform.MSBuild.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Testing.Extensions.Telemetry.1.8.3\build\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Testing.Extensions.Telemetry.1.8.3\build\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.props'))" />
|
||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.3.10.3\build\net462\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.3.10.3\build\net462\MSTest.TestAdapter.props'))" />
|
||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.3.10.3\build\net462\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.3.10.3\build\net462\MSTest.TestAdapter.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\MSTest.TestFramework.3.10.3\build\net462\MSTest.TestFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestFramework.3.10.3\build\net462\MSTest.TestFramework.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.Testing.Platform.MSBuild.1.5.2\build\Microsoft.Testing.Platform.MSBuild.targets" Condition="Exists('..\packages\Microsoft.Testing.Platform.MSBuild.1.5.2\build\Microsoft.Testing.Platform.MSBuild.targets')" />
|
||||
<Import Project="..\packages\MSTest.TestAdapter.3.7.2\build\net462\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.3.7.2\build\net462\MSTest.TestAdapter.targets')" />
|
||||
<Import Project="..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets" Condition="Exists('..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" />
|
||||
<Import Project="..\packages\Microsoft.Testing.Platform.1.8.3\build\netstandard2.0\Microsoft.Testing.Platform.targets" Condition="Exists('..\packages\Microsoft.Testing.Platform.1.8.3\build\netstandard2.0\Microsoft.Testing.Platform.targets')" />
|
||||
<Import Project="..\packages\Microsoft.Testing.Platform.MSBuild.1.8.3\build\Microsoft.Testing.Platform.MSBuild.targets" Condition="Exists('..\packages\Microsoft.Testing.Platform.MSBuild.1.8.3\build\Microsoft.Testing.Platform.MSBuild.targets')" />
|
||||
<Import Project="..\packages\MSTest.TestAdapter.3.10.3\build\net462\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.3.10.3\build\net462\MSTest.TestAdapter.targets')" />
|
||||
<Import Project="..\packages\MSTest.TestFramework.3.10.3\build\net462\MSTest.TestFramework.targets" Condition="Exists('..\packages\MSTest.TestFramework.3.10.3\build\net462\MSTest.TestFramework.targets')" />
|
||||
</Project>
|
@@ -4,7 +4,7 @@
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.4.0" newVersion="4.2.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
@@ -12,7 +12,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.1.0" newVersion="6.0.1.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.3.0" newVersion="6.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Win32.Registry" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
@@ -28,27 +28,27 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.1" newVersion="9.0.0.1" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.8" newVersion="9.0.0.8" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.ApplicationInsights" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.22.0.997" newVersion="2.22.0.997" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.23.0.29" newVersion="2.23.0.29" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.1" newVersion="9.0.0.1" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.8" newVersion="9.0.0.8" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.1" newVersion="9.0.0.1" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.8" newVersion="9.0.0.8" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
@@ -1,25 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Castle.Core" version="5.1.1" targetFramework="net48" />
|
||||
<package id="Microsoft.ApplicationInsights" version="2.22.0" targetFramework="net48" />
|
||||
<package id="Microsoft.Testing.Extensions.Telemetry" version="1.5.2" targetFramework="net48" />
|
||||
<package id="Microsoft.Testing.Extensions.TrxReport.Abstractions" version="1.5.2" targetFramework="net48" />
|
||||
<package id="Microsoft.Testing.Extensions.VSTestBridge" version="1.5.2" targetFramework="net48" />
|
||||
<package id="Microsoft.Testing.Platform" version="1.5.2" targetFramework="net48" />
|
||||
<package id="Microsoft.Testing.Platform.MSBuild" version="1.5.2" targetFramework="net48" />
|
||||
<package id="Microsoft.TestPlatform.ObjectModel" version="17.12.0" targetFramework="net48" />
|
||||
<package id="Castle.Core" version="5.2.1" targetFramework="net48" />
|
||||
<package id="Microsoft.ApplicationInsights" version="2.23.0" targetFramework="net48" />
|
||||
<package id="Microsoft.Testing.Extensions.Telemetry" version="1.8.3" targetFramework="net48" />
|
||||
<package id="Microsoft.Testing.Extensions.TrxReport.Abstractions" version="1.8.3" targetFramework="net48" />
|
||||
<package id="Microsoft.Testing.Extensions.VSTestBridge" version="1.8.3" targetFramework="net48" />
|
||||
<package id="Microsoft.Testing.Platform" version="1.8.3" targetFramework="net48" />
|
||||
<package id="Microsoft.Testing.Platform.MSBuild" version="1.8.3" targetFramework="net48" />
|
||||
<package id="Microsoft.TestPlatform.AdapterUtilities" version="17.14.1" targetFramework="net48" />
|
||||
<package id="Microsoft.TestPlatform.ObjectModel" version="17.14.1" targetFramework="net48" />
|
||||
<package id="Moq" version="4.20.72" targetFramework="net48" />
|
||||
<package id="MSTest.Analyzers" version="3.7.2" targetFramework="net48" developmentDependency="true" />
|
||||
<package id="MSTest.TestAdapter" version="3.7.2" targetFramework="net48" />
|
||||
<package id="MSTest.TestFramework" version="3.7.2" targetFramework="net48" />
|
||||
<package id="NuGet.Frameworks" version="6.12.1" targetFramework="net48" />
|
||||
<package id="System.Buffers" version="4.6.0" targetFramework="net48" />
|
||||
<package id="System.Collections.Immutable" version="9.0.1" targetFramework="net48" />
|
||||
<package id="System.Diagnostics.DiagnosticSource" version="9.0.1" targetFramework="net48" />
|
||||
<package id="System.Memory" version="4.6.0" targetFramework="net48" />
|
||||
<package id="System.Numerics.Vectors" version="4.6.0" targetFramework="net48" />
|
||||
<package id="System.Reflection.Metadata" version="9.0.1" targetFramework="net48" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.1.0" targetFramework="net48" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.6.0" targetFramework="net48" />
|
||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
|
||||
<package id="MSTest.Analyzers" version="3.10.3" targetFramework="net48" developmentDependency="true" />
|
||||
<package id="MSTest.TestAdapter" version="3.10.3" targetFramework="net48" />
|
||||
<package id="MSTest.TestFramework" version="3.10.3" targetFramework="net48" />
|
||||
<package id="NuGet.Frameworks" version="6.14.0" targetFramework="net48" />
|
||||
<package id="System.Buffers" version="4.6.1" targetFramework="net48" />
|
||||
<package id="System.Collections.Immutable" version="9.0.8" targetFramework="net48" />
|
||||
<package id="System.Diagnostics.DiagnosticSource" version="9.0.8" targetFramework="net48" />
|
||||
<package id="System.Memory" version="4.6.3" targetFramework="net48" />
|
||||
<package id="System.Numerics.Vectors" version="4.6.1" targetFramework="net48" />
|
||||
<package id="System.Reflection.Metadata" version="9.0.8" targetFramework="net48" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.1.2" targetFramework="net48" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.6.3" targetFramework="net48" />
|
||||
<package id="System.ValueTuple" version="4.6.1" targetFramework="net48" />
|
||||
</packages>
|
Reference in New Issue
Block a user