SEBWIN-296: Extended unit tests of runtime proxy.

This commit is contained in:
dbuechel 2019-02-15 10:01:52 +01:00
parent b0ff5ee0ff
commit 76da1f3585

View file

@ -10,11 +10,12 @@ using System;
using System.ServiceModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using SafeExamBrowser.Communication.Proxies;
using SafeExamBrowser.Contracts.Communication.Data;
using SafeExamBrowser.Contracts.Communication.Proxies;
using SafeExamBrowser.Contracts.Configuration;
using SafeExamBrowser.Contracts.Logging;
using SafeExamBrowser.Communication.Proxies;
using SafeExamBrowser.Contracts.UserInterface.MessageBox;
namespace SafeExamBrowser.Communication.UnitTests.Proxies
{
@ -167,6 +168,30 @@ namespace SafeExamBrowser.Communication.UnitTests.Proxies
Assert.IsFalse(communication.Success);
}
[TestMethod]
public void MustCorrectlySubmitMessageBoxResult()
{
var result = MessageBoxResult.Ok;
var requestId = Guid.NewGuid();
proxy.Setup(p => p.Send(It.IsAny<MessageBoxReplyMessage>())).Returns(new SimpleResponse(SimpleResponsePurport.Acknowledged));
var communication = sut.SubmitMessageBoxResult(requestId, result);
Assert.IsTrue(communication.Success);
proxy.Verify(p => p.Send(It.Is<MessageBoxReplyMessage>(m => m.Result == result && m.RequestId == requestId)), Times.Once);
}
[TestMethod]
public void MustFailIfMessageBoxResultTransmissionNotAcknowledged()
{
proxy.Setup(p => p.Send(It.IsAny<MessageBoxReplyMessage>())).Returns<Response>(null);
var communication = sut.SubmitMessageBoxResult(default(Guid), default(MessageBoxResult));
Assert.IsFalse(communication.Success);
}
[TestMethod]
public void MustExecuteOperationsFailsafe()
{
@ -174,12 +199,14 @@ namespace SafeExamBrowser.Communication.UnitTests.Proxies
var client = sut.InformClientReady();
var configuration = sut.GetConfiguration();
var message = sut.SubmitMessageBoxResult(default(Guid), default(MessageBoxResult));
var password = sut.SubmitPassword(default(Guid), false);
var reconfiguration = sut.RequestReconfiguration(null);
var shutdown = sut.RequestShutdown();
Assert.IsFalse(client.Success);
Assert.IsFalse(configuration.Success);
Assert.IsFalse(message.Success);
Assert.IsFalse(password.Success);
Assert.IsFalse(reconfiguration.Success);
Assert.IsFalse(shutdown.Success);