2017-10-11 11:46:39 +02:00
|
|
|
|
/*
|
2019-01-09 11:25:21 +01:00
|
|
|
|
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
2017-10-11 11:46:39 +02:00
|
|
|
|
*
|
|
|
|
|
* 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 Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
using Moq;
|
2019-10-01 16:24:10 +02:00
|
|
|
|
using SafeExamBrowser.Browser.Contracts;
|
2018-08-31 10:06:27 +02:00
|
|
|
|
using SafeExamBrowser.Client.Operations;
|
2019-08-30 09:55:26 +02:00
|
|
|
|
using SafeExamBrowser.Logging.Contracts;
|
|
|
|
|
using SafeExamBrowser.UserInterface.Contracts;
|
|
|
|
|
using SafeExamBrowser.UserInterface.Contracts.Shell;
|
2017-10-11 11:46:39 +02:00
|
|
|
|
|
2018-08-31 10:06:27 +02:00
|
|
|
|
namespace SafeExamBrowser.Client.UnitTests.Operations
|
2017-10-11 11:46:39 +02:00
|
|
|
|
{
|
|
|
|
|
[TestClass]
|
|
|
|
|
public class BrowserOperationTests
|
|
|
|
|
{
|
2019-03-08 11:43:52 +01:00
|
|
|
|
private Mock<IActionCenter> actionCenter;
|
2019-10-01 16:24:10 +02:00
|
|
|
|
private Mock<IBrowserApplication> browser;
|
|
|
|
|
private ClientContext context;
|
2019-03-08 11:43:52 +01:00
|
|
|
|
private Mock<ILogger> logger;
|
|
|
|
|
private Mock<ITaskbar> taskbar;
|
|
|
|
|
private Mock<IUserInterfaceFactory> uiFactory;
|
2017-10-11 11:46:39 +02:00
|
|
|
|
|
|
|
|
|
private BrowserOperation sut;
|
|
|
|
|
|
|
|
|
|
[TestInitialize]
|
|
|
|
|
public void Initialize()
|
|
|
|
|
{
|
2019-03-08 11:43:52 +01:00
|
|
|
|
actionCenter = new Mock<IActionCenter>();
|
2019-10-01 16:24:10 +02:00
|
|
|
|
browser = new Mock<IBrowserApplication>();
|
|
|
|
|
context = new ClientContext();
|
2019-03-08 11:43:52 +01:00
|
|
|
|
logger = new Mock<ILogger>();
|
|
|
|
|
taskbar = new Mock<ITaskbar>();
|
|
|
|
|
uiFactory = new Mock<IUserInterfaceFactory>();
|
2017-10-11 11:46:39 +02:00
|
|
|
|
|
2019-10-01 16:24:10 +02:00
|
|
|
|
context.Browser = browser.Object;
|
|
|
|
|
|
|
|
|
|
sut = new BrowserOperation(actionCenter.Object, context, logger.Object, taskbar.Object, uiFactory.Object);
|
2017-10-11 11:46:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void MustPeformCorrectly()
|
|
|
|
|
{
|
|
|
|
|
sut.Perform();
|
|
|
|
|
|
2019-10-01 16:24:10 +02:00
|
|
|
|
browser.Verify(c => c.Initialize(), Times.Once);
|
2019-03-08 15:56:38 +01:00
|
|
|
|
actionCenter.Verify(a => a.AddApplicationControl(It.IsAny<IApplicationControl>()), Times.Once);
|
2019-03-08 11:43:52 +01:00
|
|
|
|
taskbar.Verify(t => t.AddApplicationControl(It.IsAny<IApplicationControl>()), Times.Once);
|
2017-10-11 11:46:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void MustRevertCorrectly()
|
|
|
|
|
{
|
|
|
|
|
sut.Revert();
|
2019-10-01 16:24:10 +02:00
|
|
|
|
browser.Verify(c => c.Terminate(), Times.Once);
|
2017-10-11 11:46:39 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|