public void CreateCompileScriptEvent() {
            // Arrange
            JObject message = JObject.Parse(Resources.NodeCompileScriptResponse);

            // Act
            var compileScriptEvent = new CompileScriptEvent(message);

            // Assert
            Assert.IsNotNull(compileScriptEvent.Module);
            Assert.AreEqual(34, compileScriptEvent.Module.Id);
            Assert.AreEqual("http.js", compileScriptEvent.Module.Name);
            Assert.AreEqual(true, compileScriptEvent.Running);
        }
        public void CreateCompileScriptEventWithNullScriptName()
        {
            // Arrange
            JObject message = JObject.Parse(Resources.NodeCompileScriptResponseWithNullScriptName);

            // Act
            var compileScriptEvent = new CompileScriptEvent(message);

            // Assert
            Assert.IsNotNull(compileScriptEvent.Module);
            Assert.AreEqual(172, compileScriptEvent.Module.Id);
            Assert.AreEqual(NodeVariableType.UnknownModule, compileScriptEvent.Module.Name);
            Assert.AreEqual(true, compileScriptEvent.Running);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles event message.
        /// </summary>
        /// <param name="message">Message.</param>
        private void HandleEventMessage(JObject message) {
            var eventType = (string)message["event"];
            switch (eventType) {
                case "afterCompile":
                    EventHandler<CompileScriptEventArgs> compileScriptHandler = CompileScriptEvent;
                    if (compileScriptHandler != null) {
                        var compileScriptEvent = new CompileScriptEvent(message);
                        compileScriptHandler(this, new CompileScriptEventArgs(compileScriptEvent));
                    }
                    break;

                case "break":
                    EventHandler<BreakpointEventArgs> breakpointHandler = BreakpointEvent;
                    if (breakpointHandler != null) {
                        var breakpointEvent = new BreakpointEvent(message);
                        breakpointHandler(this, new BreakpointEventArgs(breakpointEvent));
                    }
                    break;

                case "exception":
                    EventHandler<ExceptionEventArgs> exceptionHandler = ExceptionEvent;
                    if (exceptionHandler != null) {
                        var exceptionEvent = new ExceptionEvent(message);
                        exceptionHandler(this, new ExceptionEventArgs(exceptionEvent));
                    }
                    break;

                case "beforeCompile":
                case "breakForCommand":
                case "newFunction":
                case "scriptCollected":
                case "compileError":
                    break;

                default:
                    Debug.Fail(string.Format("Unrecognized type '{0}' in event message: {1}", eventType, message));
                    break;
            }
        }
Exemplo n.º 4
0
 public CompileScriptEventArgs(CompileScriptEvent compileScriptEvent) {
     CompileScriptEvent = compileScriptEvent;
 }