From 7e77bff1a2952acd752ab1e6514e25289c6ccce1 Mon Sep 17 00:00:00 2001 From: dbuechel Date: Fri, 15 Mar 2019 13:36:10 +0100 Subject: [PATCH] Attempt to resolve timing issues with test for ClientHostDisconnectionOperation. --- .../Operations/ClientHostDisconnectionOperationTests.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/SafeExamBrowser.Client.UnitTests/Operations/ClientHostDisconnectionOperationTests.cs b/SafeExamBrowser.Client.UnitTests/Operations/ClientHostDisconnectionOperationTests.cs index b38a5783..db59206a 100644 --- a/SafeExamBrowser.Client.UnitTests/Operations/ClientHostDisconnectionOperationTests.cs +++ b/SafeExamBrowser.Client.UnitTests/Operations/ClientHostDisconnectionOperationTests.cs @@ -7,7 +7,6 @@ */ using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; @@ -39,13 +38,12 @@ namespace SafeExamBrowser.Client.UnitTests.Operations public void MustWaitForDisconnectionIfConnectionIsActive() { var stopWatch = new Stopwatch(); - var timeout_ms = 1000; + var timeout_ms = 200; sut = new ClientHostDisconnectionOperation(clientHost.Object, logger.Object, timeout_ms); - clientHost.SetupGet(h => h.IsConnected).Returns(true).Callback(() => Task.Run(() => + clientHost.SetupGet(h => h.IsConnected).Returns(true).Callback(() => Task.Delay(10).ContinueWith((_) => { - Thread.Sleep(10); clientHost.Raise(h => h.RuntimeDisconnected += null); })); @@ -64,7 +62,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations public void MustRespectTimeoutIfWaitingForDisconnection() { var stopWatch = new Stopwatch(); - var timeout_ms = 50; + var timeout_ms = 200; sut = new ClientHostDisconnectionOperation(clientHost.Object, logger.Object, timeout_ms);