Resolved dependencies from communication API on UI.
This commit is contained in:
parent
affd5de6a7
commit
487e89693a
18 changed files with 130 additions and 146 deletions
|
@ -113,9 +113,8 @@ namespace SafeExamBrowser.Client.UnitTests
|
||||||
{
|
{
|
||||||
var args = new MessageBoxRequestEventArgs
|
var args = new MessageBoxRequestEventArgs
|
||||||
{
|
{
|
||||||
// TODO
|
Action = (int) MessageBoxAction.YesNo,
|
||||||
//Action = MessageBoxAction.YesNo,
|
Icon = (int) MessageBoxIcon.Question,
|
||||||
//Icon = MessageBoxIcon.Question,
|
|
||||||
Message = "Some question to be answered",
|
Message = "Some question to be answered",
|
||||||
RequestId = Guid.NewGuid(),
|
RequestId = Guid.NewGuid(),
|
||||||
Title = "A Title"
|
Title = "A Title"
|
||||||
|
@ -123,18 +122,17 @@ namespace SafeExamBrowser.Client.UnitTests
|
||||||
|
|
||||||
messageBox.Setup(m => m.Show(
|
messageBox.Setup(m => m.Show(
|
||||||
It.Is<string>(s => s == args.Message),
|
It.Is<string>(s => s == args.Message),
|
||||||
It.Is<string>(s => s == args.Title), default(MessageBoxAction), default(MessageBoxIcon), null
|
It.Is<string>(s => s == args.Title),
|
||||||
// TODO
|
It.Is<MessageBoxAction>(a => a == (MessageBoxAction) args.Action),
|
||||||
//It.Is<MessageBoxAction>(a => a == args.Action),
|
It.Is<MessageBoxIcon>(i => i == (MessageBoxIcon) args.Icon),
|
||||||
//It.Is<MessageBoxIcon>(i => i == args.Icon),
|
It.IsAny<IWindow>())).Returns(MessageBoxResult.No);
|
||||||
/*It.IsAny<IWindow>()*/)).Returns(MessageBoxResult.No);
|
|
||||||
|
|
||||||
sut.TryStart();
|
sut.TryStart();
|
||||||
clientHost.Raise(c => c.MessageBoxRequested += null, args);
|
clientHost.Raise(c => c.MessageBoxRequested += null, args);
|
||||||
|
|
||||||
runtimeProxy.Verify(p => p.SubmitMessageBoxResult(
|
runtimeProxy.Verify(p => p.SubmitMessageBoxResult(
|
||||||
It.Is<Guid>(g => g == args.RequestId)// TODO ,
|
It.Is<Guid>(g => g == args.RequestId),
|
||||||
/*It.Is<MessageBoxResult>(r => r == MessageBoxResult.No)*/), Times.Once);
|
It.Is<int>(r => r == (int) MessageBoxResult.No)), Times.Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|
|
@ -154,8 +154,8 @@ namespace SafeExamBrowser.Client.UnitTests.Communication
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void MustHandleMessageBoxRequestCorrectly()
|
public void MustHandleMessageBoxRequestCorrectly()
|
||||||
{
|
{
|
||||||
var action = MessageBoxAction.YesNo;
|
var action = (int) MessageBoxAction.YesNo;
|
||||||
var icon = MessageBoxIcon.Question;
|
var icon = (int) MessageBoxIcon.Question;
|
||||||
var message = "Qwert kndorz safie abcd?";
|
var message = "Qwert kndorz safie abcd?";
|
||||||
var messageBoxRequested = false;
|
var messageBoxRequested = false;
|
||||||
var requestId = Guid.NewGuid();
|
var requestId = Guid.NewGuid();
|
||||||
|
@ -164,15 +164,13 @@ namespace SafeExamBrowser.Client.UnitTests.Communication
|
||||||
|
|
||||||
sut.MessageBoxRequested += (args) =>
|
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();
|
resetEvent.Set();
|
||||||
};
|
};
|
||||||
sut.AuthenticationToken = Guid.Empty;
|
sut.AuthenticationToken = Guid.Empty;
|
||||||
|
|
||||||
var token = sut.Connect(Guid.Empty).CommunicationToken.Value;
|
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);
|
var response = sut.Send(request);
|
||||||
|
|
||||||
resetEvent.WaitOne();
|
resetEvent.WaitOne();
|
||||||
|
@ -282,8 +280,7 @@ namespace SafeExamBrowser.Client.UnitTests.Communication
|
||||||
|
|
||||||
var token = sut.Connect(Guid.Empty).CommunicationToken.Value;
|
var token = sut.Connect(Guid.Empty).CommunicationToken.Value;
|
||||||
|
|
||||||
// TODO
|
sut.Send(new MessageBoxRequestMessage(default(int), default(int), "", Guid.Empty, "") { CommunicationToken = token });
|
||||||
sut.Send(new MessageBoxRequestMessage(/*default(MessageBoxAction), default(MessageBoxIcon), */"", Guid.Empty, "") { CommunicationToken = token });
|
|
||||||
sut.Send(new PasswordRequestMessage(default(PasswordRequestPurpose), Guid.Empty) { CommunicationToken = token });
|
sut.Send(new PasswordRequestMessage(default(PasswordRequestPurpose), Guid.Empty) { CommunicationToken = token });
|
||||||
sut.Send(new ReconfigurationDeniedMessage("") { CommunicationToken = token });
|
sut.Send(new ReconfigurationDeniedMessage("") { CommunicationToken = token });
|
||||||
sut.Send(new SimpleMessage(SimpleMessagePurport.Shutdown) { CommunicationToken = token });
|
sut.Send(new SimpleMessage(SimpleMessagePurport.Shutdown) { CommunicationToken = token });
|
||||||
|
|
|
@ -282,9 +282,11 @@ namespace SafeExamBrowser.Client
|
||||||
{
|
{
|
||||||
logger.Info($"Received message box request with id '{args.RequestId}'.");
|
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}'.");
|
logger.Info($"Message box request with id '{args.RequestId}' yielded result '{result}'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace SafeExamBrowser.Client.Communication
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case MessageBoxRequestMessage m:
|
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);
|
return new SimpleResponse(SimpleResponsePurport.Acknowledged);
|
||||||
case PasswordRequestMessage m:
|
case PasswordRequestMessage m:
|
||||||
PasswordRequested?.InvokeAsync(new PasswordRequestEventArgs { Purpose = m.Purpose, RequestId = m.RequestId });
|
PasswordRequested?.InvokeAsync(new PasswordRequestEventArgs { Purpose = m.Purpose, RequestId = m.RequestId });
|
||||||
|
|
|
@ -21,16 +21,15 @@ namespace SafeExamBrowser.Communication.Contracts.Data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Guid RequestId { get; private set; }
|
public Guid RequestId { get; private set; }
|
||||||
|
|
||||||
// TODO
|
/// <summary>
|
||||||
///// <summary>
|
/// The result of the interaction.
|
||||||
///// The result of the interaction.
|
/// </summary>
|
||||||
///// </summary>
|
public int Result { get; private set; }
|
||||||
//public MessageBoxResult Result { get; private set; }
|
|
||||||
|
|
||||||
public MessageBoxReplyMessage(Guid requestId)// TODO, MessageBoxResult result)
|
public MessageBoxReplyMessage(Guid requestId, int result)
|
||||||
{
|
{
|
||||||
RequestId = requestId;
|
RequestId = requestId;
|
||||||
// TODOResult = result;
|
Result = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,16 +16,15 @@ namespace SafeExamBrowser.Communication.Contracts.Data
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class MessageBoxRequestMessage : Message
|
public class MessageBoxRequestMessage : Message
|
||||||
{
|
{
|
||||||
// TODO
|
/// <summary>
|
||||||
///// <summary>
|
/// The action to be displayed.
|
||||||
///// The action to be displayed.
|
/// </summary>
|
||||||
///// </summary>
|
public int Action { get; private set; }
|
||||||
//public MessageBoxAction Action { get; private set; }
|
|
||||||
|
|
||||||
///// <summary>
|
/// <summary>
|
||||||
///// The icon to be displayed.
|
/// The icon to be displayed.
|
||||||
///// </summary>
|
/// </summary>
|
||||||
//public MessageBoxIcon Icon { get; private set; }
|
public int Icon { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The message to be displayed.
|
/// The message to be displayed.
|
||||||
|
@ -42,11 +41,10 @@ namespace SafeExamBrowser.Communication.Contracts.Data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Title { get; private set; }
|
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;
|
||||||
//Action = action;
|
Icon = icon;
|
||||||
//Icon = icon;
|
|
||||||
Message = message;
|
Message = message;
|
||||||
RequestId = requestId;
|
RequestId = requestId;
|
||||||
Title = title;
|
Title = title;
|
||||||
|
|
|
@ -20,10 +20,9 @@ namespace SafeExamBrowser.Communication.Contracts.Events
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Guid RequestId { get; set; }
|
public Guid RequestId { get; set; }
|
||||||
|
|
||||||
// TODO
|
/// <summary>
|
||||||
///// <summary>
|
/// The result of the interaction.
|
||||||
///// The result of the interaction.
|
/// </summary>
|
||||||
///// </summary>
|
public int Result { get; set; }
|
||||||
//public MessageBoxResult Result { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,16 +15,15 @@ namespace SafeExamBrowser.Communication.Contracts.Events
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MessageBoxRequestEventArgs : CommunicationEventArgs
|
public class MessageBoxRequestEventArgs : CommunicationEventArgs
|
||||||
{
|
{
|
||||||
// TODO
|
/// <summary>
|
||||||
///// <summary>
|
/// The action to be displayed.
|
||||||
///// The action to be displayed.
|
/// </summary>
|
||||||
///// </summary>
|
public int Action { get; set; }
|
||||||
//public MessageBoxAction Action { get; set; }
|
|
||||||
|
|
||||||
///// <summary>
|
/// <summary>
|
||||||
///// The icon to be displayed.
|
/// The icon to be displayed.
|
||||||
///// </summary>
|
/// </summary>
|
||||||
//public MessageBoxIcon Icon { get; set; }
|
public int Icon { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The message to be displayed.
|
/// The message to be displayed.
|
||||||
|
|
|
@ -36,10 +36,9 @@ namespace SafeExamBrowser.Communication.Contracts.Proxies
|
||||||
/// </summary>
|
/// </summary>
|
||||||
CommunicationResult RequestPassword(PasswordRequestPurpose purpose, Guid requestId);
|
CommunicationResult RequestPassword(PasswordRequestPurpose purpose, Guid requestId);
|
||||||
|
|
||||||
// TODO
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Requests the client to render a message box and subsequently return the interaction result as separate message.
|
/// Requests the client to render a message box and subsequently return the interaction result as separate message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
CommunicationResult ShowMessage(string message, string title, /*MessageBoxAction action, MessageBoxIcon icon, */Guid requestId);
|
CommunicationResult ShowMessage(string message, string title, int action, int icon, Guid requestId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,10 @@ namespace SafeExamBrowser.Communication.Contracts.Proxies
|
||||||
/// </summary>
|
/// </summary>
|
||||||
CommunicationResult RequestReconfiguration(string filePath);
|
CommunicationResult RequestReconfiguration(string filePath);
|
||||||
|
|
||||||
// TODO
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Submits the result of a message box input previously requested by the runtime.
|
/// Submits the result of a message box input previously requested by the runtime.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
CommunicationResult SubmitMessageBoxResult(Guid requestId/*, MessageBoxResult result*/);
|
CommunicationResult SubmitMessageBoxResult(Guid requestId, int result);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Submits the result of a password input previously requested by the runtime. If the procedure was aborted by the user,
|
/// Submits the result of a password input previously requested by the runtime. If the procedure was aborted by the user,
|
||||||
|
|
|
@ -135,44 +135,43 @@ namespace SafeExamBrowser.Communication.UnitTests.Proxies
|
||||||
Assert.IsFalse(communication.Success);
|
Assert.IsFalse(communication.Success);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
[TestMethod]
|
||||||
//[TestMethod]
|
public void MustCorrectlyShowMessage()
|
||||||
//public void MustCorrectlyShowMessage()
|
{
|
||||||
//{
|
proxy.Setup(p => p.Send(It.IsAny<MessageBoxRequestMessage>())).Returns(new SimpleResponse(SimpleResponsePurport.Acknowledged));
|
||||||
// proxy.Setup(p => p.Send(It.IsAny<MessageBoxRequestMessage>())).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<MessageBoxRequestMessage>()), Times.Once);
|
proxy.Verify(p => p.Send(It.IsAny<MessageBoxRequestMessage>()), Times.Once);
|
||||||
// Assert.IsTrue(communication.Success);
|
Assert.IsTrue(communication.Success);
|
||||||
//}
|
}
|
||||||
|
|
||||||
//[TestMethod]
|
[TestMethod]
|
||||||
//public void MustFailIfMessageBoxRequestNotAchnowledged()
|
public void MustFailIfMessageBoxRequestNotAchnowledged()
|
||||||
//{
|
{
|
||||||
// proxy.Setup(p => p.Send(It.IsAny<MessageBoxRequestMessage>())).Returns<Response>(null);
|
proxy.Setup(p => p.Send(It.IsAny<MessageBoxRequestMessage>())).Returns<Response>(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]
|
[TestMethod]
|
||||||
//public void MustExecuteAllOperationsFailsafe()
|
public void MustExecuteAllOperationsFailsafe()
|
||||||
//{
|
{
|
||||||
// proxy.Setup(p => p.Send(It.IsAny<Message>())).Throws<Exception>();
|
proxy.Setup(p => p.Send(It.IsAny<Message>())).Throws<Exception>();
|
||||||
|
|
||||||
// var authenticate = sut.RequestAuthentication();
|
var authenticate = sut.RequestAuthentication();
|
||||||
// var message = sut.ShowMessage(default(string), default(string), default(MessageBoxAction), default(MessageBoxIcon), default(Guid));
|
var message = sut.ShowMessage(default(string), default(string), default(int), default(int), default(Guid));
|
||||||
// var password = sut.RequestPassword(default(PasswordRequestPurpose), default(Guid));
|
var password = sut.RequestPassword(default(PasswordRequestPurpose), default(Guid));
|
||||||
// var reconfiguration = sut.InformReconfigurationDenied(null);
|
var reconfiguration = sut.InformReconfigurationDenied(null);
|
||||||
// var shutdown = sut.InitiateShutdown();
|
var shutdown = sut.InitiateShutdown();
|
||||||
|
|
||||||
// Assert.IsFalse(authenticate.Success);
|
Assert.IsFalse(authenticate.Success);
|
||||||
// Assert.IsFalse(message.Success);
|
Assert.IsFalse(message.Success);
|
||||||
// Assert.IsFalse(password.Success);
|
Assert.IsFalse(password.Success);
|
||||||
// Assert.IsFalse(reconfiguration.Success);
|
Assert.IsFalse(reconfiguration.Success);
|
||||||
// Assert.IsFalse(shutdown.Success);
|
Assert.IsFalse(shutdown.Success);
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,49 +168,48 @@ namespace SafeExamBrowser.Communication.UnitTests.Proxies
|
||||||
Assert.IsFalse(communication.Success);
|
Assert.IsFalse(communication.Success);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
[TestMethod]
|
||||||
//[TestMethod]
|
public void MustCorrectlySubmitMessageBoxResult()
|
||||||
//public void MustCorrectlySubmitMessageBoxResult()
|
{
|
||||||
//{
|
var result = 1234;
|
||||||
// var result = MessageBoxResult.Ok;
|
var requestId = Guid.NewGuid();
|
||||||
// var requestId = Guid.NewGuid();
|
|
||||||
|
|
||||||
// proxy.Setup(p => p.Send(It.IsAny<MessageBoxReplyMessage>())).Returns(new SimpleResponse(SimpleResponsePurport.Acknowledged));
|
proxy.Setup(p => p.Send(It.IsAny<MessageBoxReplyMessage>())).Returns(new SimpleResponse(SimpleResponsePurport.Acknowledged));
|
||||||
|
|
||||||
// var communication = sut.SubmitMessageBoxResult(requestId, result);
|
var communication = sut.SubmitMessageBoxResult(requestId, result);
|
||||||
|
|
||||||
// Assert.IsTrue(communication.Success);
|
Assert.IsTrue(communication.Success);
|
||||||
// proxy.Verify(p => p.Send(It.Is<MessageBoxReplyMessage>(m => m.Result == result && m.RequestId == requestId)), Times.Once);
|
proxy.Verify(p => p.Send(It.Is<MessageBoxReplyMessage>(m => m.Result == result && m.RequestId == requestId)), Times.Once);
|
||||||
//}
|
}
|
||||||
|
|
||||||
//[TestMethod]
|
[TestMethod]
|
||||||
//public void MustFailIfMessageBoxResultTransmissionNotAcknowledged()
|
public void MustFailIfMessageBoxResultTransmissionNotAcknowledged()
|
||||||
//{
|
{
|
||||||
// proxy.Setup(p => p.Send(It.IsAny<MessageBoxReplyMessage>())).Returns<Response>(null);
|
proxy.Setup(p => p.Send(It.IsAny<MessageBoxReplyMessage>())).Returns<Response>(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]
|
[TestMethod]
|
||||||
//public void MustExecuteOperationsFailsafe()
|
public void MustExecuteOperationsFailsafe()
|
||||||
//{
|
{
|
||||||
// proxy.Setup(p => p.Send(It.IsAny<Message>())).Throws<Exception>();
|
proxy.Setup(p => p.Send(It.IsAny<Message>())).Throws<Exception>();
|
||||||
|
|
||||||
// var client = sut.InformClientReady();
|
var client = sut.InformClientReady();
|
||||||
// var configuration = sut.GetConfiguration();
|
var configuration = sut.GetConfiguration();
|
||||||
// var message = sut.SubmitMessageBoxResult(default(Guid), default(MessageBoxResult));
|
var message = sut.SubmitMessageBoxResult(default(Guid), default(int));
|
||||||
// var password = sut.SubmitPassword(default(Guid), false);
|
var password = sut.SubmitPassword(default(Guid), false);
|
||||||
// var reconfiguration = sut.RequestReconfiguration(null);
|
var reconfiguration = sut.RequestReconfiguration(null);
|
||||||
// var shutdown = sut.RequestShutdown();
|
var shutdown = sut.RequestShutdown();
|
||||||
|
|
||||||
// Assert.IsFalse(client.Success);
|
Assert.IsFalse(client.Success);
|
||||||
// Assert.IsFalse(configuration.Success);
|
Assert.IsFalse(configuration.Success);
|
||||||
// Assert.IsFalse(message.Success);
|
Assert.IsFalse(message.Success);
|
||||||
// Assert.IsFalse(password.Success);
|
Assert.IsFalse(password.Success);
|
||||||
// Assert.IsFalse(reconfiguration.Success);
|
Assert.IsFalse(reconfiguration.Success);
|
||||||
// Assert.IsFalse(shutdown.Success);
|
Assert.IsFalse(shutdown.Success);
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,12 +127,11 @@ namespace SafeExamBrowser.Communication.Proxies
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
public CommunicationResult ShowMessage(string message, string title, int action, int icon, Guid requestId)
|
||||||
public CommunicationResult ShowMessage(string message, string title, /*MessageBoxAction action, MessageBoxIcon icon, */Guid requestId)
|
|
||||||
{
|
{
|
||||||
try
|
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);
|
var success = IsAcknowledged(response);
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
|
|
|
@ -127,12 +127,11 @@ namespace SafeExamBrowser.Communication.Proxies
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
public CommunicationResult SubmitMessageBoxResult(Guid requestId, int result)
|
||||||
public CommunicationResult SubmitMessageBoxResult(Guid requestId/*, MessageBoxResult result*/)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var response = Send(new MessageBoxReplyMessage(requestId/*, result*/));
|
var response = Send(new MessageBoxReplyMessage(requestId, result));
|
||||||
var acknowledged = IsAcknowledged(response);
|
var acknowledged = IsAcknowledged(response);
|
||||||
|
|
||||||
if (acknowledged)
|
if (acknowledged)
|
||||||
|
|
|
@ -211,7 +211,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication
|
||||||
{
|
{
|
||||||
var args = default(MessageBoxReplyEventArgs);
|
var args = default(MessageBoxReplyEventArgs);
|
||||||
var requestId = Guid.NewGuid();
|
var requestId = Guid.NewGuid();
|
||||||
var result = MessageBoxResult.Ok;
|
var result = (int) MessageBoxResult.Ok;
|
||||||
var sync = new AutoResetEvent(false);
|
var sync = new AutoResetEvent(false);
|
||||||
|
|
||||||
sut.AllowConnection = true;
|
sut.AllowConnection = true;
|
||||||
|
@ -219,7 +219,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication
|
||||||
sut.AuthenticationToken = Guid.Empty;
|
sut.AuthenticationToken = Guid.Empty;
|
||||||
|
|
||||||
var token = sut.Connect(Guid.Empty).CommunicationToken.Value;
|
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);
|
var response = sut.Send(message);
|
||||||
|
|
||||||
sync.WaitOne();
|
sync.WaitOne();
|
||||||
|
@ -229,7 +229,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication
|
||||||
Assert.IsInstanceOfType(response, typeof(SimpleResponse));
|
Assert.IsInstanceOfType(response, typeof(SimpleResponse));
|
||||||
Assert.AreEqual(SimpleResponsePurport.Acknowledged, (response as SimpleResponse)?.Purport);
|
Assert.AreEqual(SimpleResponsePurport.Acknowledged, (response as SimpleResponse)?.Purport);
|
||||||
Assert.AreEqual(requestId, args.RequestId);
|
Assert.AreEqual(requestId, args.RequestId);
|
||||||
// TODO Assert.AreEqual(result, args.Result);
|
Assert.AreEqual(result, args.Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
@ -317,7 +317,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Communication
|
||||||
sut.Send(new SimpleMessage(SimpleMessagePurport.ClientIsReady) { CommunicationToken = token });
|
sut.Send(new SimpleMessage(SimpleMessagePurport.ClientIsReady) { CommunicationToken = token });
|
||||||
sut.Send(new SimpleMessage(SimpleMessagePurport.ConfigurationNeeded) { CommunicationToken = token });
|
sut.Send(new SimpleMessage(SimpleMessagePurport.ConfigurationNeeded) { CommunicationToken = token });
|
||||||
sut.Send(new SimpleMessage(SimpleMessagePurport.RequestShutdown) { 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 PasswordReplyMessage(Guid.Empty, false, "") { CommunicationToken = token });
|
||||||
sut.Send(new ReconfigurationMessage("") { CommunicationToken = token });
|
sut.Send(new ReconfigurationMessage("") { CommunicationToken = token });
|
||||||
sut.Disconnect(new DisconnectionMessage { CommunicationToken = token });
|
sut.Disconnect(new DisconnectionMessage { CommunicationToken = token });
|
||||||
|
|
|
@ -330,11 +330,10 @@ namespace SafeExamBrowser.Runtime.UnitTests
|
||||||
clientProxy.Setup(c => c.ShowMessage(
|
clientProxy.Setup(c => c.ShowMessage(
|
||||||
It.IsAny<string>(),
|
It.IsAny<string>(),
|
||||||
It.IsAny<string>(),
|
It.IsAny<string>(),
|
||||||
// TODO
|
It.Is<int>(a => a == (int) MessageBoxAction.Confirm),
|
||||||
//It.Is<MessageBoxAction>(a => a == MessageBoxAction.Confirm),
|
It.IsAny<int>(),
|
||||||
//It.IsAny<MessageBoxIcon>(),
|
|
||||||
It.IsAny<Guid>()))
|
It.IsAny<Guid>()))
|
||||||
.Callback<string, string, MessageBoxAction, MessageBoxIcon, Guid>((m, t, a, i, id) =>
|
.Callback<string, string, int, int, Guid>((m, t, a, i, id) =>
|
||||||
{
|
{
|
||||||
runtimeHost.Raise(r => r.MessageBoxReplyReceived += null, new MessageBoxReplyEventArgs { RequestId = id });
|
runtimeHost.Raise(r => r.MessageBoxReplyReceived += null, new MessageBoxReplyEventArgs { RequestId = id });
|
||||||
})
|
})
|
||||||
|
@ -346,9 +345,8 @@ namespace SafeExamBrowser.Runtime.UnitTests
|
||||||
clientProxy.Verify(c => c.ShowMessage(
|
clientProxy.Verify(c => c.ShowMessage(
|
||||||
It.IsAny<string>(),
|
It.IsAny<string>(),
|
||||||
It.IsAny<string>(),
|
It.IsAny<string>(),
|
||||||
// TODO
|
It.Is<int>(a => a == (int) MessageBoxAction.Confirm),
|
||||||
//It.Is<MessageBoxAction>(a => a == MessageBoxAction.Confirm),
|
It.Is<int>(i => i == (int) args.Icon),
|
||||||
//It.Is<MessageBoxIcon>(i => i == args.Icon),
|
|
||||||
It.IsAny<Guid>()), Times.Once);
|
It.IsAny<Guid>()), Times.Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace SafeExamBrowser.Runtime.Communication
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case MessageBoxReplyMessage m:
|
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);
|
return new SimpleResponse(SimpleResponsePurport.Acknowledged);
|
||||||
case PasswordReplyMessage m:
|
case PasswordReplyMessage m:
|
||||||
PasswordReceived?.InvokeAsync(new PasswordReplyEventArgs { Password = m.Password, RequestId = m.RequestId, Success = m.Success });
|
PasswordReceived?.InvokeAsync(new PasswordReplyEventArgs { Password = m.Password, RequestId = m.RequestId, Success = m.Success });
|
||||||
|
|
|
@ -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 requestId = Guid.NewGuid();
|
||||||
var result = MessageBoxResult.None;
|
var result = MessageBoxResult.None;
|
||||||
|
@ -459,12 +459,12 @@ namespace SafeExamBrowser.Runtime
|
||||||
|
|
||||||
runtimeHost.MessageBoxReplyReceived += responseEventHandler;
|
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)
|
if (communication.Success)
|
||||||
{
|
{
|
||||||
responseEvent.WaitOne();
|
responseEvent.WaitOne();
|
||||||
// TODO result = response.Result;
|
result = (MessageBoxResult) response.Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
runtimeHost.MessageBoxReplyReceived -= responseEventHandler;
|
runtimeHost.MessageBoxReplyReceived -= responseEventHandler;
|
||||||
|
|
Loading…
Reference in a new issue