public async Task SendMessageViaDebuggerClient() { // Arrange var connectionMock = new Mock<IDebuggerConnection>(); var messageEventArgs = new MessageEventArgs(Resources.NodeDisconnectResponse); connectionMock.Setup(p => p.SendMessage(It.IsAny<string>())) .Raises(f => f.OutputMessage += null, messageEventArgs); var client = new DebuggerClient(connectionMock.Object); var disconnectCommand = new DisconnectCommand(10); // Act await client.SendRequestAsync(disconnectCommand); // Assert Assert.IsTrue(disconnectCommand.Running); }
public void RaiseCompileScriptEventViaDebuggerClient() { // Arrange var connectionMock = new Mock<IDebuggerConnection>(); var messageEventArgs = new MessageEventArgs(Resources.NodeCompileScriptResponse); var client = new DebuggerClient(connectionMock.Object); object sender = null; CompileScriptEventArgs args = null; // Act client.CompileScriptEvent += (s, a) => { sender = s; args = a; }; connectionMock.Raise(f => f.OutputMessage += null, messageEventArgs); // Assert Assert.AreEqual(client, sender); Assert.IsNotNull(args); Assert.IsNotNull(args.CompileScriptEvent); }
/// <summary> /// Process message from debugger connection. /// </summary> /// <param name="sender">Sender.</param> /// <param name="args">Event arguments.</param> private void OnOutputMessage(object sender, MessageEventArgs args) { JObject message = JObject.Parse(args.Message); var messageType = (string)message["type"]; switch (messageType) { case "event": HandleEventMessage(message); break; case "response": HandleResponseMessage(message); break; default: Debug.Fail(string.Format("Unrecognized type '{0}' in message: {1}", messageType, message)); break; } }
/// <summary> /// Process message from debugger connection. /// </summary> /// <param name="sender">Sender.</param> /// <param name="args">Event arguments.</param> private void OnOutputMessage(object sender, MessageEventArgs args) { var message = Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(args.Message, jsonSettings); var messageType = (string)message["type"]; switch (messageType) { case "event": HandleEventMessage(message); break; case "response": HandleResponseMessage(message); break; default: Debug.Fail(string.Format(CultureInfo.CurrentCulture, "Unrecognized type '{0}' in message: {1}", messageType, message)); break; } }