Fixed verification of event handler subscriptions in unit tests.

This commit is contained in:
Damian Büchel 2020-12-04 16:17:13 +01:00
parent b1997b5b56
commit 86242911a2
2 changed files with 6 additions and 0 deletions

View file

@ -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<CommunicationEventHandler>());
clientHost.VerifyRemove(h => h.RuntimeDisconnected -= It.IsAny<CommunicationEventHandler>());
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<CommunicationEventHandler>());
clientHost.VerifyRemove(h => h.RuntimeDisconnected -= It.IsAny<CommunicationEventHandler>());
clientHost.VerifyNoOtherCalls();
Assert.IsTrue(after - before >= new TimeSpan(0, 0, 0, 0, timeout_ms));

View file

@ -309,6 +309,7 @@ namespace SafeExamBrowser.Runtime.UnitTests
It.Is<MessageBoxAction>(a => a == MessageBoxAction.Confirm),
It.Is<MessageBoxIcon>(i => i == args.Icon),
It.IsAny<IWindow>()), Times.Once);
clientProxy.VerifyAdd(p => p.ConnectionLost += It.IsAny<CommunicationEventHandler>());
clientProxy.VerifyNoOtherCalls();
}