From 487e89693af22f9e30b584a73c83e5e11cb166e6 Mon Sep 17 00:00:00 2001 From: dbuechel Date: Fri, 30 Aug 2019 14:02:36 +0200 Subject: [PATCH] Resolved dependencies from communication API on UI. --- .../ClientControllerTests.cs | 18 +++-- .../Communication/ClientHostTests.cs | 13 ++-- SafeExamBrowser.Client/ClientController.cs | 6 +- .../Communication/ClientHost.cs | 2 +- .../Data/MessageBoxReplyMessage.cs | 13 ++-- .../Data/MessageBoxRequestMessage.cs | 24 +++---- .../Events/MessageBoxReplyEventArgs.cs | 9 ++- .../Events/MessageBoxRequestEventArgs.cs | 17 +++-- .../Proxies/IClientProxy.cs | 3 +- .../Proxies/IRuntimeProxy.cs | 3 +- .../Proxies/ClientProxyTests.cs | 61 ++++++++-------- .../Proxies/RuntimeProxyTests.cs | 69 +++++++++---------- .../Proxies/ClientProxy.cs | 5 +- .../Proxies/RuntimeProxy.cs | 5 +- .../Communication/RuntimeHostTests.cs | 8 +-- .../RuntimeControllerTests.cs | 12 ++-- .../Communication/RuntimeHost.cs | 2 +- SafeExamBrowser.Runtime/RuntimeController.cs | 6 +- 18 files changed, 130 insertions(+), 146 deletions(-) diff --git a/SafeExamBrowser.Client.UnitTests/ClientControllerTests.cs b/SafeExamBrowser.Client.UnitTests/ClientControllerTests.cs index 97b251e4..52f3e101 100644 --- a/SafeExamBrowser.Client.UnitTests/ClientControllerTests.cs +++ b/SafeExamBrowser.Client.UnitTests/ClientControllerTests.cs @@ -113,9 +113,8 @@ namespace SafeExamBrowser.Client.UnitTests { var args = new MessageBoxRequestEventArgs { - // TODO - //Action = MessageBoxAction.YesNo, - //Icon = MessageBoxIcon.Question, + Action = (int) MessageBoxAction.YesNo, + Icon = (int) MessageBoxIcon.Question, Message = "Some question to be answered", RequestId = Guid.NewGuid(), Title = "A Title" @@ -123,18 +122,17 @@ namespace SafeExamBrowser.Client.UnitTests messageBox.Setup(m => m.Show( It.Is(s => s == args.Message), - It.Is(s => s == args.Title), default(MessageBoxAction), default(MessageBoxIcon), null - // TODO - //It.Is(a => a == args.Action), - //It.Is(i => i == args.Icon), - /*It.IsAny()*/)).Returns(MessageBoxResult.No); + It.Is(s => s == args.Title), + It.Is(a => a == (MessageBoxAction) args.Action), + It.Is(i => i == (MessageBoxIcon) args.Icon), + It.IsAny())).Returns(MessageBoxResult.No); sut.TryStart(); clientHost.Raise(c => c.MessageBoxRequested += null, args); runtimeProxy.Verify(p => p.SubmitMessageBoxResult( - It.Is(g => g == args.RequestId)// TODO , - /*It.Is(r => r == MessageBoxResult.No)*/), Times.Once); + It.Is(g => g == args.RequestId), + It.Is(r => r == (int) MessageBoxResult.No)), Times.Once); } [TestMethod] diff --git a/SafeExamBrowser.Client.UnitTests/Communication/ClientHostTests.cs b/SafeExamBrowser.Client.UnitTests/Communication/ClientHostTests.cs index 4aa8777f..4fc86887 100644 --- a/SafeExamBrowser.Client.UnitTests/Communication/ClientHostTests.cs +++ b/SafeExamBrowser.Client.UnitTests/Communication/ClientHostTests.cs @@ -154,8 +154,8 @@ namespace SafeExamBrowser.Client.UnitTests.Communication [TestMethod] public void MustHandleMessageBoxRequestCorrectly() { - var action = MessageBoxAction.YesNo; - var icon = MessageBoxIcon.Question; + var action = (int) MessageBoxAction.YesNo; + var icon = (int) MessageBoxIcon.Question; var message = "Qwert kndorz safie abcd?"; var messageBoxRequested = false; var requestId = Guid.NewGuid(); @@ -164,15 +164,13 @@ namespace SafeExamBrowser.Client.UnitTests.Communication sut.MessageBoxRequested += (args) => { - // TODO - messageBoxRequested = /*args.Action == action && args.Icon == icon &&*/ args.Message == message && args.RequestId == requestId && args.Title == title; + messageBoxRequested = args.Action == action && args.Icon == icon && args.Message == message && args.RequestId == requestId && args.Title == title; resetEvent.Set(); }; sut.AuthenticationToken = Guid.Empty; var token = sut.Connect(Guid.Empty).CommunicationToken.Value; - // TODO - var request = new MessageBoxRequestMessage(/*action, icon, */message, requestId, title) { CommunicationToken = token }; + var request = new MessageBoxRequestMessage(action, icon, message, requestId, title) { CommunicationToken = token }; var response = sut.Send(request); resetEvent.WaitOne(); @@ -282,8 +280,7 @@ namespace SafeExamBrowser.Client.UnitTests.Communication var token = sut.Connect(Guid.Empty).CommunicationToken.Value; - // TODO - sut.Send(new MessageBoxRequestMessage(/*default(MessageBoxAction), default(MessageBoxIcon), */"", Guid.Empty, "") { CommunicationToken = token }); + sut.Send(new MessageBoxRequestMessage(default(int), default(int), "", Guid.Empty, "") { CommunicationToken = token }); sut.Send(new PasswordRequestMessage(default(PasswordRequestPurpose), Guid.Empty) { CommunicationToken = token }); sut.Send(new ReconfigurationDeniedMessage("") { CommunicationToken = token }); sut.Send(new SimpleMessage(SimpleMessagePurport.Shutdown) { CommunicationToken = token }); diff --git a/SafeExamBrowser.Client/ClientController.cs b/SafeExamBrowser.Client/ClientController.cs index a36d6214..566fe7b0 100644 --- a/SafeExamBrowser.Client/ClientController.cs +++ b/SafeExamBrowser.Client/ClientController.cs @@ -282,9 +282,11 @@ namespace SafeExamBrowser.Client { logger.Info($"Received message box request with id '{args.RequestId}'."); - var result = messageBox.Show(args.Message, args.Title/*,// TODO args.Action, args.Icon*/, parent: splashScreen); + var action = (MessageBoxAction) args.Action; + var icon = (MessageBoxIcon) args.Icon; + var result = messageBox.Show(args.Message, args.Title, action, icon, parent: splashScreen); - runtime.SubmitMessageBoxResult(args.RequestId/*// TODO , result*/); + runtime.SubmitMessageBoxResult(args.RequestId, (int) result); logger.Info($"Message box request with id '{args.RequestId}' yielded result '{result}'."); } diff --git a/SafeExamBrowser.Client/Communication/ClientHost.cs b/SafeExamBrowser.Client/Communication/ClientHost.cs index 370a006d..56e2625d 100644 --- a/SafeExamBrowser.Client/Communication/ClientHost.cs +++ b/SafeExamBrowser.Client/Communication/ClientHost.cs @@ -69,7 +69,7 @@ namespace SafeExamBrowser.Client.Communication switch (message) { case MessageBoxRequestMessage m: - MessageBoxRequested?.InvokeAsync(new MessageBoxRequestEventArgs { /*// TODO Action = m.Action, Icon = m.Icon,*/ Message = m.Message, RequestId = m.RequestId, Title = m.Title }); + MessageBoxRequested?.InvokeAsync(new MessageBoxRequestEventArgs { Action = m.Action, Icon = m.Icon, Message = m.Message, RequestId = m.RequestId, Title = m.Title }); return new SimpleResponse(SimpleResponsePurport.Acknowledged); case PasswordRequestMessage m: PasswordRequested?.InvokeAsync(new PasswordRequestEventArgs { Purpose = m.Purpose, RequestId = m.RequestId }); diff --git a/SafeExamBrowser.Communication.Contracts/Data/MessageBoxReplyMessage.cs b/SafeExamBrowser.Communication.Contracts/Data/MessageBoxReplyMessage.cs index fc09005f..14b8a238 100644 --- a/SafeExamBrowser.Communication.Contracts/Data/MessageBoxReplyMessage.cs +++ b/SafeExamBrowser.Communication.Contracts/Data/MessageBoxReplyMessage.cs @@ -21,16 +21,15 @@ namespace SafeExamBrowser.Communication.Contracts.Data /// public Guid RequestId { get; private set; } - // TODO - ///// - ///// The result of the interaction. - ///// - //public MessageBoxResult Result { get; private set; } + /// + /// The result of the interaction. + /// + public int Result { get; private set; } - public MessageBoxReplyMessage(Guid requestId)// TODO, MessageBoxResult result) + public MessageBoxReplyMessage(Guid requestId, int result) { RequestId = requestId; - // TODOResult = result; + Result = result; } } } diff --git a/SafeExamBrowser.Communication.Contracts/Data/MessageBoxRequestMessage.cs b/SafeExamBrowser.Communication.Contracts/Data/MessageBoxRequestMessage.cs index 92fcbc90..73e06ad9 100644 --- a/SafeExamBrowser.Communication.Contracts/Data/MessageBoxRequestMessage.cs +++ b/SafeExamBrowser.Communication.Contracts/Data/MessageBoxRequestMessage.cs @@ -16,16 +16,15 @@ namespace SafeExamBrowser.Communication.Contracts.Data [Serializable] public class MessageBoxRequestMessage : Message { - // TODO - ///// - ///// The action to be displayed. - ///// - //public MessageBoxAction Action { get; private set; } + /// + /// The action to be displayed. + /// + public int Action { get; private set; } - ///// - ///// The icon to be displayed. - ///// - //public MessageBoxIcon Icon { get; private set; } + /// + /// The icon to be displayed. + /// + public int Icon { get; private set; } /// /// The message to be displayed. @@ -42,11 +41,10 @@ namespace SafeExamBrowser.Communication.Contracts.Data /// public string Title { get; private set; } - public MessageBoxRequestMessage(/*MessageBoxAction action, MessageBoxIcon icon, */string message, Guid requestId, string title) + public MessageBoxRequestMessage(int action, int icon, string message, Guid requestId, string title) { - // TODO - //Action = action; - //Icon = icon; + Action = action; + Icon = icon; Message = message; RequestId = requestId; Title = title; diff --git a/SafeExamBrowser.Communication.Contracts/Events/MessageBoxReplyEventArgs.cs b/SafeExamBrowser.Communication.Contracts/Events/MessageBoxReplyEventArgs.cs index 92fec0e5..3f024a9f 100644 --- a/SafeExamBrowser.Communication.Contracts/Events/MessageBoxReplyEventArgs.cs +++ b/SafeExamBrowser.Communication.Contracts/Events/MessageBoxReplyEventArgs.cs @@ -20,10 +20,9 @@ namespace SafeExamBrowser.Communication.Contracts.Events /// public Guid RequestId { get; set; } - // TODO - ///// - ///// The result of the interaction. - ///// - //public MessageBoxResult Result { get; set; } + /// + /// The result of the interaction. + /// + public int Result { get; set; } } } diff --git a/SafeExamBrowser.Communication.Contracts/Events/MessageBoxRequestEventArgs.cs b/SafeExamBrowser.Communication.Contracts/Events/MessageBoxRequestEventArgs.cs index c27b7421..012e7f0e 100644 --- a/SafeExamBrowser.Communication.Contracts/Events/MessageBoxRequestEventArgs.cs +++ b/SafeExamBrowser.Communication.Contracts/Events/MessageBoxRequestEventArgs.cs @@ -15,16 +15,15 @@ namespace SafeExamBrowser.Communication.Contracts.Events /// public class MessageBoxRequestEventArgs : CommunicationEventArgs { - // TODO - ///// - ///// The action to be displayed. - ///// - //public MessageBoxAction Action { get; set; } + /// + /// The action to be displayed. + /// + public int Action { get; set; } - ///// - ///// The icon to be displayed. - ///// - //public MessageBoxIcon Icon { get; set; } + /// + /// The icon to be displayed. + /// + public int Icon { get; set; } /// /// The message to be displayed. diff --git a/SafeExamBrowser.Communication.Contracts/Proxies/IClientProxy.cs b/SafeExamBrowser.Communication.Contracts/Proxies/IClientProxy.cs index 278489ba..b5b0b33c 100644 --- a/SafeExamBrowser.Communication.Contracts/Proxies/IClientProxy.cs +++ b/SafeExamBrowser.Communication.Contracts/Proxies/IClientProxy.cs @@ -36,10 +36,9 @@ namespace SafeExamBrowser.Communication.Contracts.Proxies /// CommunicationResult RequestPassword(PasswordRequestPurpose purpose, Guid requestId); - // TODO /// /// Requests the client to render a message box and subsequently return the interaction result as separate message. /// - CommunicationResult ShowMessage(string message, string title, /*MessageBoxAction action, MessageBoxIcon icon, */Guid requestId); + CommunicationResult ShowMessage(string message, string title, int action, int icon, Guid requestId); } } diff --git a/SafeExamBrowser.Communication.Contracts/Proxies/IRuntimeProxy.cs b/SafeExamBrowser.Communication.Contracts/Proxies/IRuntimeProxy.cs index 9c6050cd..dd970c02 100644 --- a/SafeExamBrowser.Communication.Contracts/Proxies/IRuntimeProxy.cs +++ b/SafeExamBrowser.Communication.Contracts/Proxies/IRuntimeProxy.cs @@ -36,11 +36,10 @@ namespace SafeExamBrowser.Communication.Contracts.Proxies /// CommunicationResult RequestReconfiguration(string filePath); - // TODO /// /// Submits the result of a message box input previously requested by the runtime. /// - CommunicationResult SubmitMessageBoxResult(Guid requestId/*, MessageBoxResult result*/); + CommunicationResult SubmitMessageBoxResult(Guid requestId, int result); /// /// Submits the result of a password input previously requested by the runtime. If the procedure was aborted by the user, diff --git a/SafeExamBrowser.Communication.UnitTests/Proxies/ClientProxyTests.cs b/SafeExamBrowser.Communication.UnitTests/Proxies/ClientProxyTests.cs index f8f15259..e93c459a 100644 --- a/SafeExamBrowser.Communication.UnitTests/Proxies/ClientProxyTests.cs +++ b/SafeExamBrowser.Communication.UnitTests/Proxies/ClientProxyTests.cs @@ -135,44 +135,43 @@ namespace SafeExamBrowser.Communication.UnitTests.Proxies Assert.IsFalse(communication.Success); } - // TODO - //[TestMethod] - //public void MustCorrectlyShowMessage() - //{ - // proxy.Setup(p => p.Send(It.IsAny())).Returns(new SimpleResponse(SimpleResponsePurport.Acknowledged)); + [TestMethod] + 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)); + var communication = sut.ShowMessage(default(string), default(string), default(int), default(int), default(Guid)); - // proxy.Verify(p => p.Send(It.IsAny()), Times.Once); - // Assert.IsTrue(communication.Success); - //} + 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); + [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)); + var communication = sut.ShowMessage(default(string), default(string), default(int), default(int), default(Guid)); - // Assert.IsFalse(communication.Success); - //} + Assert.IsFalse(communication.Success); + } - //[TestMethod] - //public void MustExecuteAllOperationsFailsafe() - //{ - // proxy.Setup(p => p.Send(It.IsAny())).Throws(); + [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(); + var authenticate = sut.RequestAuthentication(); + var message = sut.ShowMessage(default(string), default(string), default(int), default(int), 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); - //} + Assert.IsFalse(authenticate.Success); + Assert.IsFalse(message.Success); + Assert.IsFalse(password.Success); + Assert.IsFalse(reconfiguration.Success); + Assert.IsFalse(shutdown.Success); + } } } diff --git a/SafeExamBrowser.Communication.UnitTests/Proxies/RuntimeProxyTests.cs b/SafeExamBrowser.Communication.UnitTests/Proxies/RuntimeProxyTests.cs index 9aedf23d..0a1fc0ea 100644 --- a/SafeExamBrowser.Communication.UnitTests/Proxies/RuntimeProxyTests.cs +++ b/SafeExamBrowser.Communication.UnitTests/Proxies/RuntimeProxyTests.cs @@ -168,49 +168,48 @@ namespace SafeExamBrowser.Communication.UnitTests.Proxies Assert.IsFalse(communication.Success); } - // TODO - //[TestMethod] - //public void MustCorrectlySubmitMessageBoxResult() - //{ - // var result = MessageBoxResult.Ok; - // var requestId = Guid.NewGuid(); + [TestMethod] + public void MustCorrectlySubmitMessageBoxResult() + { + var result = 1234; + var requestId = Guid.NewGuid(); - // proxy.Setup(p => p.Send(It.IsAny())).Returns(new SimpleResponse(SimpleResponsePurport.Acknowledged)); + proxy.Setup(p => p.Send(It.IsAny())).Returns(new SimpleResponse(SimpleResponsePurport.Acknowledged)); - // var communication = sut.SubmitMessageBoxResult(requestId, result); + var communication = sut.SubmitMessageBoxResult(requestId, result); - // Assert.IsTrue(communication.Success); - // proxy.Verify(p => p.Send(It.Is(m => m.Result == result && m.RequestId == requestId)), Times.Once); - //} + Assert.IsTrue(communication.Success); + proxy.Verify(p => p.Send(It.Is(m => m.Result == result && m.RequestId == requestId)), Times.Once); + } - //[TestMethod] - //public void MustFailIfMessageBoxResultTransmissionNotAcknowledged() - //{ - // proxy.Setup(p => p.Send(It.IsAny())).Returns(null); + [TestMethod] + public void MustFailIfMessageBoxResultTransmissionNotAcknowledged() + { + proxy.Setup(p => p.Send(It.IsAny())).Returns(null); - // var communication = sut.SubmitMessageBoxResult(default(Guid), default(MessageBoxResult)); + var communication = sut.SubmitMessageBoxResult(default(Guid), default(int)); - // Assert.IsFalse(communication.Success); - //} + Assert.IsFalse(communication.Success); + } - //[TestMethod] - //public void MustExecuteOperationsFailsafe() - //{ - // proxy.Setup(p => p.Send(It.IsAny())).Throws(); + [TestMethod] + public void MustExecuteOperationsFailsafe() + { + proxy.Setup(p => p.Send(It.IsAny())).Throws(); - // 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(); + var client = sut.InformClientReady(); + var configuration = sut.GetConfiguration(); + var message = sut.SubmitMessageBoxResult(default(Guid), default(int)); + 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); - //} + Assert.IsFalse(client.Success); + Assert.IsFalse(configuration.Success); + Assert.IsFalse(message.Success); + Assert.IsFalse(password.Success); + Assert.IsFalse(reconfiguration.Success); + Assert.IsFalse(shutdown.Success); + } } } diff --git a/SafeExamBrowser.Communication/Proxies/ClientProxy.cs b/SafeExamBrowser.Communication/Proxies/ClientProxy.cs index 86066162..a270f33a 100644 --- a/SafeExamBrowser.Communication/Proxies/ClientProxy.cs +++ b/SafeExamBrowser.Communication/Proxies/ClientProxy.cs @@ -127,12 +127,11 @@ namespace SafeExamBrowser.Communication.Proxies } } - // TODO - public CommunicationResult ShowMessage(string message, string title, /*MessageBoxAction action, MessageBoxIcon icon, */Guid requestId) + public CommunicationResult ShowMessage(string message, string title, int action, int icon, Guid requestId) { try { - var response = Send(new MessageBoxRequestMessage(/*action, icon, */message, requestId, title)); + var response = Send(new MessageBoxRequestMessage(action, icon, message, requestId, title)); var success = IsAcknowledged(response); if (success) diff --git a/SafeExamBrowser.Communication/Proxies/RuntimeProxy.cs b/SafeExamBrowser.Communication/Proxies/RuntimeProxy.cs index 00fdfa77..d12fd84f 100644 --- a/SafeExamBrowser.Communication/Proxies/RuntimeProxy.cs +++ b/SafeExamBrowser.Communication/Proxies/RuntimeProxy.cs @@ -127,12 +127,11 @@ namespace SafeExamBrowser.Communication.Proxies } } - // TODO - public CommunicationResult SubmitMessageBoxResult(Guid requestId/*, MessageBoxResult result*/) + public CommunicationResult SubmitMessageBoxResult(Guid requestId, int result) { try { - var response = Send(new MessageBoxReplyMessage(requestId/*, result*/)); + var response = Send(new MessageBoxReplyMessage(requestId, result)); var acknowledged = IsAcknowledged(response); if (acknowledged) diff --git a/SafeExamBrowser.Runtime.UnitTests/Communication/RuntimeHostTests.cs b/SafeExamBrowser.Runtime.UnitTests/Communication/RuntimeHostTests.cs index 2bb923ed..bf68036f 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Communication/RuntimeHostTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Communication/RuntimeHostTests.cs @@ -211,7 +211,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication { var args = default(MessageBoxReplyEventArgs); var requestId = Guid.NewGuid(); - var result = MessageBoxResult.Ok; + var result = (int) MessageBoxResult.Ok; var sync = new AutoResetEvent(false); sut.AllowConnection = true; @@ -219,7 +219,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication sut.AuthenticationToken = Guid.Empty; var token = sut.Connect(Guid.Empty).CommunicationToken.Value; - var message = new MessageBoxReplyMessage(requestId/*// TODO , result*/) { CommunicationToken = token }; + var message = new MessageBoxReplyMessage(requestId, result) { CommunicationToken = token }; var response = sut.Send(message); sync.WaitOne(); @@ -229,7 +229,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication Assert.IsInstanceOfType(response, typeof(SimpleResponse)); Assert.AreEqual(SimpleResponsePurport.Acknowledged, (response as SimpleResponse)?.Purport); Assert.AreEqual(requestId, args.RequestId); - // TODO Assert.AreEqual(result, args.Result); + Assert.AreEqual(result, args.Result); } [TestMethod] @@ -317,7 +317,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication sut.Send(new SimpleMessage(SimpleMessagePurport.ClientIsReady) { CommunicationToken = token }); sut.Send(new SimpleMessage(SimpleMessagePurport.ConfigurationNeeded) { CommunicationToken = token }); sut.Send(new SimpleMessage(SimpleMessagePurport.RequestShutdown) { CommunicationToken = token }); - sut.Send(new MessageBoxReplyMessage(Guid.Empty/*// TODO , MessageBoxResult.Cancel*/) { CommunicationToken = token }); + sut.Send(new MessageBoxReplyMessage(Guid.Empty, (int) MessageBoxResult.Cancel) { CommunicationToken = token }); sut.Send(new PasswordReplyMessage(Guid.Empty, false, "") { CommunicationToken = token }); sut.Send(new ReconfigurationMessage("") { CommunicationToken = token }); sut.Disconnect(new DisconnectionMessage { CommunicationToken = token }); diff --git a/SafeExamBrowser.Runtime.UnitTests/RuntimeControllerTests.cs b/SafeExamBrowser.Runtime.UnitTests/RuntimeControllerTests.cs index 10ed7a01..84e7215d 100644 --- a/SafeExamBrowser.Runtime.UnitTests/RuntimeControllerTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/RuntimeControllerTests.cs @@ -330,11 +330,10 @@ namespace SafeExamBrowser.Runtime.UnitTests clientProxy.Setup(c => c.ShowMessage( It.IsAny(), It.IsAny(), - // TODO - //It.Is(a => a == MessageBoxAction.Confirm), - //It.IsAny(), + It.Is(a => a == (int) MessageBoxAction.Confirm), + It.IsAny(), It.IsAny())) - .Callback((m, t, a, i, id) => + .Callback((m, t, a, i, id) => { runtimeHost.Raise(r => r.MessageBoxReplyReceived += null, new MessageBoxReplyEventArgs { RequestId = id }); }) @@ -346,9 +345,8 @@ namespace SafeExamBrowser.Runtime.UnitTests clientProxy.Verify(c => c.ShowMessage( It.IsAny(), It.IsAny(), - // TODO - //It.Is(a => a == MessageBoxAction.Confirm), - //It.Is(i => i == args.Icon), + It.Is(a => a == (int) MessageBoxAction.Confirm), + It.Is(i => i == (int) args.Icon), It.IsAny()), Times.Once); } diff --git a/SafeExamBrowser.Runtime/Communication/RuntimeHost.cs b/SafeExamBrowser.Runtime/Communication/RuntimeHost.cs index 9df492b8..b0ad11fc 100644 --- a/SafeExamBrowser.Runtime/Communication/RuntimeHost.cs +++ b/SafeExamBrowser.Runtime/Communication/RuntimeHost.cs @@ -59,7 +59,7 @@ namespace SafeExamBrowser.Runtime.Communication switch (message) { case MessageBoxReplyMessage m: - MessageBoxReplyReceived?.InvokeAsync(new MessageBoxReplyEventArgs { RequestId = m.RequestId/*// TODO , Result = m.Result*/ }); + MessageBoxReplyReceived?.InvokeAsync(new MessageBoxReplyEventArgs { RequestId = m.RequestId, Result = m.Result }); return new SimpleResponse(SimpleResponsePurport.Acknowledged); case PasswordReplyMessage m: PasswordReceived?.InvokeAsync(new PasswordReplyEventArgs { Password = m.Password, RequestId = m.RequestId, Success = m.Success }); diff --git a/SafeExamBrowser.Runtime/RuntimeController.cs b/SafeExamBrowser.Runtime/RuntimeController.cs index e79325b7..f5687e0a 100644 --- a/SafeExamBrowser.Runtime/RuntimeController.cs +++ b/SafeExamBrowser.Runtime/RuntimeController.cs @@ -442,7 +442,7 @@ namespace SafeExamBrowser.Runtime } } - private MessageBoxResult ShowMessageBoxViaClient(string message, string title, MessageBoxAction confirm, MessageBoxIcon icon) + private MessageBoxResult ShowMessageBoxViaClient(string message, string title, MessageBoxAction action, MessageBoxIcon icon) { var requestId = Guid.NewGuid(); var result = MessageBoxResult.None; @@ -459,12 +459,12 @@ namespace SafeExamBrowser.Runtime runtimeHost.MessageBoxReplyReceived += responseEventHandler; - var communication = sessionContext.ClientProxy.ShowMessage(message, title, /*// TODO MessageBoxAction.Confirm, icon, */requestId); + var communication = sessionContext.ClientProxy.ShowMessage(message, title, (int) action, (int) icon, requestId); if (communication.Success) { responseEvent.WaitOne(); - // TODO result = response.Result; + result = (MessageBoxResult) response.Result; } runtimeHost.MessageBoxReplyReceived -= responseEventHandler;