public void CreateSetBreakpointCommand() {
            // Arrange
            const int commandId = 3;
            const int moduleId = 5;
            const int line = 2;
            const int column = 0;
            const string fileName = "module.js";
            var module = new NodeModule(moduleId, fileName);
            var breakOn = new BreakOn(BreakOnKind.Equal, 2);
            var position = new FilePosition(fileName, line, column);
            var breakpoint = new NodeBreakpoint(null, position, true, breakOn, null);

            // Act
            var setBreakpointCommand = new SetBreakpointCommand(commandId, module, breakpoint, false, false);

            // Assert
            Assert.AreEqual(commandId, setBreakpointCommand.Id);
            Assert.AreEqual(
                string.Format(
                    "{{\"command\":\"setbreakpoint\",\"seq\":{0},\"type\":\"request\",\"arguments\":{{\"line\":{1},\"column\":{2},\"type\":\"scriptId\",\"target\":{3},\"ignoreCount\":1}}}}",
                    commandId, line, column, module.Id),
                setBreakpointCommand.ToString());
        }
        private async Task<SetBreakpointCommand> SetBreakpointAsync(
            NodeBreakpoint breakpoint,
            bool withoutPredicate = false,
            CancellationToken cancellationToken = new CancellationToken()) {
            DebugWriteCommand("Set Breakpoint");

            // Try to find module
            NodeModule module = GetModuleForFilePath(breakpoint.Target.FileName);

            var setBreakpointCommand = new SetBreakpointCommand(CommandId, module, breakpoint, withoutPredicate, IsRemote, SourceMapper);
            await TrySendRequestAsync(setBreakpointCommand, cancellationToken).ConfigureAwait(false);

            return setBreakpointCommand;
        }
        public void CreateSetBreakpointCommandWithNullBreakpoint() {
            // Arrange
            const int commandId = 3;
            const int moduleId = 5;
            const string fileName = "module.js";
            var module = new NodeModule(moduleId, fileName);
            SetBreakpointCommand setBreakpointCommand = null;
            Exception exception = null;

            // Act
            try {
                setBreakpointCommand = new SetBreakpointCommand(commandId, module, null, false, false);
            } catch (Exception e) {
                exception = e;
            }

            // Assert
            Assert.IsNull(setBreakpointCommand);
            Assert.IsNotNull(exception);
            Assert.IsInstanceOfType(exception, typeof (ArgumentNullException));
        }
        public void ProcessSetBreakpointResponse() {
            // Arrange
            const int commandId = 3;
            const int moduleId = 33;
            const int line = 2;
            const int column = 0;
            const string fileName = "module.js";
            var module = new NodeModule(moduleId, fileName);
            var breakOn = new BreakOn(BreakOnKind.Equal, 2);
            var position = new FilePosition(fileName, line, column);
            var breakpoint = new NodeBreakpoint(null, position, true, breakOn, null);
            var setBreakpointCommand = new SetBreakpointCommand(commandId, module, breakpoint, false, false);
            JObject breakpointResponse = SerializationTestData.GetSetBreakpointResponse();

            // Act
            setBreakpointCommand.ProcessResponse(breakpointResponse);

            // Assert
            Assert.AreEqual(2, setBreakpointCommand.BreakpointId);
            Assert.AreEqual(0, setBreakpointCommand.Column);
            Assert.AreEqual(0, setBreakpointCommand.Line);
            Assert.AreEqual(false, setBreakpointCommand.Running);
            Assert.AreEqual(33, setBreakpointCommand.ScriptId);
        }
        public void CreateSetBreakpointCommandOnLocalFile() {
            // Arrange
            const int commandId = 3;
            const int line = 2;
            const int column = 0;
            const string fileName = @"c:\module.js";
            var breakOn = new BreakOn(BreakOnKind.Equal, 2);
            var position = new FilePosition(fileName, line, column);
            var breakpoint = new NodeBreakpoint(null, position, true, breakOn, null);

            // Act
            var setBreakpointCommand = new SetBreakpointCommand(commandId, null, breakpoint, false, false);

            // Assert
            Assert.AreEqual(commandId, setBreakpointCommand.Id);
            Assert.AreEqual(
                string.Format(
                    "{{\"command\":\"setbreakpoint\",\"seq\":{0},\"type\":\"request\",\"arguments\":{{\"line\":{1},\"column\":{2},\"type\":\"scriptRegExp\",\"target\":\"{3}\",\"ignoreCount\":1}}}}",
                    commandId, line, column, SetBreakpointCommand.CreateLocalScriptRegExp(fileName).Replace(@"\", @"\\")),
                setBreakpointCommand.ToString());
        }
        public void CreateSetBreakpointCommandOnRemoteFile() {
            // Arrange
            const int commandId = 3;
            const int line = 2;
            const int column = 0;
            const string fileName = @"module.js";
            var breakOn = new BreakOn(BreakOnKind.Equal, 2);
            var position = new FilePosition(fileName, line, column);
            var breakpoint = new NodeBreakpoint(null, position, true, breakOn, null);

            // Act
            var setBreakpointCommand = new SetBreakpointCommand(commandId, null, breakpoint, false, true);

            // Assert
            Assert.AreEqual(commandId, setBreakpointCommand.Id);
            Assert.AreEqual(
                string.Format(
                    "{{\"command\":\"setbreakpoint\",\"seq\":{0},\"type\":\"request\",\"arguments\":{{\"line\":{1},\"column\":{2},\"type\":\"scriptRegExp\",\"target\":\"^[Mm][Oo][Dd][Uu][Ll][Ee]\\\\.[Jj][Ss]$\",\"ignoreCount\":1}}}}",
                    commandId, line, column),
                setBreakpointCommand.ToString());
        }