/* * Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET) * * 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; using SafeExamBrowser.Client.Operations; using SafeExamBrowser.Contracts.Applications; using SafeExamBrowser.Contracts.Logging; using SafeExamBrowser.Contracts.UserInterface; using SafeExamBrowser.Contracts.UserInterface.Shell; namespace SafeExamBrowser.Client.UnitTests.Operations { [TestClass] public class BrowserOperationTests { private Mock actionCenter; private Mock controller; private Mock appInfo; private Mock logger; private Mock taskbar; private Mock uiFactory; private BrowserOperation sut; [TestInitialize] public void Initialize() { actionCenter = new Mock(); controller = new Mock(); appInfo = new Mock(); logger = new Mock(); taskbar = new Mock(); uiFactory = new Mock(); sut = new BrowserOperation(actionCenter.Object, controller.Object, appInfo.Object, logger.Object, taskbar.Object, uiFactory.Object); } [TestMethod] public void MustPeformCorrectly() { var order = 0; controller.Setup(c => c.Initialize()).Callback(() => Assert.AreEqual(++order, 1)); controller.Setup(c => c.RegisterApplicationControl(It.IsAny())).Callback(() => Assert.AreEqual(++order, 2)); taskbar.Setup(t => t.AddApplicationControl(It.IsAny())).Callback(() => Assert.AreEqual(++order, 3)); sut.Perform(); controller.Verify(c => c.Initialize(), Times.Once); controller.Verify(c => c.RegisterApplicationControl(It.IsAny()), Times.Once); taskbar.Verify(t => t.AddApplicationControl(It.IsAny()), Times.Once); } [TestMethod] public void MustRevertCorrectly() { sut.Revert(); controller.Verify(c => c.Terminate(), Times.Once); } } }