From 29b99d8830fadbe302c20e858dadfdf798225590 Mon Sep 17 00:00:00 2001 From: dbuechel Date: Wed, 6 Mar 2019 16:16:50 +0100 Subject: [PATCH] SEBWIN-141: Fixed unit tests for new taskbar configuration and shutdown procedure. --- .../ClientControllerTests.cs | 31 ++++++------------- .../Operations/TaskbarOperationTests.cs | 1 + 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/SafeExamBrowser.Client.UnitTests/ClientControllerTests.cs b/SafeExamBrowser.Client.UnitTests/ClientControllerTests.cs index 02ffd4e5..df732729 100644 --- a/SafeExamBrowser.Client.UnitTests/ClientControllerTests.cs +++ b/SafeExamBrowser.Client.UnitTests/ClientControllerTests.cs @@ -179,33 +179,15 @@ namespace SafeExamBrowser.Client.UnitTests [TestMethod] public void Communication_MustCorrectlyInitiateShutdown() { - var order = 0; - var taskbarCall = 0; - var shutdownCall = 0; - - taskbar.Setup(t => t.Close()).Callback(() => taskbarCall = ++order); - shutdown.Setup(s => s()).Callback(() => shutdownCall = ++order); - sut.TryStart(); clientHost.Raise(c => c.Shutdown += null); - taskbar.Verify(t => t.Close(), Times.Once); shutdown.Verify(s => s(), Times.Once); - - Assert.AreEqual(1, taskbarCall); - Assert.AreEqual(2, shutdownCall); } [TestMethod] public void Communication_MustShutdownOnLostConnection() { - var order = 0; - var taskbarCall = 0; - var shutdownCall = 0; - - taskbar.Setup(t => t.Close()).Callback(() => taskbarCall = ++order); - shutdown.Setup(s => s()).Callback(() => shutdownCall = ++order); - sut.TryStart(); runtimeProxy.Raise(p => p.ConnectionLost += null); @@ -215,11 +197,7 @@ namespace SafeExamBrowser.Client.UnitTests It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); - taskbar.Verify(t => t.Close(), Times.Once); shutdown.Verify(s => s(), Times.Once); - - Assert.AreEqual(1, taskbarCall); - Assert.AreEqual(2, shutdownCall); } [TestMethod] @@ -489,6 +467,14 @@ namespace SafeExamBrowser.Client.UnitTests Assert.IsTrue(args.Cancel); } + [TestMethod] + public void Shutdown_MustCloseActionCenterAndTaskbar() + { + sut.Terminate(); + actionCenter.Verify(a => a.Close(), Times.Once); + taskbar.Verify(o => o.Close(), Times.Once); + } + [TestMethod] public void Shutdown_MustShowErrorMessageOnCommunicationFailure() { @@ -638,6 +624,7 @@ namespace SafeExamBrowser.Client.UnitTests [TestMethod] public void Startup_MustCorrectlyHandleTaskbar() { + settings.Taskbar.EnableTaskbar = true; operationSequence.Setup(o => o.TryPerform()).Returns(OperationResult.Success); sut.TryStart(); diff --git a/SafeExamBrowser.Client.UnitTests/Operations/TaskbarOperationTests.cs b/SafeExamBrowser.Client.UnitTests/Operations/TaskbarOperationTests.cs index 24ba16a2..61f5df9f 100644 --- a/SafeExamBrowser.Client.UnitTests/Operations/TaskbarOperationTests.cs +++ b/SafeExamBrowser.Client.UnitTests/Operations/TaskbarOperationTests.cs @@ -56,6 +56,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations settings.AllowApplicationLog = true; settings.AllowKeyboardLayout = true; settings.AllowWirelessNetwork = true; + settings.EnableTaskbar = true; systemInfoMock.SetupGet(s => s.HasBattery).Returns(true); uiFactoryMock.Setup(u => u.CreateNotification(It.IsAny())).Returns(new Mock().Object);