Fixed verification of event handler subscriptions in unit tests.
This commit is contained in:
parent
b1997b5b56
commit
86242911a2
2 changed files with 6 additions and 0 deletions
|
@ -11,6 +11,7 @@ using System.Threading.Tasks;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using Moq;
|
||||||
using SafeExamBrowser.Client.Operations;
|
using SafeExamBrowser.Client.Operations;
|
||||||
|
using SafeExamBrowser.Communication.Contracts.Events;
|
||||||
using SafeExamBrowser.Communication.Contracts.Hosts;
|
using SafeExamBrowser.Communication.Contracts.Hosts;
|
||||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||||
using SafeExamBrowser.Logging.Contracts;
|
using SafeExamBrowser.Logging.Contracts;
|
||||||
|
@ -57,6 +58,8 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
after = DateTime.Now;
|
after = DateTime.Now;
|
||||||
|
|
||||||
clientHost.VerifyGet(h => h.IsConnected);
|
clientHost.VerifyGet(h => h.IsConnected);
|
||||||
|
clientHost.VerifyAdd(h => h.RuntimeDisconnected += It.IsAny<CommunicationEventHandler>());
|
||||||
|
clientHost.VerifyRemove(h => h.RuntimeDisconnected -= It.IsAny<CommunicationEventHandler>());
|
||||||
clientHost.VerifyNoOtherCalls();
|
clientHost.VerifyNoOtherCalls();
|
||||||
|
|
||||||
Assert.IsTrue(after - before < new TimeSpan(0, 0, 0, 0, timeout_ms));
|
Assert.IsTrue(after - before < new TimeSpan(0, 0, 0, 0, timeout_ms));
|
||||||
|
@ -78,6 +81,8 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
after = DateTime.Now;
|
after = DateTime.Now;
|
||||||
|
|
||||||
clientHost.VerifyGet(h => h.IsConnected);
|
clientHost.VerifyGet(h => h.IsConnected);
|
||||||
|
clientHost.VerifyAdd(h => h.RuntimeDisconnected += It.IsAny<CommunicationEventHandler>());
|
||||||
|
clientHost.VerifyRemove(h => h.RuntimeDisconnected -= It.IsAny<CommunicationEventHandler>());
|
||||||
clientHost.VerifyNoOtherCalls();
|
clientHost.VerifyNoOtherCalls();
|
||||||
|
|
||||||
Assert.IsTrue(after - before >= new TimeSpan(0, 0, 0, 0, timeout_ms));
|
Assert.IsTrue(after - before >= new TimeSpan(0, 0, 0, 0, timeout_ms));
|
||||||
|
|
|
@ -309,6 +309,7 @@ namespace SafeExamBrowser.Runtime.UnitTests
|
||||||
It.Is<MessageBoxAction>(a => a == MessageBoxAction.Confirm),
|
It.Is<MessageBoxAction>(a => a == MessageBoxAction.Confirm),
|
||||||
It.Is<MessageBoxIcon>(i => i == args.Icon),
|
It.Is<MessageBoxIcon>(i => i == args.Icon),
|
||||||
It.IsAny<IWindow>()), Times.Once);
|
It.IsAny<IWindow>()), Times.Once);
|
||||||
|
clientProxy.VerifyAdd(p => p.ConnectionLost += It.IsAny<CommunicationEventHandler>());
|
||||||
clientProxy.VerifyNoOtherCalls();
|
clientProxy.VerifyNoOtherCalls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue