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 CreateLocalScriptRegExpShouldOnlyMatchExactPath() { const string drive = "c:"; var pathParts = new[] { "nOdE", "IS", "awsome.js" }; string fileName = Path.Combine(drive, Path.Combine(pathParts)); var scriptRegExp = new Regex(SetBreakpointCommand.CreateLocalScriptRegExp(fileName)); Assert.IsFalse(scriptRegExp.IsMatch(Path.Combine("d:", Path.Combine(pathParts)))); Assert.IsFalse(scriptRegExp.IsMatch(fileName + 'x')); Assert.IsFalse(scriptRegExp.IsMatch(Path.Combine(fileName, "x"))); Assert.IsFalse(scriptRegExp.IsMatch("x" + fileName)); }
public void CreateLocalScriptRegExpShouldCreateCaseInSensitiveRegularExpression() { const string drive = "c:"; var pathParts = new[] { "nOdE", "IS", "awesome.js" }; string fileName = Path.Combine(drive, Path.Combine(pathParts)); var scriptRegExp = new Regex(SetBreakpointCommand.CreateLocalScriptRegExp(fileName)); Assert.IsTrue(scriptRegExp.IsMatch(fileName)); Assert.IsTrue(scriptRegExp.IsMatch(fileName.ToUpperInvariant())); Assert.IsTrue(scriptRegExp.IsMatch(fileName.ToLowerInvariant())); Assert.IsTrue(scriptRegExp.IsMatch(Path.Combine(drive.ToUpperInvariant(), Path.Combine(pathParts)))); Assert.IsTrue(scriptRegExp.IsMatch(Path.Combine(drive.ToLowerInvariant(), Path.Combine(pathParts)))); }
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()); }
public void CreateSetBreakpointCommandOnFirstLine() { // Arrange const int commandId = 3; const int moduleId = 5; const int line = 0; const int column = 0; const string fileName = "c:\\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 + NodeConstants.ScriptWrapBegin.Length, module.Id), setBreakpointCommand.ToString()); }