Dito.
This commit is contained in:
parent
7e77bff1a2
commit
36719c584a
1 changed files with 11 additions and 10 deletions
|
@ -6,6 +6,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
@ -37,7 +38,8 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void MustWaitForDisconnectionIfConnectionIsActive()
|
public void MustWaitForDisconnectionIfConnectionIsActive()
|
||||||
{
|
{
|
||||||
var stopWatch = new Stopwatch();
|
var after = default(DateTime);
|
||||||
|
var before = default(DateTime);
|
||||||
var timeout_ms = 200;
|
var timeout_ms = 200;
|
||||||
|
|
||||||
sut = new ClientHostDisconnectionOperation(clientHost.Object, logger.Object, timeout_ms);
|
sut = new ClientHostDisconnectionOperation(clientHost.Object, logger.Object, timeout_ms);
|
||||||
|
@ -47,36 +49,35 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
|
||||||
clientHost.Raise(h => h.RuntimeDisconnected += null);
|
clientHost.Raise(h => h.RuntimeDisconnected += null);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
stopWatch.Start();
|
before = DateTime.Now;
|
||||||
sut.Revert();
|
sut.Revert();
|
||||||
stopWatch.Stop();
|
after = DateTime.Now;
|
||||||
|
|
||||||
clientHost.VerifyGet(h => h.IsConnected);
|
clientHost.VerifyGet(h => h.IsConnected);
|
||||||
clientHost.VerifyNoOtherCalls();
|
clientHost.VerifyNoOtherCalls();
|
||||||
|
|
||||||
Assert.IsFalse(stopWatch.IsRunning);
|
Assert.IsTrue(after - before < new TimeSpan(0, 0, 0, 0, timeout_ms));
|
||||||
Assert.IsTrue(stopWatch.ElapsedMilliseconds < timeout_ms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void MustRespectTimeoutIfWaitingForDisconnection()
|
public void MustRespectTimeoutIfWaitingForDisconnection()
|
||||||
{
|
{
|
||||||
var stopWatch = new Stopwatch();
|
var after = default(DateTime);
|
||||||
|
var before = default(DateTime);
|
||||||
var timeout_ms = 200;
|
var timeout_ms = 200;
|
||||||
|
|
||||||
sut = new ClientHostDisconnectionOperation(clientHost.Object, logger.Object, timeout_ms);
|
sut = new ClientHostDisconnectionOperation(clientHost.Object, logger.Object, timeout_ms);
|
||||||
|
|
||||||
clientHost.SetupGet(h => h.IsConnected).Returns(true);
|
clientHost.SetupGet(h => h.IsConnected).Returns(true);
|
||||||
|
|
||||||
stopWatch.Start();
|
before = DateTime.Now;
|
||||||
sut.Revert();
|
sut.Revert();
|
||||||
stopWatch.Stop();
|
after = DateTime.Now;
|
||||||
|
|
||||||
clientHost.VerifyGet(h => h.IsConnected);
|
clientHost.VerifyGet(h => h.IsConnected);
|
||||||
clientHost.VerifyNoOtherCalls();
|
clientHost.VerifyNoOtherCalls();
|
||||||
|
|
||||||
Assert.IsFalse(stopWatch.IsRunning);
|
Assert.IsTrue(after - before >= new TimeSpan(0, 0, 0, 0, timeout_ms));
|
||||||
Assert.IsTrue(stopWatch.ElapsedMilliseconds >= timeout_ms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|
Loading…
Reference in a new issue