Extended unit tests for client host.
This commit is contained in:
parent
66c28bd826
commit
645ae7d307
1 changed files with 53 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
@ -151,6 +152,32 @@ namespace SafeExamBrowser.Client.UnitTests.Communication
|
||||||
Assert.AreEqual(PROCESS_ID, (response as AuthenticationResponse)?.ProcessId);
|
Assert.AreEqual(PROCESS_ID, (response as AuthenticationResponse)?.ProcessId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void MustHandleExamSelectionRequestCorrectly()
|
||||||
|
{
|
||||||
|
var examSelectionRequested = false;
|
||||||
|
var requestId = Guid.NewGuid();
|
||||||
|
var resetEvent = new AutoResetEvent(false);
|
||||||
|
|
||||||
|
sut.ExamSelectionRequested += (args) =>
|
||||||
|
{
|
||||||
|
examSelectionRequested = true;
|
||||||
|
resetEvent.Set();
|
||||||
|
};
|
||||||
|
sut.AuthenticationToken = Guid.Empty;
|
||||||
|
|
||||||
|
var token = sut.Connect(Guid.Empty).CommunicationToken.Value;
|
||||||
|
var request = new ExamSelectionRequestMessage(Enumerable.Empty<(string id, string lms, string name, string url)>(), requestId) { CommunicationToken = token };
|
||||||
|
var response = sut.Send(request);
|
||||||
|
|
||||||
|
resetEvent.WaitOne();
|
||||||
|
|
||||||
|
Assert.IsTrue(examSelectionRequested);
|
||||||
|
Assert.IsNotNull(response);
|
||||||
|
Assert.IsInstanceOfType(response, typeof(SimpleResponse));
|
||||||
|
Assert.AreEqual(SimpleResponsePurport.Acknowledged, (response as SimpleResponse)?.Purport);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void MustHandleMessageBoxRequestCorrectly()
|
public void MustHandleMessageBoxRequestCorrectly()
|
||||||
{
|
{
|
||||||
|
@ -259,6 +286,32 @@ namespace SafeExamBrowser.Client.UnitTests.Communication
|
||||||
Assert.AreEqual(SimpleResponsePurport.Acknowledged, (response as SimpleResponse)?.Purport);
|
Assert.AreEqual(SimpleResponsePurport.Acknowledged, (response as SimpleResponse)?.Purport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void MustHandleServerFailureCorrectly()
|
||||||
|
{
|
||||||
|
var serverFailureActionRequested = false;
|
||||||
|
var requestId = Guid.NewGuid();
|
||||||
|
var resetEvent = new AutoResetEvent(false);
|
||||||
|
|
||||||
|
sut.ServerFailureActionRequested += (args) =>
|
||||||
|
{
|
||||||
|
serverFailureActionRequested = true;
|
||||||
|
resetEvent.Set();
|
||||||
|
};
|
||||||
|
sut.AuthenticationToken = Guid.Empty;
|
||||||
|
|
||||||
|
var token = sut.Connect(Guid.Empty).CommunicationToken.Value;
|
||||||
|
var request = new ServerFailureActionRequestMessage("", true, requestId) { CommunicationToken = token };
|
||||||
|
var response = sut.Send(request);
|
||||||
|
|
||||||
|
resetEvent.WaitOne();
|
||||||
|
|
||||||
|
Assert.IsTrue(serverFailureActionRequested);
|
||||||
|
Assert.IsNotNull(response);
|
||||||
|
Assert.IsInstanceOfType(response, typeof(SimpleResponse));
|
||||||
|
Assert.AreEqual(SimpleResponsePurport.Acknowledged, (response as SimpleResponse)?.Purport);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void MustHandleShutdownRequestCorrectly()
|
public void MustHandleShutdownRequestCorrectly()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue