public void Name_For_Class_With_CamelCase_Name_Has_Spaces_Separating_Words() { var commandFile = new IronPythonCommandFile(_engine, @"class CommandName(BaseIronPythonCommand): def Execute(self, args): return 1"); Assert.Equal("Command Name", commandFile.First().Name); }
public void Ignores_Methods_Starting_With_Underscore() { var commandFile = new IronPythonCommandFile(_engine, @"def _CommandName(args): return ""result"""); Assert.False(commandFile.Any()); }
public void Default_Description_Is_The_Name() { var commandFile = new IronPythonCommandFile(_engine, @"def CommandName(args): return ""result"""); Assert.Equal("Command Name", commandFile.First().Description); Assert.Equal("Command Name", commandFile.First().GetDescription(string.Empty)); }
public void Default_Description_Is_The_Name() { var commandFile = new IronPythonCommandFile(_engine, @"def CommandName(args): return ""result"""); Assert.Equal("Command Name", commandFile.First().Description); Assert.Equal("Command Name", commandFile.First().GetDescription(string.Empty)); }
public void DocString_Serves_As_Description_For() { var commandFile = new IronPythonCommandFile(_engine, @"def CommandName(args): """"""This is the description"""""" return ""result"""); Assert.Equal("This is the description", commandFile.First().GetDescription(string.Empty)); Assert.Equal("This is the description", commandFile.First().Description); }
public void Can_Create_Command_From_Method() { var commandFile = new IronPythonCommandFile(_engine, @"def CommandName(args): return ""result"""); Assert.True(commandFile.Any()); var command = commandFile.First(); Assert.Equal("Command Name",command.Name); }
public void DocString_Serves_As_Description_For() { var commandFile = new IronPythonCommandFile(_engine, @"def CommandName(args): """"""This is the description"""""" return ""result"""); Assert.Equal("This is the description", commandFile.First().GetDescription(string.Empty)); Assert.Equal("This is the description", commandFile.First().Description); }
public void Name_For_Class_With_GetName_Is_Result_Of_GetName() { var commandFile = new IronPythonCommandFile(_engine, @"class Command(BaseIronPythonCommand): def GetName(self): return ""Name"" def Execute(self, args): return 1"); Assert.Equal(1, commandFile.Count()); Assert.Equal("Name", commandFile.First().Name); }
public void Can_Call_GetName_With_Two_Arguments() { var commandFile = new IronPythonCommandFile(_engine, @"class CommandName(BaseIronPythonCommand): def GetName(self): return ""Name"" def Execute(self, args): return"); var command = commandFile.First(); Assert.Equal("Name",command.GetName("")); }
public void Can_Create_Command_From_Method() { var commandFile = new IronPythonCommandFile(_engine, @"def CommandName(args): return ""result"""); Assert.True(commandFile.Any()); var command = commandFile.First(); Assert.Equal("Command Name", command.Name); }
public void Can_Call_GetName_With_Two_Arguments() { var commandFile = new IronPythonCommandFile(_engine, @"class CommandName(BaseIronPythonCommand): def GetName(self): return ""Name"" def Execute(self, args): return"); var command = commandFile.First(); Assert.Equal("Name", command.GetName("")); }
public void Class_With_Docstring_Has_Description_And_No_Description_Method_Uses_Docstring_As_Description() { var commandFile = new IronPythonCommandFile(_engine, @" class CommandName(BaseIronPythonCommand): """"""This is the description"""""" def Execute(self, args): return ""None"" "); var command = commandFile.First(); Assert.Equal("This is the description", command.GetDescription(string.Empty)); Assert.Equal("This is the description", command.Description); }
public void Class_With_Docstring_Has_Description_And_No_Description_Method_Uses_Docstring_As_Description() { var commandFile = new IronPythonCommandFile(_engine, @" class CommandName(BaseIronPythonCommand): """"""This is the description"""""" def Execute(self, args): return ""None"" "); var command = commandFile.First(); Assert.Equal("This is the description", command.GetDescription(string.Empty)); Assert.Equal("This is the description", command.Description); }
public void ValueException_Shows_Error_Line_And_Column() { var code = @" class CommandName(BaseIronPythonCommand): (invalid) "; try { var commandFile = new IronPythonCommandFile(_engine, code); } catch (PythonException e) { Assert.IsType <UnboundNameException>(e.InnerException); } }
public void Output_Line_And_File_On_Syntax_Exception() { var code = @" class CommandName(BaseIronPythonCommand): """"""This is the description"""""" def Execute(self, args): return ""None"" "; try { var commandFile = new IronPythonCommandFile(_engine,code); } catch (SyntaxErrorException e) { Console.WriteLine(e); } }
public void Output_Line_And_File_On_Syntax_Exception() { var code = @" class CommandName(BaseIronPythonCommand): """"""This is the description"""""" def Execute(self, args): return ""None"" "; try { var commandFile = new IronPythonCommandFile(_engine, code); } catch (SyntaxErrorException e) { Console.WriteLine(e); } }
public void Syntax_Exception_Shows_Error_Line_And_Column() { var code = @" class CommandName(BaseIronPythonCommand): %invalid) "; try { var commandFile = new IronPythonCommandFile(_engine,code); } catch (SyntaxErrorExceptionPrettyWrapper e) { var lines = e.Message.Split('\n'); Assert.Equal("Line 3", lines[1]); Assert.Equal(" %invalid)", lines[2]); Assert.Equal(" ^---", lines[3].Substring(0,7)); } }
public void Syntax_Exception_Shows_Error_Line_And_Column() { var code = @" class CommandName(BaseIronPythonCommand): %invalid) "; try { var commandFile = new IronPythonCommandFile(_engine, code); } catch (SyntaxErrorExceptionPrettyWrapper e) { var lines = e.Message.Split('\n'); Assert.Equal("Line 3", lines[1]); Assert.Equal(" %invalid)", lines[2]); Assert.Equal(" ^---", lines[3].Substring(0, 7)); } }
public void ValueException_Shows_Error_Line_And_Column() { var code = @" class CommandName(BaseIronPythonCommand): (invalid) "; try { var commandFile = new IronPythonCommandFile(_engine,code); } catch (PythonException e) { Assert.IsType<UnboundNameException>(e.InnerException); } }
public void Name_For_Class_With_CamelCase_Name_Has_Spaces_Separating_Words() { var commandFile = new IronPythonCommandFile(_engine, @"class CommandName(BaseIronPythonCommand): def Execute(self, args): return 1"); Assert.Equal("Command Name", commandFile.First().Name); }
public void Name_For_Class_With_GetName_Is_Result_Of_GetName() { var commandFile = new IronPythonCommandFile(_engine, @"class Command(BaseIronPythonCommand): def GetName(self): return ""Name"" def Execute(self, args): return 1"); Assert.Equal(1, commandFile.Count()); Assert.Equal("Name", commandFile.First().Name); }
public void Ignores_Methods_Starting_With_Underscore() { var commandFile = new IronPythonCommandFile(_engine, @"def _CommandName(args): return ""result"""); Assert.False(commandFile.Any()); }
private void LoadPythonCommandsForFile(string pythonFile) { var localCommands = new IronPythonCommandFile(_engine, new FileInfo(pythonFile)); Commands.AddRange(localCommands); _pythonCommands[pythonFile] = localCommands; }