SEBWIN-219: Fixed broken unit tests.
This commit is contained in:
parent
d3dea29ecd
commit
24c5ea3ba9
5 changed files with 64 additions and 58 deletions
|
@ -23,7 +23,7 @@ namespace SafeExamBrowser.Client.UnitTests.Behaviour.Operations
|
|||
public class TaskbarOperationTests
|
||||
{
|
||||
private Mock<ILogger> loggerMock;
|
||||
private Mock<TaskbarSettings> settingsMock;
|
||||
private TaskbarSettings settings;
|
||||
private Mock<ISystemComponent<ISystemKeyboardLayoutControl>> keyboardLayoutMock;
|
||||
private Mock<ISystemComponent<ISystemPowerSupplyControl>> powerSupplyMock;
|
||||
private Mock<ISystemComponent<ISystemWirelessNetworkControl>> wirelessNetworkMock;
|
||||
|
@ -38,7 +38,7 @@ namespace SafeExamBrowser.Client.UnitTests.Behaviour.Operations
|
|||
public void Initialize()
|
||||
{
|
||||
loggerMock = new Mock<ILogger>();
|
||||
settingsMock = new Mock<TaskbarSettings>();
|
||||
settings = new TaskbarSettings();
|
||||
keyboardLayoutMock = new Mock<ISystemComponent<ISystemKeyboardLayoutControl>>();
|
||||
powerSupplyMock = new Mock<ISystemComponent<ISystemPowerSupplyControl>>();
|
||||
wirelessNetworkMock = new Mock<ISystemComponent<ISystemWirelessNetworkControl>>();
|
||||
|
@ -47,15 +47,15 @@ namespace SafeExamBrowser.Client.UnitTests.Behaviour.Operations
|
|||
textMock = new Mock<IText>();
|
||||
uiFactoryMock = new Mock<IUserInterfaceFactory>();
|
||||
|
||||
settingsMock.SetupGet(s => s.AllowApplicationLog).Returns(true);
|
||||
settingsMock.SetupGet(s => s.AllowKeyboardLayout).Returns(true);
|
||||
settingsMock.SetupGet(s => s.AllowWirelessNetwork).Returns(true);
|
||||
settings.AllowApplicationLog = true;
|
||||
settings.AllowKeyboardLayout = true;
|
||||
settings.AllowWirelessNetwork = true;
|
||||
systemInfoMock.SetupGet(s => s.HasBattery).Returns(true);
|
||||
uiFactoryMock.Setup(u => u.CreateNotification(It.IsAny<INotificationInfo>())).Returns(new Mock<INotificationButton>().Object);
|
||||
|
||||
sut = new TaskbarOperation(
|
||||
loggerMock.Object,
|
||||
settingsMock.Object,
|
||||
settings,
|
||||
keyboardLayoutMock.Object,
|
||||
powerSupplyMock.Object,
|
||||
wirelessNetworkMock.Object,
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using SafeExamBrowser.Contracts.Behaviour;
|
||||
using SafeExamBrowser.Client.Behaviour;
|
||||
using SafeExamBrowser.Contracts.Behaviour.Operations;
|
||||
using SafeExamBrowser.Contracts.Communication;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.Monitoring;
|
||||
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
||||
|
@ -22,10 +24,12 @@ namespace SafeExamBrowser.Client.UnitTests
|
|||
private Mock<IDisplayMonitor> displayMonitorMock;
|
||||
private Mock<ILogger> loggerMock;
|
||||
private Mock<IProcessMonitor> processMonitorMock;
|
||||
private Mock<IOperationSequence> operationSequenceMock;
|
||||
private Mock<IRuntimeProxy> runtimeProxyMock;
|
||||
private Mock<ITaskbar> taskbarMock;
|
||||
private Mock<IWindowMonitor> windowMonitorMock;
|
||||
|
||||
//private IClientController sut;
|
||||
private ClientController sut;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
|
@ -33,19 +37,23 @@ namespace SafeExamBrowser.Client.UnitTests
|
|||
displayMonitorMock = new Mock<IDisplayMonitor>();
|
||||
loggerMock = new Mock<ILogger>();
|
||||
processMonitorMock = new Mock<IProcessMonitor>();
|
||||
operationSequenceMock = new Mock<IOperationSequence>();
|
||||
runtimeProxyMock = new Mock<IRuntimeProxy>();
|
||||
taskbarMock = new Mock<ITaskbar>();
|
||||
windowMonitorMock= new Mock<IWindowMonitor>();
|
||||
|
||||
// TODO
|
||||
operationSequenceMock.Setup(o => o.TryPerform()).Returns(true);
|
||||
|
||||
//sut = new ClientController(
|
||||
// displayMonitorMock.Object,
|
||||
// loggerMock.Object,
|
||||
// processMonitorMock.Object,
|
||||
// taskbarMock.Object,
|
||||
// windowMonitorMock.Object);
|
||||
sut = new ClientController(
|
||||
displayMonitorMock.Object,
|
||||
loggerMock.Object,
|
||||
operationSequenceMock.Object,
|
||||
processMonitorMock.Object,
|
||||
runtimeProxyMock.Object,
|
||||
taskbarMock.Object,
|
||||
windowMonitorMock.Object);
|
||||
|
||||
// sut.Start();
|
||||
sut.TryStart();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace SafeExamBrowser.Core.UnitTests.Behaviour.Operations
|
|||
public class DelayedInitializationOperationTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void Todo()
|
||||
public void TODO()
|
||||
{
|
||||
Assert.Fail();
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
public class ConfigurationOperationTests
|
||||
{
|
||||
private Mock<ILogger> logger;
|
||||
private Mock<RuntimeInfo> info;
|
||||
private RuntimeInfo info;
|
||||
private Mock<IConfigurationRepository> repository;
|
||||
private Mock<Settings> settings;
|
||||
private Settings settings;
|
||||
private Mock<IText> text;
|
||||
private Mock<IUserInterfaceFactory> uiFactory;
|
||||
private ConfigurationOperation sut;
|
||||
|
@ -34,17 +34,17 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
public void Initialize()
|
||||
{
|
||||
logger = new Mock<ILogger>();
|
||||
info = new Mock<RuntimeInfo>();
|
||||
info = new RuntimeInfo();
|
||||
repository = new Mock<IConfigurationRepository>();
|
||||
settings = new Mock<Settings>();
|
||||
settings = new Settings();
|
||||
text = new Mock<IText>();
|
||||
uiFactory = new Mock<IUserInterfaceFactory>();
|
||||
|
||||
info.SetupGet(i => i.AppDataFolder).Returns(@"C:\Not\Really\AppData");
|
||||
info.SetupGet(i => i.DefaultSettingsFileName).Returns("SettingsDummy.txt");
|
||||
info.SetupGet(i => i.ProgramDataFolder).Returns(@"C:\Not\Really\ProgramData");
|
||||
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>())).Returns(settings.Object);
|
||||
repository.Setup(r => r.LoadDefaultSettings()).Returns(settings.Object);
|
||||
info.AppDataFolder = @"C:\Not\Really\AppData";
|
||||
info.DefaultSettingsFileName = "SettingsDummy.txt";
|
||||
info.ProgramDataFolder = @"C:\Not\Really\ProgramData";
|
||||
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>())).Returns(settings);
|
||||
repository.Setup(r => r.LoadDefaultSettings()).Returns(settings);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@ -52,11 +52,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
{
|
||||
repository.Setup(r => r.LoadDefaultSettings());
|
||||
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info.Object, text.Object, uiFactory.Object, null);
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, null);
|
||||
|
||||
sut.Perform();
|
||||
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info.Object, text.Object, uiFactory.Object, new string[] { });
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, new string[] { });
|
||||
|
||||
sut.Perform();
|
||||
|
||||
|
@ -68,7 +68,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
{
|
||||
var path = @"an/invalid\path.'*%yolo/()";
|
||||
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info.Object, text.Object, uiFactory.Object, new [] { "blubb.exe", path });
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, new [] { "blubb.exe", path });
|
||||
|
||||
sut.Perform();
|
||||
}
|
||||
|
@ -79,10 +79,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
var path = @"http://www.safeexambrowser.org/whatever.seb";
|
||||
var location = Path.GetDirectoryName(GetType().Assembly.Location);
|
||||
|
||||
info.SetupGet(r => r.ProgramDataFolder).Returns(location);
|
||||
info.SetupGet(r => r.AppDataFolder).Returns(location);
|
||||
info.ProgramDataFolder = location;
|
||||
info.AppDataFolder = location;
|
||||
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", path });
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, new[] { "blubb.exe", path });
|
||||
|
||||
sut.Perform();
|
||||
|
||||
|
@ -94,10 +94,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
{
|
||||
var location = Path.GetDirectoryName(GetType().Assembly.Location);
|
||||
|
||||
info.SetupGet(r => r.ProgramDataFolder).Returns(location);
|
||||
info.SetupGet(r => r.AppDataFolder).Returns($@"{location}\WRONG");
|
||||
info.ProgramDataFolder = location;
|
||||
info.AppDataFolder = $@"{location}\WRONG";
|
||||
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info.Object, text.Object, uiFactory.Object, null);
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, null);
|
||||
|
||||
sut.Perform();
|
||||
|
||||
|
@ -109,9 +109,9 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
{
|
||||
var location = Path.GetDirectoryName(GetType().Assembly.Location);
|
||||
|
||||
info.SetupGet(r => r.AppDataFolder).Returns(location);
|
||||
info.AppDataFolder = location;
|
||||
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info.Object, text.Object, uiFactory.Object, null);
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, null);
|
||||
|
||||
sut.Perform();
|
||||
|
||||
|
@ -121,7 +121,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
[TestMethod]
|
||||
public void MustFallbackToDefaultsAsLastPrio()
|
||||
{
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info.Object, text.Object, uiFactory.Object, null);
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, null);
|
||||
|
||||
sut.Perform();
|
||||
|
||||
|
@ -131,12 +131,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
[TestMethod]
|
||||
public void MustAbortIfWishedByUser()
|
||||
{
|
||||
var location = Path.GetDirectoryName(GetType().Assembly.Location);
|
||||
|
||||
info.SetupGet(r => r.ProgramDataFolder).Returns(location);
|
||||
info.ProgramDataFolder = Path.GetDirectoryName(GetType().Assembly.Location);
|
||||
uiFactory.Setup(u => u.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>())).Returns(MessageBoxResult.Yes);
|
||||
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info.Object, text.Object, uiFactory.Object, null);
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, null);
|
||||
|
||||
sut.Perform();
|
||||
|
||||
|
@ -148,7 +146,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
{
|
||||
uiFactory.Setup(u => u.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>())).Returns(MessageBoxResult.No);
|
||||
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info.Object, text.Object, uiFactory.Object, null);
|
||||
sut = new ConfigurationOperation(repository.Object, logger.Object, info, text.Object, uiFactory.Object, null);
|
||||
|
||||
sut.Perform();
|
||||
|
||||
|
|
|
@ -45,12 +45,12 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
public void MustConnectToService()
|
||||
{
|
||||
service.Setup(s => s.Connect(null)).Returns(true);
|
||||
configuration.SetupGet(s => s.CurrentSettings.ServicePolicy).Returns(ServicePolicy.Mandatory);
|
||||
configuration.SetupGet(s => s.CurrentSettings).Returns(new Settings { ServicePolicy = ServicePolicy.Mandatory });
|
||||
|
||||
sut.Perform();
|
||||
|
||||
service.Setup(s => s.Connect(null)).Returns(true);
|
||||
configuration.SetupGet(s => s.CurrentSettings.ServicePolicy).Returns(ServicePolicy.Optional);
|
||||
configuration.SetupGet(s => s.CurrentSettings).Returns(new Settings { ServicePolicy = ServicePolicy.Optional });
|
||||
|
||||
sut.Perform();
|
||||
|
||||
|
@ -61,22 +61,22 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
public void MustNotFailIfServiceNotAvailable()
|
||||
{
|
||||
service.Setup(s => s.Connect(null)).Returns(false);
|
||||
configuration.SetupGet(s => s.CurrentSettings.ServicePolicy).Returns(ServicePolicy.Mandatory);
|
||||
configuration.SetupGet(s => s.CurrentSettings).Returns(new Settings { ServicePolicy = ServicePolicy.Mandatory });
|
||||
|
||||
sut.Perform();
|
||||
|
||||
service.Setup(s => s.Connect(null)).Returns(false);
|
||||
configuration.SetupGet(s => s.CurrentSettings.ServicePolicy).Returns(ServicePolicy.Optional);
|
||||
configuration.SetupGet(s => s.CurrentSettings).Returns(new Settings { ServicePolicy = ServicePolicy.Optional });
|
||||
|
||||
sut.Perform();
|
||||
|
||||
service.Setup(s => s.Connect(null)).Throws<Exception>();
|
||||
configuration.SetupGet(s => s.CurrentSettings.ServicePolicy).Returns(ServicePolicy.Mandatory);
|
||||
configuration.SetupGet(s => s.CurrentSettings).Returns(new Settings { ServicePolicy = ServicePolicy.Mandatory });
|
||||
|
||||
sut.Perform();
|
||||
|
||||
service.Setup(s => s.Connect(null)).Throws<Exception>();
|
||||
configuration.SetupGet(s => s.CurrentSettings.ServicePolicy).Returns(ServicePolicy.Optional);
|
||||
configuration.SetupGet(s => s.CurrentSettings).Returns(new Settings { ServicePolicy = ServicePolicy.Optional });
|
||||
|
||||
sut.Perform();
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
public void MustAbortIfServiceMandatoryAndNotAvailable()
|
||||
{
|
||||
service.Setup(s => s.Connect(null)).Returns(false);
|
||||
configuration.SetupGet(s => s.CurrentSettings.ServicePolicy).Returns(ServicePolicy.Mandatory);
|
||||
configuration.SetupGet(s => s.CurrentSettings).Returns(new Settings { ServicePolicy = ServicePolicy.Mandatory });
|
||||
|
||||
sut.Perform();
|
||||
|
||||
|
@ -96,7 +96,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
public void MustNotAbortIfServiceOptionalAndNotAvailable()
|
||||
{
|
||||
service.Setup(s => s.Connect(null)).Returns(false);
|
||||
configuration.SetupGet(s => s.CurrentSettings.ServicePolicy).Returns(ServicePolicy.Optional);
|
||||
configuration.SetupGet(s => s.CurrentSettings).Returns(new Settings { ServicePolicy = ServicePolicy.Optional });
|
||||
|
||||
sut.Perform();
|
||||
|
||||
|
@ -108,13 +108,13 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
public void MustDisconnectWhenReverting()
|
||||
{
|
||||
service.Setup(s => s.Connect(null)).Returns(true);
|
||||
configuration.SetupGet(s => s.CurrentSettings.ServicePolicy).Returns(ServicePolicy.Mandatory);
|
||||
configuration.SetupGet(s => s.CurrentSettings).Returns(new Settings { ServicePolicy = ServicePolicy.Mandatory });
|
||||
|
||||
sut.Perform();
|
||||
sut.Revert();
|
||||
|
||||
service.Setup(s => s.Connect(null)).Returns(true);
|
||||
configuration.SetupGet(s => s.CurrentSettings.ServicePolicy).Returns(ServicePolicy.Optional);
|
||||
configuration.SetupGet(s => s.CurrentSettings).Returns(new Settings { ServicePolicy = ServicePolicy.Optional });
|
||||
|
||||
sut.Perform();
|
||||
sut.Revert();
|
||||
|
@ -127,7 +127,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
{
|
||||
service.Setup(s => s.Connect(null)).Returns(true);
|
||||
service.Setup(s => s.Disconnect()).Throws<Exception>();
|
||||
configuration.SetupGet(s => s.CurrentSettings.ServicePolicy).Returns(ServicePolicy.Optional);
|
||||
configuration.SetupGet(s => s.CurrentSettings).Returns(new Settings { ServicePolicy = ServicePolicy.Optional });
|
||||
|
||||
sut.Perform();
|
||||
sut.Revert();
|
||||
|
@ -139,25 +139,25 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
|
|||
public void MustNotDisconnnectIfNotAvailable()
|
||||
{
|
||||
service.Setup(s => s.Connect(null)).Returns(false);
|
||||
configuration.SetupGet(s => s.CurrentSettings.ServicePolicy).Returns(ServicePolicy.Mandatory);
|
||||
configuration.SetupGet(s => s.CurrentSettings).Returns(new Settings { ServicePolicy = ServicePolicy.Mandatory });
|
||||
|
||||
sut.Perform();
|
||||
sut.Revert();
|
||||
|
||||
service.Setup(s => s.Connect(null)).Returns(false);
|
||||
configuration.SetupGet(s => s.CurrentSettings.ServicePolicy).Returns(ServicePolicy.Optional);
|
||||
configuration.SetupGet(s => s.CurrentSettings).Returns(new Settings { ServicePolicy = ServicePolicy.Optional });
|
||||
|
||||
sut.Perform();
|
||||
sut.Revert();
|
||||
|
||||
service.Setup(s => s.Connect(null)).Throws<Exception>();
|
||||
configuration.SetupGet(s => s.CurrentSettings.ServicePolicy).Returns(ServicePolicy.Mandatory);
|
||||
configuration.SetupGet(s => s.CurrentSettings).Returns(new Settings { ServicePolicy = ServicePolicy.Mandatory });
|
||||
|
||||
sut.Perform();
|
||||
sut.Revert();
|
||||
|
||||
service.Setup(s => s.Connect(null)).Throws<Exception>();
|
||||
configuration.SetupGet(s => s.CurrentSettings.ServicePolicy).Returns(ServicePolicy.Optional);
|
||||
configuration.SetupGet(s => s.CurrentSettings).Returns(new Settings { ServicePolicy = ServicePolicy.Optional });
|
||||
|
||||
sut.Perform();
|
||||
sut.Revert();
|
||||
|
|
Loading…
Reference in a new issue