/* * Copyright (c) 2018 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 System; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using SafeExamBrowser.Contracts.Communication.Hosts; using SafeExamBrowser.Contracts.Communication.Proxies; using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.Logging; using SafeExamBrowser.Contracts.WindowsApi; using SafeExamBrowser.Runtime.Operations; namespace SafeExamBrowser.Runtime.UnitTests.Operations { [TestClass] public class ClientTerminationOperationTests { private Action clientReady; private AppConfig appConfig; private Mock configuration; private Mock proxy; private Mock logger; private Mock process; private Mock processFactory; private Mock proxyFactory; private Mock runtimeHost; private Mock session; private ClientTerminationOperation sut; [TestInitialize] public void Initialize() { appConfig = new AppConfig(); configuration = new Mock(); clientReady = new Action(() => runtimeHost.Raise(h => h.ClientReady += null)); logger = new Mock(); process = new Mock(); processFactory = new Mock(); proxy = new Mock(); proxyFactory = new Mock(); runtimeHost = new Mock(); session = new Mock(); configuration.SetupGet(c => c.CurrentSession).Returns(session.Object); configuration.SetupGet(c => c.AppConfig).Returns(appConfig); proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny())).Returns(proxy.Object); sut = new ClientTerminationOperation(configuration.Object, logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, 0); } [TestMethod] public void MustDoNothingOnPerform() { sut.Perform(); processFactory.VerifyNoOtherCalls(); proxy.VerifyNoOtherCalls(); proxyFactory.VerifyNoOtherCalls(); } [TestMethod] public void MustDoNothingOnRevert() { sut.Revert(); process.VerifyNoOtherCalls(); proxy.VerifyNoOtherCalls(); runtimeHost.VerifyNoOtherCalls(); } [TestMethod] public void TODO() { // TODO: MustStartClientOnRepeat -> Extract static fields from operation -> allows unit testing of this requirement etc.! Assert.Fail(); } } }