From b0ff5ee0ffb00d636f325732edc98c3f27cf6248 Mon Sep 17 00:00:00 2001 From: dbuechel Date: Fri, 15 Feb 2019 09:52:18 +0100 Subject: [PATCH] SEBWIN-296: Extended unit tests for client proxy. --- .../Proxies/ClientProxyTests.cs | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/SafeExamBrowser.Communication.UnitTests/Proxies/ClientProxyTests.cs b/SafeExamBrowser.Communication.UnitTests/Proxies/ClientProxyTests.cs index 4df6dc28..e88eeccf 100644 --- a/SafeExamBrowser.Communication.UnitTests/Proxies/ClientProxyTests.cs +++ b/SafeExamBrowser.Communication.UnitTests/Proxies/ClientProxyTests.cs @@ -10,10 +10,11 @@ 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.Logging; -using SafeExamBrowser.Communication.Proxies; +using SafeExamBrowser.Contracts.UserInterface.MessageBox; namespace SafeExamBrowser.Communication.UnitTests.Proxies { @@ -135,16 +136,39 @@ namespace SafeExamBrowser.Communication.UnitTests.Proxies } [TestMethod] - public void MustExecuteOperationsFailsafe() + public void MustCorrectlyShowMessage() + { + proxy.Setup(p => p.Send(It.IsAny())).Returns(new SimpleResponse(SimpleResponsePurport.Acknowledged)); + + var communication = sut.ShowMessage(default(string), default(string), default(MessageBoxAction), default(MessageBoxIcon), default(Guid)); + + proxy.Verify(p => p.Send(It.IsAny()), Times.Once); + Assert.IsTrue(communication.Success); + } + + [TestMethod] + public void MustFailIfMessageBoxRequestNotAchnowledged() + { + proxy.Setup(p => p.Send(It.IsAny())).Returns(null); + + var communication = sut.ShowMessage(default(string), default(string), default(MessageBoxAction), default(MessageBoxIcon), default(Guid)); + + Assert.IsFalse(communication.Success); + } + + [TestMethod] + public void MustExecuteAllOperationsFailsafe() { proxy.Setup(p => p.Send(It.IsAny())).Throws(); var authenticate = sut.RequestAuthentication(); + var message = sut.ShowMessage(default(string), default(string), default(MessageBoxAction), default(MessageBoxIcon), default(Guid)); var password = sut.RequestPassword(default(PasswordRequestPurpose), default(Guid)); var reconfiguration = sut.InformReconfigurationDenied(null); var shutdown = sut.InitiateShutdown(); Assert.IsFalse(authenticate.Success); + Assert.IsFalse(message.Success); Assert.IsFalse(password.Success); Assert.IsFalse(reconfiguration.Success); Assert.IsFalse(shutdown.Success);