From 86242911a236f6445de2a0bec4fb2b94f8c8ce7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20B=C3=BCchel?= Date: Fri, 4 Dec 2020 16:17:13 +0100 Subject: [PATCH] Fixed verification of event handler subscriptions in unit tests. --- .../Operations/ClientHostDisconnectionOperationTests.cs | 5 +++++ SafeExamBrowser.Runtime.UnitTests/RuntimeControllerTests.cs | 1 + 2 files changed, 6 insertions(+) diff --git a/SafeExamBrowser.Client.UnitTests/Operations/ClientHostDisconnectionOperationTests.cs b/SafeExamBrowser.Client.UnitTests/Operations/ClientHostDisconnectionOperationTests.cs index 4e4378fa..9d83e115 100644 --- a/SafeExamBrowser.Client.UnitTests/Operations/ClientHostDisconnectionOperationTests.cs +++ b/SafeExamBrowser.Client.UnitTests/Operations/ClientHostDisconnectionOperationTests.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using SafeExamBrowser.Client.Operations; +using SafeExamBrowser.Communication.Contracts.Events; using SafeExamBrowser.Communication.Contracts.Hosts; using SafeExamBrowser.Core.Contracts.OperationModel; using SafeExamBrowser.Logging.Contracts; @@ -57,6 +58,8 @@ namespace SafeExamBrowser.Client.UnitTests.Operations after = DateTime.Now; clientHost.VerifyGet(h => h.IsConnected); + clientHost.VerifyAdd(h => h.RuntimeDisconnected += It.IsAny()); + clientHost.VerifyRemove(h => h.RuntimeDisconnected -= It.IsAny()); clientHost.VerifyNoOtherCalls(); Assert.IsTrue(after - before < new TimeSpan(0, 0, 0, 0, timeout_ms)); @@ -78,6 +81,8 @@ namespace SafeExamBrowser.Client.UnitTests.Operations after = DateTime.Now; clientHost.VerifyGet(h => h.IsConnected); + clientHost.VerifyAdd(h => h.RuntimeDisconnected += It.IsAny()); + clientHost.VerifyRemove(h => h.RuntimeDisconnected -= It.IsAny()); clientHost.VerifyNoOtherCalls(); Assert.IsTrue(after - before >= new TimeSpan(0, 0, 0, 0, timeout_ms)); diff --git a/SafeExamBrowser.Runtime.UnitTests/RuntimeControllerTests.cs b/SafeExamBrowser.Runtime.UnitTests/RuntimeControllerTests.cs index d0b603f6..16ff57b7 100644 --- a/SafeExamBrowser.Runtime.UnitTests/RuntimeControllerTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/RuntimeControllerTests.cs @@ -309,6 +309,7 @@ namespace SafeExamBrowser.Runtime.UnitTests It.Is(a => a == MessageBoxAction.Confirm), It.Is(i => i == args.Icon), It.IsAny()), Times.Once); + clientProxy.VerifyAdd(p => p.ConnectionLost += It.IsAny()); clientProxy.VerifyNoOtherCalls(); }