Browse Source

IronRuby addin now uses AvalonEdit.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5970 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Matt Ward 16 years ago
parent
commit
a152542520
  1. 2
      src/AddIns/BackendBindings/Ruby/RubyBinding.sln
  2. 10
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/RubyBinding.addin
  3. 30
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/RubyBinding.csproj
  4. 32
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/ConsoleTextEditorKeyEventArgs.cs
  5. 33
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/ControlDispatcher.cs
  6. 25
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/ConvertProjectToRubyProjectCommand.cs
  7. 47
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/ConvertToRubyMenuCommand.cs
  8. 34
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/IConsoleTextEditor.cs
  9. 17
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/IControlDispatcher.cs
  10. 12
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/NRefactoryToRubyConverter.cs
  11. 74
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsole.cs
  12. 50
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsoleCompletionData.cs
  13. 34
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsoleCompletionDataProvider.cs
  14. 4
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsoleHost.cs
  15. 25
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsolePad.cs
  16. 183
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsoleTextEditor.cs
  17. 28
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsoleTextEditorKeyEventArgs.cs
  18. 22
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyDesignerGenerator.cs
  19. 1
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyDesignerLoader.cs
  20. 2
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyDesignerLoaderProvider.cs
  21. 76
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyFormattingStrategy.cs
  22. 9
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyFormsDesignerDisplayBinding.cs
  23. 27
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyLanguageBinding.cs
  24. 6
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyOptionsPanel.cs
  25. 6
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyOutputStream.cs
  26. 58
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTextEditorViewContent.cs
  27. 192
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/TextEditor.cs
  28. 71
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/AddInOptionsTestFixture.cs
  29. 2
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Configuration/RubyAddInOptionsTestFixture.cs
  30. 11
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/CodeCompletionTests.cs
  31. 145
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/ConsoleTextEditorTestFixture.cs
  32. 111
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/ConsoleTextEditorThreadSafetyTestFixture.cs
  33. 5
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/DisposedRubyConsoleTestFixture.cs
  34. 47
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/InsertConsoleCompletionDataTestFixture.cs
  35. 27
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/KeysPressedWhenCompletionWindowOpenTestFixture.cs
  36. 11
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleCodeCompletionTestFixture.cs
  37. 49
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleCommandLineHistoryTestFixture.cs
  38. 18
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleCurrentLineTestFixture.cs
  39. 28
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleEnterKeyTestFixture.cs
  40. 13
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleHomeKeyTestFixture.cs
  41. 21
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleHostTests.cs
  42. 92
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleReadOnlyRegionsTestFixture.cs
  43. 40
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleReadTestFixture.cs
  44. 29
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleUnreadLinesTestFixture.cs
  45. 19
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleWriteTestFixture.cs
  46. 5
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyOutputStreamTestFixture.cs
  47. 402
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/TextEditorTestFixture.cs
  48. 41
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/TwoRubyConsoleLinesWaitingTestFixture.cs
  49. 9
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/ConvertCSharpToRubyMenuCommandTestFixture.cs
  50. 21
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/ConvertToRubyProjectCommandTestFixture.cs
  51. 9
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/ConvertVBNetToRubyMenuCommandTestFixture.cs
  52. 4
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/FormsDesignerDisplayBindingTestFixture.cs
  53. 1
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs
  54. 6
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/InsertEventHandlerTestFixtureBase.cs
  55. 4
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/InsertEventHandlerWithSpaceIndentTestFixture.cs
  56. 42
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/MergeFormTestFixture.cs
  57. 46
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/NoNewLineAfterInitializeComponentMethodTestFixture.cs
  58. 1
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/NullGeneratorPassedToLoader.cs
  59. 2
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/OneCompatibleMethodTestFixture.cs
  60. 158
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/ProjectRootNamespacePassedToMergeTestFixture.cs
  61. 1
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/RubyDesignerLoaderTestFixture.cs
  62. 8
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/TextEditorIndentPassedToGeneratorTestFixture.cs
  63. 2
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/DebugRunRubyCommandTestFixture.cs
  64. 206
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RubyIndentationTests.cs
  65. 6
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RubyOptionsPanelTestFixture.cs
  66. 2
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RunRubyCommandTestFixture.cs
  67. 1
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseClassMethodWithBodyTestFixture.cs
  68. 1
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseClassWithBaseClassTestFixture.cs
  69. 1
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseClassWithCtorTestFixture.cs
  70. 8
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseClassWithNewLineBeforeMethodTestFixture.cs
  71. 1
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseClassWithSingleMethodTestFixture.cs
  72. 1
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseMethodWithOptionalParametersTestFixture.cs
  73. 1
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseMethodWithParametersTestFixture.cs
  74. 1
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseMethodsWithNoClassTestFixture.cs
  75. 1
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseModuleTestFixture.cs
  76. 1
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseRequireFollowedByCommentTestFixture.cs
  77. 1
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseRequireTestFixture.cs
  78. 45
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj
  79. 2
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyLanguage/CreateNewRubyProjectTestFixture.cs
  80. 2
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyLanguage/ProjectBindingTestFixture.cs
  81. 44
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyLanguage/RubyLanguageBindingTestFixture.cs
  82. 2
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyLanguage/RubyLanguagePropertiesTests.cs
  83. 52
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/DerivedAddInOptions.cs
  84. 20
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/DerivedConvertProjectToRubyProjectCommand.cs
  85. 7
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/DerivedRubyConsoleHost.cs
  86. 9
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/DerivedRubyDesignerGenerator.cs
  87. 1
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/DerivedRubyDesignerLoader.cs
  88. 120
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockConsoleTextEditor.cs
  89. 28
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockConsoleTextEditorKeyEventArgs.cs
  90. 50
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockControlDispatcher.cs
  91. 4
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockDesignerLoaderHost.cs
  92. 19
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockEditableViewContent.cs
  93. 25
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockKeyboardDevice.cs
  94. 41
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockPresentationSource.cs
  95. 2
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockProject.cs
  96. 10
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockProjectContent.cs
  97. 138
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockTextEditor.cs
  98. 38
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockTextEditorOptions.cs
  99. 85
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockTextEditorProperties.cs
  100. 13
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockTextEditorViewContent.cs
  101. Some files were not shown because too many files have changed in this diff Show More

2
src/AddIns/BackendBindings/Ruby/RubyBinding.sln

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.0.0.5545
# SharpDevelop 4.0.0.5967
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RubyBinding", "RubyBinding\Project\RubyBinding.csproj", "{C896FFFF-5B6C-4B0E-B6DF-049865F501B4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RubyBinding.Tests", "RubyBinding\Test\RubyBinding.Tests.csproj", "{01DF0475-0CB2-4E81-971B-BADC60CDE3A5}"

10
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/RubyBinding.addin

@ -23,10 +23,6 @@ @@ -23,10 +23,6 @@
resource="ICSharpCode.RubyBinding.Resources.Ruby.xshd"/>
</Path>
<!--<Path name="/AddIns/DefaultTextEditor/Formatter/Ruby">
<Class id="RubyFormatter" class="ICSharpCode.RubyBinding.RubyFormattingStrategy"/>
</Path>-->
<!-- Add the "Ruby" entry to the Open File Dialog -->
<Path name="/SharpDevelop/Workbench/FileFilter">
<FileFilter id="Ruby"
@ -97,6 +93,12 @@ @@ -97,6 +93,12 @@
class="ICSharpCode.RubyBinding.RubyProjectBinding" />
</Path>
<Path name="/SharpDevelop/Workbench/LanguageBindings">
<LanguageBinding id="Ruby"
class="ICSharpCode.RubyBinding.RubyLanguageBinding"
extensions=".rb" />
</Path>
<!-- The Ruby code completion binding -->
<!-- <Path name = "/AddIns/DefaultTextEditor/CodeCompletion">
<CodeCompletionBinding id="Ruby"

30
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/RubyBinding.csproj

@ -56,25 +56,40 @@ @@ -56,25 +56,40 @@
<Reference Include="Microsoft.Scripting">
<HintPath>..\..\IronRuby\bin\Microsoft.Scripting.dll</HintPath>
</Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>Configuration\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\AddInOptions.cs" />
<Compile Include="Src\CommandLineHistory.cs" />
<Compile Include="Src\ConsoleTextEditorKeyEventArgs.cs" />
<Compile Include="Src\ControlDispatcher.cs" />
<Compile Include="Src\IControlDispatcher.cs" />
<Compile Include="Src\RubyConsoleCompletionData.cs" />
<Compile Include="Src\ConvertProjectToRubyProjectCommand.cs" />
<Compile Include="Src\ConvertToRubyMenuCommand.cs" />
<Compile Include="Src\IComponentCreator.cs" />
<Compile Include="Src\IMemberProvider.cs" />
<Compile Include="Src\ITextEditor.cs" />
<Compile Include="Src\IConsoleTextEditor.cs" />
<Compile Include="Src\NRefactoryToRubyConverter.cs" />
<Compile Include="Src\RubyAddInOptions.cs" />
<Compile Include="Src\RubyAstWalker.cs" />
@ -88,6 +103,7 @@ @@ -88,6 +103,7 @@
<Compile Include="Src\RubyConsoleCompletionDataProvider.cs" />
<Compile Include="Src\RubyConsoleHost.cs" />
<Compile Include="Src\RubyConsolePad.cs" />
<Compile Include="Src\RubyConsoleTextEditorKeyEventArgs.cs" />
<Compile Include="Src\RubyConstructorInfo.cs" />
<Compile Include="Src\RubyControlFieldExpression.cs" />
<Compile Include="Src\RubyDesignerGenerator.cs" />
@ -95,6 +111,7 @@ @@ -95,6 +111,7 @@
<Compile Include="Src\RubyDesignerLoaderProvider.cs" />
<Compile Include="Src\RubyFormattingStrategy.cs" />
<Compile Include="Src\RubyFormsDesignerDisplayBinding.cs" />
<Compile Include="Src\RubyLanguageBinding.cs" />
<Compile Include="Src\RubyProjectBinding.cs" />
<Compile Include="Src\RubyLanguageProperties.cs" />
<Compile Include="Src\RubyNameCreationService.cs" />
@ -103,9 +120,10 @@ @@ -103,9 +120,10 @@
<Compile Include="Src\RubyParser.cs" />
<Compile Include="Src\RubyProject.cs" />
<Compile Include="Src\RubyPropertyValueAssignment.cs" />
<Compile Include="Src\RubyTextEditorViewContent.cs" />
<Compile Include="Src\RunDebugRubyCommand.cs" />
<Compile Include="Src\RunRubyCommand.cs" />
<Compile Include="Src\TextEditor.cs" />
<Compile Include="Src\RubyConsoleTextEditor.cs" />
<EmbeddedResource Include="Resources\Ruby.xshd" />
<EmbeddedResource Include="Resources\RubyOptionsPanel.xfrm" />
<None Include="..\..\IronRuby\bin\ir.exe.config">
@ -141,9 +159,9 @@ @@ -141,9 +159,9 @@
<Folder Include="Resources" />
<Folder Include="Src" />
<Folder Include="Templates" />
<ProjectReference Include="..\..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj">
<Project>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</Project>
<Name>ICSharpCode.TextEditor</Name>
<ProjectReference Include="..\..\..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj">
<Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project>
<Name>ICSharpCode.AvalonEdit</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">

32
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/ConsoleTextEditorKeyEventArgs.cs

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Input;
namespace ICSharpCode.RubyBinding
{
public delegate void ConsoleTextEditorKeyEventHandler(object source, ConsoleTextEditorKeyEventArgs e);
public abstract class ConsoleTextEditorKeyEventArgs : EventArgs
{
Key key;
public ConsoleTextEditorKeyEventArgs(Key key)
{
this.key = key;
}
public Key Key {
get { return key; }
}
public abstract bool Handled {
get; set;
}
}
}

33
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/ControlDispatcher.cs

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows;
using System.Windows.Threading;
namespace ICSharpCode.RubyBinding
{
public class ControlDispatcher : IControlDispatcher
{
Dispatcher dispatcher;
public ControlDispatcher(UIElement uiElement)
{
dispatcher = uiElement.Dispatcher;
}
public bool CheckAccess()
{
return dispatcher.CheckAccess();
}
public object Invoke(Delegate method, params object[] args)
{
return dispatcher.Invoke(method, args);
}
}
}

25
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/ConvertProjectToRubyProjectCommand.cs

@ -14,9 +14,9 @@ using ICSharpCode.NRefactory.Ast; @@ -14,9 +14,9 @@ using ICSharpCode.NRefactory.Ast;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Project.Converter;
using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.RubyBinding
{
@ -25,17 +25,6 @@ namespace ICSharpCode.RubyBinding @@ -25,17 +25,6 @@ namespace ICSharpCode.RubyBinding
/// </summary>
public class ConvertProjectToRubyProjectCommand : LanguageConverter
{
ITextEditorProperties textEditorProperties;
public ConvertProjectToRubyProjectCommand(ITextEditorProperties textEditorProperties)
{
this.textEditorProperties = textEditorProperties;
}
public ConvertProjectToRubyProjectCommand() : this(SharpDevelopTextEditorProperties.Instance)
{
}
public override string TargetLanguageName {
get { return RubyProjectBinding.LanguageName; }
}
@ -57,7 +46,7 @@ namespace ICSharpCode.RubyBinding @@ -57,7 +46,7 @@ namespace ICSharpCode.RubyBinding
ParseInformation parseInfo = GetParseInfo(sourceItem.FileName);
NRefactoryToRubyConverter converter = NRefactoryToRubyConverter.Create(sourceItem.Include, parseInfo);
if (converter != null) {
targetItem.Include = ChangeExtension(sourceItem.Include);
targetItem.Include = ChangeFileExtensionToRubyFileExtension(sourceItem.Include);
string code = GetParseableFileContent(sourceItem.FileName);
string rubyCode = converter.Convert(code);
@ -68,8 +57,7 @@ namespace ICSharpCode.RubyBinding @@ -68,8 +57,7 @@ namespace ICSharpCode.RubyBinding
// Add code to call main method at the end of the file.
rubyCode += "\r\n\r\n" + converter.GenerateMainMethodCall(converter.EntryPointMethods[0]);
}
SaveFile(targetItem.FileName, rubyCode, textEditorProperties.Encoding);
SaveFile(targetItem.FileName, rubyCode, GetDefaultFileEncoding());
} else {
LanguageConverterConvertFile(sourceItem, targetItem);
}
@ -122,10 +110,15 @@ namespace ICSharpCode.RubyBinding @@ -122,10 +110,15 @@ namespace ICSharpCode.RubyBinding
return ParserService.GetParseInformation(fileName);
}
protected virtual Encoding GetDefaultFileEncoding()
{
return FileService.DefaultFileEncoding.GetEncoding();
}
/// <summary>
/// Changes the extension to ".rb"
/// </summary>
static string ChangeExtension(string fileName)
static string ChangeFileExtensionToRubyFileExtension(string fileName)
{
return Path.ChangeExtension(fileName, ".rb");
}

47
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/ConvertToRubyMenuCommand.cs

@ -7,13 +7,14 @@ @@ -7,13 +7,14 @@
using System;
using System.IO;
using ICSharpCode.AvalonEdit;
using ICSharpCode.Core;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.RubyBinding
{
@ -22,38 +23,44 @@ namespace ICSharpCode.RubyBinding @@ -22,38 +23,44 @@ namespace ICSharpCode.RubyBinding
/// </summary>
public class ConvertToRubyMenuCommand : AbstractMenuCommand
{
RubyTextEditorViewContent view;
public override void Run()
{
Run(WorkbenchSingleton.Workbench, SharpDevelopTextEditorProperties.Instance);
Run(WorkbenchSingleton.Workbench);
}
protected void Run(IWorkbench workbench, ITextEditorProperties textEditorProperties)
protected void Run(IWorkbench workbench)
{
// Get the code to convert.
IViewContent viewContent = workbench.ActiveWorkbenchWindow.ActiveViewContent;
IEditable editable = viewContent as IEditable;
// Generate the ruby code.
ParseInformation parseInfo = GetParseInformation(viewContent.PrimaryFileName);
NRefactoryToRubyConverter converter = NRefactoryToRubyConverter.Create(viewContent.PrimaryFileName, parseInfo);
converter.IndentString = NRefactoryToRubyConverter.GetIndentString(textEditorProperties);
string pythonCode = converter.Convert(editable.Text);
// Show the python code in a new window.
NewFile("Generated.rb", "Ruby", pythonCode);
view = new RubyTextEditorViewContent(workbench);
string code = GenerateRubyCode();
ShowRubyCodeInNewWindow(code);
}
/// <summary>
/// Creates a new file using the FileService by default.
/// </summary>
protected virtual void NewFile(string defaultName, string language, string content)
string GenerateRubyCode()
{
FileService.NewFile(defaultName, content);
ParseInformation parseInfo = GetParseInformation(view.PrimaryFileName);
NRefactoryToRubyConverter converter = NRefactoryToRubyConverter.Create(view.PrimaryFileName, parseInfo);
converter.IndentString = view.TextEditorOptions.IndentationString;
return converter.Convert(view.EditableView.Text);
}
void ShowRubyCodeInNewWindow(string code)
{
NewFile("Generated.rb", "Ruby", code);
}
protected virtual ParseInformation GetParseInformation(string fileName)
{
return ParserService.GetParseInformation(fileName);
}
/// <summary>
/// Creates a new file using the FileService by default.
/// </summary>
protected virtual void NewFile(string defaultName, string language, string content)
{
FileService.NewFile(defaultName, content);
}
}
}

34
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/ITextEditor.cs → src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/IConsoleTextEditor.cs

@ -6,11 +6,6 @@ @@ -6,11 +6,6 @@
// </file>
using System;
using System.Drawing;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
namespace ICSharpCode.RubyBinding
{
@ -19,41 +14,22 @@ namespace ICSharpCode.RubyBinding @@ -19,41 +14,22 @@ namespace ICSharpCode.RubyBinding
/// all the methods will be called on another thread not the main UI thread and will therefore need to
/// be invoked.
/// </summary>
public interface ITextEditor
public interface IConsoleTextEditor
{
/// <summary>
/// Fired when a key is pressed but before any text has been added to the text editor.
/// </summary>
/// <remarks>
/// The KeyPress handler should return true if the text editor should not process the key and not
/// insert any text.
/// </remarks>
event KeyEventHandler KeyPress;
/// <summary>
/// Fired when dialog key is pressed but before any text has been added to the text editor.
/// </summary>
/// <remarks>
/// The DialogKeyPress handler should return true if the text editor should not process the
/// dialog key.
/// The handler should set the ConsoleTextEditorKeyEventArgs.Handled to true if the text editor should not
/// process the key and not insert any text.
/// </remarks>
event DialogKeyProcessor DialogKeyPress;
/// <summary>
/// Gets or sets the indentation style.
/// </summary>
IndentStyle IndentStyle {get; set;}
event ConsoleTextEditorKeyEventHandler PreviewKeyDown;
/// <summary>
/// Inserts text at the current cursor location.
/// </summary>
void Write(string text);
/// <summary>
/// Inserts text at the current cursor location with the specified colour.
/// </summary>
void Write(string text, Color backgroundColor);
/// <summary>
/// Replaces the text at the specified index on the current line with the specified text.
/// </summary>
@ -92,7 +68,7 @@ namespace ICSharpCode.RubyBinding @@ -92,7 +68,7 @@ namespace ICSharpCode.RubyBinding
/// <summary>
/// Shows the code completion window.
/// </summary>
void ShowCompletionWindow(ICompletionDataProvider completionDataProvider);
void ShowCompletionWindow(RubyConsoleCompletionDataProvider completionDataProvider);
/// <summary>
/// Indicates whether the completion window is currently being displayed.

17
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/IControlDispatcher.cs

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
namespace ICSharpCode.RubyBinding
{
public interface IControlDispatcher
{
bool CheckAccess();
object Invoke(Delegate method, params object[] args);
}
}

12
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/NRefactoryToRubyConverter.cs

@ -16,7 +16,6 @@ using ICSharpCode.NRefactory.Parser; @@ -16,7 +16,6 @@ using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.PrettyPrinter;
using ICSharpCode.NRefactory.Visitors;
using Dom = ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.RubyBinding
{
@ -97,17 +96,6 @@ namespace ICSharpCode.RubyBinding @@ -97,17 +96,6 @@ namespace ICSharpCode.RubyBinding
return false;
}
/// <summary>
/// Gets the indentation string to use in the text editor based on the text editor properties.
/// </summary>
public static string GetIndentString(ITextEditorProperties textEditorProperties)
{
if (textEditorProperties.ConvertTabsToSpaces) {
return new String(' ', textEditorProperties.IndentationSize);
}
return "\t";
}
/// <summary>
/// Gets or sets the string that will be used to indent the generated Ruby code.
/// </summary>

74
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsole.cs

@ -9,9 +9,8 @@ using System; @@ -9,9 +9,8 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using System.Windows.Input;
using ICSharpCode.AvalonEdit.CodeCompletion;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Hosting.Shell;
@ -24,20 +23,18 @@ namespace ICSharpCode.RubyBinding @@ -24,20 +23,18 @@ namespace ICSharpCode.RubyBinding
ManualResetEvent disposedEvent = new ManualResetEvent(false);
WaitHandle[] waitHandles;
int promptLength;
ITextEditor textEditor;
IConsoleTextEditor textEditor;
List<string> previousLines = new List<string>();
CommandLineHistory commandLineHistory = new CommandLineHistory();
CommandLine commandLine;
public RubyConsole(ITextEditor textEditor, CommandLine commandLine)
public RubyConsole(IConsoleTextEditor textEditor, CommandLine commandLine)
{
waitHandles = new WaitHandle[] {lineReceivedEvent, disposedEvent};
this.commandLine = commandLine;
this.textEditor = textEditor;
textEditor.KeyPress += ProcessKeyPress;
textEditor.DialogKeyPress += ProcessDialogKeyPress;
textEditor.IndentStyle = IndentStyle.None;
textEditor.PreviewKeyDown += ProcessPreviewKeyDown;
}
public void Dispose()
@ -109,7 +106,7 @@ namespace ICSharpCode.RubyBinding @@ -109,7 +106,7 @@ namespace ICSharpCode.RubyBinding
public bool IsLineAvailable {
get {
lock (previousLines) {
return previousLines.Count > 0;
return (previousLines.Count > 0);
}
}
}
@ -139,56 +136,51 @@ namespace ICSharpCode.RubyBinding @@ -139,56 +136,51 @@ namespace ICSharpCode.RubyBinding
/// <summary>
/// Processes characters entered into the text editor by the user.
/// </summary>
bool ProcessKeyPress(char ch)
void ProcessPreviewKeyDown(object source, ConsoleTextEditorKeyEventArgs e)
{
if (IsInReadOnlyRegion) {
return true;
}
if (ch == '\n') {
OnEnterKeyPressed();
}
if (ch == '.') {
ShowCompletionWindow();
}
return false;
Key keyPressed = e.Key;
e.Handled = HandleKeyDown(keyPressed);
}
/// <summary>
/// Process dialog keys such as the enter key when typed into the editor by the user.
/// </summary>
bool ProcessDialogKeyPress(Keys keyData)
{
bool HandleKeyDown(Key keyPressed)
{
if (textEditor.IsCompletionWindowDisplayed) {
return false;
}
if (IsInReadOnlyRegion) {
switch (keyData) {
case Keys.Left:
case Keys.Right:
case Keys.Up:
case Keys.Down:
switch (keyPressed) {
case Key.Left:
case Key.Right:
case Key.Up:
case Key.Down:
return false;
default:
return true;
}
}
switch (keyData) {
case Keys.Back:
switch (keyPressed) {
case Key.Back:
return !CanBackspace;
case Keys.Home:
case Key.Home:
MoveToHomePosition();
return true;
case Keys.Down:
case Key.Down:
MoveToNextCommandLine();
return true;
case Keys.Up:
case Key.Up:
MoveToPreviousCommandLine();
return true;
}
if (keyPressed == Key.Return) {
OnEnterKeyPressed();
}
if (keyPressed == Key.OemPeriod) {
ShowCompletionWindow();
}
return false;
}
@ -242,14 +234,14 @@ namespace ICSharpCode.RubyBinding @@ -242,14 +234,14 @@ namespace ICSharpCode.RubyBinding
/// Only the last line in the text editor is not read only.
/// </summary>
bool IsCurrentLineReadOnly {
get { return textEditor.Line < textEditor.TotalLines - 1; }
get { return textEditor.Line < (textEditor.TotalLines - 1); }
}
/// <summary>
/// Determines whether the current cursor position is in a prompt.
/// </summary>
bool IsInPrompt {
get { return textEditor.Column - promptLength < 0; }
get { return (textEditor.Column - promptLength) < 0; }
}
/// <summary>
@ -259,7 +251,7 @@ namespace ICSharpCode.RubyBinding @@ -259,7 +251,7 @@ namespace ICSharpCode.RubyBinding
get {
int cursorIndex = textEditor.Column - promptLength;
int selectionStartIndex = textEditor.SelectionStart - promptLength;
return cursorIndex > 0 && selectionStartIndex > 0;
return (cursorIndex > 0) && (selectionStartIndex > 0);
}
}
@ -307,6 +299,6 @@ namespace ICSharpCode.RubyBinding @@ -307,6 +299,6 @@ namespace ICSharpCode.RubyBinding
{
RubyConsoleCompletionDataProvider completionProvider = new RubyConsoleCompletionDataProvider(this);
textEditor.ShowCompletionWindow(completionProvider);
}
}
}
}

50
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsoleCompletionData.cs

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Media;
using ICSharpCode.AvalonEdit.CodeCompletion;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
namespace ICSharpCode.RubyBinding
{
public class RubyConsoleCompletionData : ICompletionData
{
string text = String.Empty;
public RubyConsoleCompletionData(string text)
{
this.text = text;
}
public ImageSource Image {
get { return null; }
}
public string Text {
get { return text; }
}
public object Content {
get { return text; }
}
public object Description {
get { return null; }
}
public double Priority {
get { return 0; }
}
public void Complete(TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs)
{
textArea.Document.Replace(completionSegment, text);
}
}
}

34
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsoleCompletionDataProvider.cs

@ -7,32 +7,31 @@ @@ -7,32 +7,31 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.AvalonEdit.CodeCompletion;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
namespace ICSharpCode.RubyBinding
{
/// <summary>
/// Provides code completion for the Ruby Console window.
/// </summary>
public class RubyConsoleCompletionDataProvider : AbstractCompletionDataProvider
public class RubyConsoleCompletionDataProvider
{
IMemberProvider memberProvider;
public RubyConsoleCompletionDataProvider(IMemberProvider memberProvider)
{
this.memberProvider = memberProvider;
DefaultIndex = 0;
//DefaultIndex = 0;
}
public override ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped)
public ICompletionData[] GenerateCompletionData(IConsoleTextEditor textEditor)
{
return GenerateCompletionData(GetLineText(textArea));
string line = textEditor.GetLine(textEditor.TotalLines - 1);
return GenerateCompletionData(line);
}
/// <summary>
@ -42,13 +41,13 @@ namespace ICSharpCode.RubyBinding @@ -42,13 +41,13 @@ namespace ICSharpCode.RubyBinding
/// </summary>
public ICompletionData[] GenerateCompletionData(string line)
{
List<DefaultCompletionData> items = new List<DefaultCompletionData>();
List<RubyConsoleCompletionData> items = new List<RubyConsoleCompletionData>();
string name = GetName(line);
if (!String.IsNullOrEmpty(name)) {
try {
foreach (string member in memberProvider.GetMemberNames(name)) {
items.Add(new DefaultCompletionData(member, String.Empty, ClassBrowserIconService.Method.ImageIndex));
items.Add(new RubyConsoleCompletionData(member));
}
} catch {
// Do nothing.
@ -62,14 +61,5 @@ namespace ICSharpCode.RubyBinding @@ -62,14 +61,5 @@ namespace ICSharpCode.RubyBinding
int startIndex = text.LastIndexOf(' ');
return text.Substring(startIndex + 1);
}
/// <summary>
/// Gets the line of text up to the cursor position.
/// </summary>
string GetLineText(TextArea textArea)
{
LineSegment lineSegment = textArea.Document.GetLineSegmentForOffset(textArea.Caret.Offset);
return textArea.Document.GetText(lineSegment);
}
}
}

4
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsoleHost.cs

@ -19,10 +19,10 @@ namespace ICSharpCode.RubyBinding @@ -19,10 +19,10 @@ namespace ICSharpCode.RubyBinding
public class RubyConsoleHost : ConsoleHost, IDisposable
{
Thread thread;
ITextEditor textEditor;
IConsoleTextEditor textEditor;
RubyConsole rubyConsole;
public RubyConsoleHost(ITextEditor textEditor)
public RubyConsoleHost(IConsoleTextEditor textEditor)
{
this.textEditor = textEditor;
}

25
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsolePad.cs

@ -6,37 +6,36 @@ @@ -6,37 +6,36 @@
// </file>
using System;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using AvalonEdit = ICSharpCode.AvalonEdit;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.TextEditor;
namespace ICSharpCode.RubyBinding
{
public class RubyConsolePad : AbstractPadContent
{
TextEditor textEditor;
TextEditorControl textEditorControl;
RubyConsoleTextEditor consoleTextEditor;
AvalonEdit.TextEditor textEditor;
RubyConsoleHost host;
public RubyConsolePad()
{
textEditorControl = new TextEditorControl();
textEditorControl.CreateControl();
textEditor = new TextEditor(textEditorControl);
host = new RubyConsoleHost(textEditor);
host.Run();
textEditor = new AvalonEdit.TextEditor();
consoleTextEditor = new RubyConsoleTextEditor(textEditor);
host = new RubyConsoleHost(consoleTextEditor);
host.Run();
}
public override object Control {
get { return textEditorControl; }
get { return textEditor; }
}
public override void Dispose()
{
host.Dispose();
textEditorControl.Dispose();
}
public override object InitiallyFocusedControl {
get { return textEditor; }
}
}
}

183
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsoleTextEditor.cs

@ -0,0 +1,183 @@ @@ -0,0 +1,183 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Drawing;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;
using ICSharpCode.AvalonEdit;
using ICSharpCode.AvalonEdit.CodeCompletion;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.RubyBinding
{
public class RubyConsoleTextEditor : IConsoleTextEditor
{
delegate string GetLineInvoker(int index);
TextEditor textEditor;
Color customLineColour = Color.LightGray;
BeginReadOnlySectionProvider readOnlyRegion;
IControlDispatcher dispatcher;
CompletionWindow completionWindow;
public RubyConsoleTextEditor(TextEditor textEditor)
: this(textEditor, new ControlDispatcher(textEditor))
{
}
public RubyConsoleTextEditor(TextEditor textEditor, IControlDispatcher dispatcher)
{
this.textEditor = textEditor;
this.dispatcher = dispatcher;
readOnlyRegion = new BeginReadOnlySectionProvider();
textEditor.TextArea.ReadOnlySectionProvider = readOnlyRegion;
textEditor.PreviewKeyDown += OnTextEditorPreviewKeyDown;
}
void OnTextEditorPreviewKeyDown(object source, KeyEventArgs e)
{
if (PreviewKeyDown != null) {
PreviewKeyDown(this, new RubyConsoleTextEditorKeyEventArgs(e));
}
}
public event ConsoleTextEditorKeyEventHandler PreviewKeyDown;
public Color CustomLineColour {
get { return customLineColour; }
}
public void Write(string text)
{
if (dispatcher.CheckAccess()) {
TextLocation location = GetCurrentCursorLocation();
int offset = textEditor.Document.GetOffset(location);
textEditor.Document.Insert(offset, text);
} else {
Action<string> action = Write;
dispatcher.Invoke(action, new object[] {text});
}
}
TextLocation GetCurrentCursorLocation()
{
return new TextLocation(Line + 1, Column + 1);
}
public int Column {
get { return textEditor.TextArea.Caret.Column - 1; }
set { textEditor.TextArea.Caret.Column = value + 1; }
}
public int SelectionStart {
get { return textEditor.SelectionStart; }
}
public int SelectionLength {
get { return textEditor.SelectionLength; }
}
/// <summary>
/// Gets the current cursor line.
/// </summary>
public int Line {
get { return textEditor.TextArea.Caret.Line - 1; }
}
/// <summary>
/// Gets the total number of lines in the text editor.
/// </summary>
public int TotalLines {
get { return textEditor.Document.LineCount; }
}
/// <summary>
/// Gets the text for the specified line.
/// </summary>
public string GetLine(int index)
{
if (dispatcher.CheckAccess()) {
DocumentLine line = textEditor.Document.GetLineByNumber(index + 1);
return textEditor.Document.GetText(line);
} else {
GetLineInvoker invoker = new GetLineInvoker(GetLine);
return (string)dispatcher.Invoke(invoker, new object[] {index});
}
}
/// <summary>
/// Replaces the text at the specified index on the current line with the specified text.
/// </summary>
public void Replace(int index, int length, string text)
{
if (dispatcher.CheckAccess()) {
DocumentLine line = textEditor.Document.GetLineByNumber(textEditor.TextArea.Caret.Line);
int offset = line.Offset + index;
textEditor.Document.Replace(offset, length, text);
} else {
Action<int, int, string> action = Replace;
dispatcher.Invoke(action, new object[] {index, length, text});
}
}
/// <summary>
/// Makes the current text read only. Text can still be entered at the end.
/// </summary>
public void MakeCurrentContentReadOnly()
{
if (dispatcher.CheckAccess()) {
readOnlyRegion.EndOffset = textEditor.Document.TextLength;
} else {
Action action = MakeCurrentContentReadOnly;
dispatcher.Invoke(action);
}
}
public void ShowCompletionWindow(RubyConsoleCompletionDataProvider completionDataProvider)
{
ICompletionData[] items = completionDataProvider.GenerateCompletionData(this);
if (items.Length > 0) {
ShowCompletionWindow(items);
}
}
void ShowCompletionWindow(ICompletionData[] items)
{
completionWindow = new CompletionWindow(textEditor.TextArea);
completionWindow.Closed += CompletionWindowClosed;
foreach (ICompletionData item in items) {
completionWindow.CompletionList.CompletionData.Add(item);
}
completionWindow.ExpectInsertionBeforeStart = true;
completionWindow.Show();
Action<CompletionWindow> action = ShowCompletionWindow;
completionWindow.Dispatcher.BeginInvoke(DispatcherPriority.Normal, action, completionWindow);
}
void ShowCompletionWindow(CompletionWindow window)
{
if (completionWindow == window) {
window.Show();
}
}
public bool IsCompletionWindowDisplayed {
get { return completionWindow != null; }
}
void CompletionWindowClosed(object source, EventArgs e)
{
if (completionWindow != null) {
completionWindow.Closed -= CompletionWindowClosed;
completionWindow = null;
}
}
}
}

28
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsoleTextEditorKeyEventArgs.cs

@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Input;
namespace ICSharpCode.RubyBinding
{
public class RubyConsoleTextEditorKeyEventArgs : ConsoleTextEditorKeyEventArgs
{
KeyEventArgs e;
public RubyConsoleTextEditorKeyEventArgs(KeyEventArgs e)
: base(e.Key)
{
this.e = e;
}
public override bool Handled {
get { return e.Handled; }
set { e.Handled = value; }
}
}
}

22
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyDesignerGenerator.cs

@ -42,11 +42,11 @@ namespace ICSharpCode.RubyBinding @@ -42,11 +42,11 @@ namespace ICSharpCode.RubyBinding
public class RubyDesignerGenerator : IRubyDesignerGenerator
{
FormsDesignerViewContent viewContent;
ICSharpCode.TextEditor.Document.ITextEditorProperties textEditorProperties;
ITextEditorOptions textEditorOptions;
public RubyDesignerGenerator(ICSharpCode.TextEditor.Document.ITextEditorProperties textEditorProperties)
public RubyDesignerGenerator(ITextEditorOptions textEditorOptions)
{
this.textEditorProperties = textEditorProperties;
this.textEditorOptions = textEditorOptions;
}
/// <summary>
@ -86,7 +86,7 @@ namespace ICSharpCode.RubyBinding @@ -86,7 +86,7 @@ namespace ICSharpCode.RubyBinding
public void MergeRootComponentChanges(IDesignerHost host, IDesignerSerializationManager serializationManager)
{
ParseInformation parseInfo = ParseFile();
Merge(host, ViewContent.DesignerCodeFileDocument, parseInfo.CompilationUnit, textEditorProperties, serializationManager);
Merge(host, ViewContent.DesignerCodeFileDocument, parseInfo.CompilationUnit, textEditorOptions, serializationManager);
}
/// <summary>
@ -95,17 +95,17 @@ namespace ICSharpCode.RubyBinding @@ -95,17 +95,17 @@ namespace ICSharpCode.RubyBinding
/// <param name="component">The designer host.</param>
/// <param name="document">The document that the generated code will be merged into.</param>
/// <param name="parseInfo">The current compilation unit for the <paramref name="document"/>.</param>
public static void Merge(IDesignerHost host, IDocument document, ICompilationUnit compilationUnit, ICSharpCode.TextEditor.Document.ITextEditorProperties textEditorProperties, IDesignerSerializationManager serializationManager)
public static void Merge(IDesignerHost host, IDocument document, ICompilationUnit compilationUnit, ITextEditorOptions textEditorOptions, IDesignerSerializationManager serializationManager)
{
// Get the document's initialize components method.
IMethod method = GetInitializeComponents(compilationUnit);
// Generate the Ruby source code.
RubyCodeDomSerializer serializer = new RubyCodeDomSerializer(NRefactoryToRubyConverter.GetIndentString(textEditorProperties));
RubyCodeDomSerializer serializer = new RubyCodeDomSerializer(textEditorOptions.IndentationString);
int indent = method.Region.BeginColumn;
if (textEditorProperties.ConvertTabsToSpaces) {
indent = (indent / textEditorProperties.IndentationSize);
if (textEditorProperties.IndentationSize > 1) {
if (textEditorOptions.ConvertTabsToSpaces) {
indent = (indent / textEditorOptions.IndentationSize);
if (textEditorOptions.IndentationSize > 1) {
indent += 1;
}
}
@ -134,7 +134,7 @@ namespace ICSharpCode.RubyBinding @@ -134,7 +134,7 @@ namespace ICSharpCode.RubyBinding
// Insert the event handler at the end of the class with an extra
// new line before it.
IDocument doc = viewContent.DesignerCodeFileDocument;
string eventHandler = CreateEventHandler(eventMethodName, body, NRefactoryToRubyConverter.GetIndentString(textEditorProperties));
string eventHandler = CreateEventHandler(eventMethodName, body, textEditorOptions.IndentationString);
IDocumentLine classEndLine = GetClassEndLine(doc);
InsertEventHandlerBeforeLine(doc, eventHandler, classEndLine);
@ -251,7 +251,7 @@ namespace ICSharpCode.RubyBinding @@ -251,7 +251,7 @@ namespace ICSharpCode.RubyBinding
eventHandler.Append("(sender, e)");
eventHandler.AppendLine();
eventHandler.Append(indentation);
eventHandler.Append(NRefactoryToRubyConverter.GetIndentString(textEditorProperties));
eventHandler.Append(textEditorOptions.IndentationString);
eventHandler.Append(body);
eventHandler.AppendLine();
eventHandler.Append(indentation);

1
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyDesignerLoader.cs

@ -18,7 +18,6 @@ using System.Security.Permissions; @@ -18,7 +18,6 @@ using System.Security.Permissions;
using ICSharpCode.FormsDesigner;
using ICSharpCode.FormsDesigner.Services;
using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.RubyBinding
{

2
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyDesignerLoaderProvider.cs

@ -8,8 +8,6 @@ @@ -8,8 +8,6 @@
using System;
using System.ComponentModel.Design.Serialization;
using ICSharpCode.FormsDesigner;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.RubyBinding
{

76
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyFormattingStrategy.cs

@ -7,18 +7,17 @@ @@ -7,18 +7,17 @@
using System;
using System.Collections.Generic;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Actions;
using ICSharpCode.TextEditor.Document;
using System.Text;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.RubyBinding
{
public class RubyFormattingStrategy : DefaultFormattingStrategy
{
TextArea textArea;
int line;
IDocument document;
string previousLineText;
ITextEditor textEditor;
IDocumentLine currentLine;
IDocumentLine previousLine;
string previousLineTextTrimmed;
List<string> decreaseLineIndentStatements = new List<string>();
List<string> decreaseLineIndentStartsWithStatements = new List<string>();
@ -85,32 +84,32 @@ namespace ICSharpCode.RubyBinding @@ -85,32 +84,32 @@ namespace ICSharpCode.RubyBinding
{
increaseLineIndentContainsStatements.Add(" case ");
}
protected override int SmartIndentLine(TextArea textArea, int line)
public override void IndentLine(ITextEditor editor, IDocumentLine line)
{
this.textArea = textArea;
this.line = line;
this.document = textArea.Document;
this.textEditor = editor;
this.currentLine = line;
GetPreviousLineText();
if (ShouldDecreaseLineIndent()) {
return DecreaseLineIndent();
DecreaseLineIndent();
} else if (ShouldIncreaseLineIndent()) {
return IncreaseLineIndent();
IncreaseLineIndent();
} else {
base.IndentLine(editor, line);
}
return base.SmartIndentLine(textArea, line);
}
void GetPreviousLineText()
{
LineSegment previousLine = document.GetLineSegment(line - 1);
this.previousLineText = document.GetText(previousLine).Trim();
previousLine = textEditor.Document.GetLine(currentLine.LineNumber - 1);
previousLineTextTrimmed = previousLine.Text.Trim();
}
bool ShouldIncreaseLineIndent()
{
if (increaseLineIndentStatements.Contains(previousLineText)) {
if (increaseLineIndentStatements.Contains(previousLineTextTrimmed)) {
return true;
}
if (PreviousLineStartsWith(increaseLineIndentStartsWithStatements)) {
@ -124,7 +123,7 @@ namespace ICSharpCode.RubyBinding @@ -124,7 +123,7 @@ namespace ICSharpCode.RubyBinding
bool ShouldDecreaseLineIndent()
{
if (decreaseLineIndentStatements.Contains(previousLineText)) {
if (decreaseLineIndentStatements.Contains(previousLineTextTrimmed)) {
return true;
}
return PreviousLineStartsWith(decreaseLineIndentStartsWithStatements);
@ -133,7 +132,7 @@ namespace ICSharpCode.RubyBinding @@ -133,7 +132,7 @@ namespace ICSharpCode.RubyBinding
bool PreviousLineStartsWith(List<string> items)
{
foreach (string item in items) {
if (previousLineText.StartsWith(item)) {
if (previousLineTextTrimmed.StartsWith(item)) {
return true;
}
}
@ -143,7 +142,7 @@ namespace ICSharpCode.RubyBinding @@ -143,7 +142,7 @@ namespace ICSharpCode.RubyBinding
bool PreviousLineEndsWith(List<string> items)
{
foreach (string item in items) {
if (previousLineText.EndsWith(item)) {
if (previousLineTextTrimmed.EndsWith(item)) {
return true;
}
}
@ -153,31 +152,42 @@ namespace ICSharpCode.RubyBinding @@ -153,31 +152,42 @@ namespace ICSharpCode.RubyBinding
bool PreviousLineContains(List<string> items)
{
foreach (string item in items) {
if (previousLineText.Contains(item)) {
if (previousLineTextTrimmed.Contains(item)) {
return true;
}
}
return false;
}
int IncreaseLineIndent()
void IncreaseLineIndent()
{
return ModifyLineIndent(true);
ModifyLineIndent(true);
}
int DecreaseLineIndent()
void DecreaseLineIndent()
{
return ModifyLineIndent(false);
ModifyLineIndent(false);
}
int ModifyLineIndent(bool increaseIndent)
void ModifyLineIndent(bool increaseIndent)
{
LineSegment currentLine = document.GetLineSegment(line);
string indentation = GetIndentation(textArea, line - 1);
indentation = GetNewLineIndentation(indentation, Tab.GetIndentationString(document), increaseIndent);
string newIndentedText = indentation + document.GetText(currentLine);
SmartReplaceLine(document, currentLine, newIndentedText);
return indentation.Length;
string indentation = GetPreviousLineIndentation();
indentation = GetNewLineIndentation(indentation, textEditor.Options.IndentationString, increaseIndent);
string newIndentedText = indentation + currentLine.Text;
textEditor.Document.Replace(currentLine.Offset, currentLine.Length, newIndentedText);
}
string GetPreviousLineIndentation()
{
StringBuilder whitespace = new StringBuilder();
foreach (char ch in previousLine.Text) {
if (Char.IsWhiteSpace(ch)) {
whitespace.Append(ch);
} else {
break;
}
}
return whitespace.ToString();
}
string GetNewLineIndentation(string previousLineIndentation, string singleIndent, bool increaseIndent)

9
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyFormsDesignerDisplayBinding.cs

@ -13,8 +13,6 @@ using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; @@ -13,8 +13,6 @@ using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.RubyBinding
{
@ -49,10 +47,11 @@ namespace ICSharpCode.RubyBinding @@ -49,10 +47,11 @@ namespace ICSharpCode.RubyBinding
public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent)
{
return CreateSecondaryViewContent(viewContent, SharpDevelopTextEditorProperties.Instance);
RubyTextEditorViewContent textEditorView = new RubyTextEditorViewContent(viewContent);
return CreateSecondaryViewContent(viewContent, textEditorView.TextEditorOptions);
}
public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent, ITextEditorProperties textEditorProperties)
public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent, ITextEditorOptions textEditorOptions)
{
foreach (IViewContent existingView in viewContent.SecondaryViewContents) {
if (existingView.GetType() == typeof(FormsDesignerViewContent)) {
@ -61,7 +60,7 @@ namespace ICSharpCode.RubyBinding @@ -61,7 +60,7 @@ namespace ICSharpCode.RubyBinding
}
IDesignerLoaderProvider loader = new RubyDesignerLoaderProvider();
IDesignerGenerator generator = new RubyDesignerGenerator(textEditorProperties);
IDesignerGenerator generator = new RubyDesignerGenerator(textEditorOptions);
return new IViewContent[] { new FormsDesignerViewContent(viewContent, loader, generator) };
}

27
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyLanguageBinding.cs

@ -6,31 +6,20 @@ @@ -6,31 +6,20 @@
// </file>
using System;
using ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.RubyBinding
{
public class RubyLanguageBinding : ILanguageBinding
public class RubyLanguageBinding : DefaultLanguageBinding
{
public const string LanguageName = "Ruby";
public RubyLanguageBinding()
{
}
public string Language {
get { return LanguageName; }
public override IFormattingStrategy FormattingStrategy {
get { return new RubyFormattingStrategy(); }
}
public IProject LoadProject(IMSBuildEngineProvider engineProvider, string fileName, string projectName)
{
return new RubyProject(engineProvider, fileName, projectName);
public override LanguageProperties Properties {
get { return RubyLanguageProperties.Default; }
}
public IProject CreateProject(ProjectCreateInformation info)
{
return new RubyProject(info);
}
}
}

6
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyOptionsPanel.cs

@ -19,14 +19,14 @@ namespace ICSharpCode.RubyBinding @@ -19,14 +19,14 @@ namespace ICSharpCode.RubyBinding
/// </summary>
public class RubyOptionsPanel : XmlFormsOptionPanel
{
AddInOptions options;
RubyAddInOptions options;
TextBox rubyFileNameTextBox;
public RubyOptionsPanel() : this(new AddInOptions())
public RubyOptionsPanel() : this(new RubyAddInOptions())
{
}
public RubyOptionsPanel(AddInOptions options)
public RubyOptionsPanel(RubyAddInOptions options)
{
this.options = options;
}

6
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyOutputStream.cs

@ -13,9 +13,9 @@ namespace ICSharpCode.RubyBinding @@ -13,9 +13,9 @@ namespace ICSharpCode.RubyBinding
{
public class RubyOutputStream : Stream
{
ITextEditor textEditor;
IConsoleTextEditor textEditor;
public RubyOutputStream(ITextEditor textEditor)
public RubyOutputStream(IConsoleTextEditor textEditor)
{
this.textEditor = textEditor;
}
@ -66,6 +66,6 @@ namespace ICSharpCode.RubyBinding @@ -66,6 +66,6 @@ namespace ICSharpCode.RubyBinding
{
string text = UTF8Encoding.UTF8.GetString(buffer, offset, count);
textEditor.Write(text);
}
}
}
}

58
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTextEditorViewContent.cs

@ -0,0 +1,58 @@ @@ -0,0 +1,58 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.RubyBinding
{
public class RubyTextEditorViewContent
{
IViewContent view;
IEditable editable;
ITextEditorProvider textEditorProvider;
ITextEditor textEditor;
ITextEditorOptions textEditorOptions;
public RubyTextEditorViewContent(IWorkbench workbench)
{
Init(workbench.ActiveWorkbenchWindow.ActiveViewContent);
}
public RubyTextEditorViewContent(IViewContent view)
{
Init(view);
}
void Init(IViewContent view)
{
this.view = view;
editable = view as IEditable;
textEditorProvider = view as ITextEditorProvider;
textEditor = textEditorProvider.TextEditor;
textEditorOptions = textEditor.Options;
}
public FileName PrimaryFileName {
get { return view.PrimaryFileName; }
}
public IEditable EditableView {
get { return editable; }
}
public ITextEditor TextEditor {
get { return textEditor; }
}
public ITextEditorOptions TextEditorOptions {
get { return textEditorOptions; }
}
}
}

192
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/TextEditor.cs

@ -1,192 +0,0 @@ @@ -1,192 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Drawing;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
namespace ICSharpCode.RubyBinding
{
public class TextEditor : ITextEditor
{
delegate string GetLineInvoker(int index);
delegate void WriteInvoker(string text, Color color);
TextEditorControl textEditorControl;
TextArea textArea;
Color customLineColour = Color.LightGray;
TextMarker readOnlyMarker;
CodeCompletionWindow completionWindow;
public TextEditor(TextEditorControl textEditorControl)
{
this.textEditorControl = textEditorControl;
this.textArea = textEditorControl.ActiveTextAreaControl.TextArea;
textEditorControl.TextEditorProperties.SupportReadOnlySegments = true;
}
public IndentStyle IndentStyle {
get { return textEditorControl.IndentStyle; }
set { SetIndentStyle(value); }
}
public event KeyEventHandler KeyPress {
add { textArea.KeyEventHandler += value; }
remove { textArea.KeyEventHandler -= value; }
}
public event DialogKeyProcessor DialogKeyPress {
add { textArea.DoProcessDialogKey += value; }
remove { textArea.DoProcessDialogKey -= value; }
}
public Color CustomLineColour {
get { return customLineColour; }
}
public void Write(string text)
{
Write(text, Color.Empty);
}
public void Write(string text, Color backgroundColour)
{
if (textEditorControl.InvokeRequired) {
WriteInvoker invoker = new WriteInvoker(Write);
textEditorControl.Invoke(invoker, new object[] {text, backgroundColour});
} else {
int offset = textEditorControl.Document.PositionToOffset(new TextLocation(Column, Line));
textEditorControl.ActiveTextAreaControl.TextArea.InsertString(text);
if (!backgroundColour.IsEmpty) {
TextMarker marker = new TextMarker(offset, text.Length, TextMarkerType.SolidBlock, backgroundColour);
textEditorControl.Document.MarkerStrategy.AddMarker(marker);
textEditorControl.Refresh();
}
}
}
public int Column {
get { return textEditorControl.ActiveTextAreaControl.Caret.Column; }
set { textEditorControl.ActiveTextAreaControl.Caret.Column = value; }
}
public int SelectionStart {
get {
ColumnRange range = GetSelectionRange();
if (range != ColumnRange.NoColumn) {
return range.StartColumn;
}
return Column;
}
}
public int SelectionLength {
get {
ColumnRange range = GetSelectionRange();
return range.EndColumn - range.StartColumn;
}
}
/// <summary>
/// Gets the current cursor line.
/// </summary>
public int Line {
get { return textArea.Caret.Line; }
}
/// <summary>
/// Gets the total number of lines in the text editor.
/// </summary>
public int TotalLines {
get { return textEditorControl.Document.TotalNumberOfLines; }
}
/// <summary>
/// Gets the text for the specified line.
/// </summary>
public string GetLine(int index)
{
if (textEditorControl.InvokeRequired) {
GetLineInvoker invoker = new GetLineInvoker(GetLine);
return (string)textEditorControl.Invoke(invoker, new object[] {index});
} else {
LineSegment lineSegment = textEditorControl.Document.GetLineSegment(index);
return textEditorControl.Document.GetText(lineSegment);
}
}
/// <summary>
/// Replaces the text at the specified index on the current line with the specified text.
/// </summary>
public void Replace(int index, int length, string text)
{
int currentLine = textEditorControl.ActiveTextAreaControl.Caret.Line;
LineSegment lineSegment = textEditorControl.Document.GetLineSegment(currentLine);
textEditorControl.Document.Replace(lineSegment.Offset + index, length, text);
}
/// <summary>
/// Makes the current text read only. Text can still be entered at the end.
/// </summary>
public void MakeCurrentContentReadOnly()
{
IDocument doc = textEditorControl.Document;
if (readOnlyMarker == null) {
readOnlyMarker = new TextMarker(0, doc.TextLength, TextMarkerType.Invisible);
readOnlyMarker.IsReadOnly = true;
doc.MarkerStrategy.AddMarker(readOnlyMarker);
}
readOnlyMarker.Offset = 0;
readOnlyMarker.Length = doc.TextLength;
doc.UndoStack.ClearAll();
}
public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider)
{
completionWindow = CodeCompletionWindow.ShowCompletionWindow(textEditorControl.ParentForm, textEditorControl, String.Empty, completionDataProvider, ' ');
if (completionWindow != null) {
completionWindow.Closed += CompletionWindowClosed;
}
}
public bool IsCompletionWindowDisplayed {
get { return completionWindow != null; }
}
/// <summary>
/// Gets the range of the currently selected text.
/// </summary>
ColumnRange GetSelectionRange()
{
return textArea.SelectionManager.GetSelectionAtLine(textArea.Caret.Line);
}
void SetIndentStyle(IndentStyle style)
{
if (textEditorControl.InvokeRequired) {
Action <IndentStyle> action = SetIndentStyle;
textEditorControl.Invoke(action, new object[] {style});
} else {
textEditorControl.IndentStyle = style;
}
}
void CompletionWindowClosed(object source, EventArgs e)
{
if (completionWindow != null) {
completionWindow.Closed -= CompletionWindowClosed;
completionWindow.Dispose();
completionWindow = null;
}
}
}
}

71
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/AddInOptionsTestFixture.cs

@ -1,71 +0,0 @@ @@ -1,71 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests
{
/// <summary>
/// Tests the AddInOptions class.
/// </summary>
[TestFixture]
public class AddInOptionsTestFixture
{
[Test]
public void DefaultRubyConsoleFileName()
{
Properties p = new Properties();
DerivedAddInOptions options = new DerivedAddInOptions(p);
options.AddInPath = @"C:\Projects\SD\AddIns\Ruby";
string expectedFileName = Path.Combine(options.AddInPath, "ir.exe");
Assert.AreEqual(expectedFileName, options.RubyFileName);
Assert.AreEqual("${addinpath:ICSharpCode.RubyBinding}", options.AddInPathRequested);
}
[Test]
public void SetRubyConsoleFileNameToNull()
{
Properties p = new Properties();
DerivedAddInOptions options = new DerivedAddInOptions(p);
options.AddInPath = @"C:\Projects\SD\AddIns\Ruby";
options.RubyFileName = null;
string expectedFileName = Path.Combine(options.AddInPath, "ir.exe");
Assert.AreEqual(expectedFileName, options.RubyFileName);
}
[Test]
public void SetRubyConsoleFileNameToEmptyString()
{
Properties p = new Properties();
DerivedAddInOptions options = new DerivedAddInOptions(p);
options.AddInPath = @"C:\Projects\SD\AddIns\Ruby";
options.RubyFileName = String.Empty;
string expectedFileName = Path.Combine(options.AddInPath, "ir.exe");
Assert.AreEqual(expectedFileName, options.RubyFileName);
}
[Test]
public void SetRubyConsoleFileName()
{
Properties p = new Properties();
AddInOptions options = new AddInOptions(p);
string fileName = @"C:\IronRuby\ir.exe";
options.RubyFileName = fileName;
Assert.AreEqual(fileName, options.RubyFileName);
Assert.AreEqual(fileName, p["RubyFileName"]);
}
}
}

2
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyAddInOptionsTestFixture.cs → src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Configuration/RubyAddInOptionsTestFixture.cs

@ -12,7 +12,7 @@ using ICSharpCode.RubyBinding; @@ -12,7 +12,7 @@ using ICSharpCode.RubyBinding;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests
namespace RubyBinding.Tests.Configuration
{
/// <summary>
/// Tests the AddInOptions class.

11
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/CodeCompletionTests.cs

@ -7,9 +7,9 @@ @@ -7,9 +7,9 @@
using System;
using ICSharpCode.AvalonEdit.CodeCompletion;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using NUnit.Framework;
namespace RubyBinding.Tests.Console
@ -55,15 +55,6 @@ namespace RubyBinding.Tests.Console @@ -55,15 +55,6 @@ namespace RubyBinding.Tests.Console
Assert.AreEqual(0, completionProvider.GenerateCompletionData(">>> a").Length);
}
[Test]
public void ImageIndexIsMethod()
{
memberProvider.SetMemberNames(new string[] {"a"});
ICompletionData[] items = completionProvider.GenerateCompletionData(">>> a");
Assert.AreEqual(ClassBrowserIconService.Method.ImageIndex, items[0].ImageIndex);
}
[Test]
public void UnderscoresPassedToGetMemberNames()
{

145
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/ConsoleTextEditorTestFixture.cs

@ -0,0 +1,145 @@ @@ -0,0 +1,145 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows.Input;
using ICSharpCode.AvalonEdit;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests.Console
{
[TestFixture]
public class ConsoleTextEditorTestFixture
{
RubyConsoleTextEditor consoleTextEditor;
TextEditor avalonEditTextEditor;
[TestFixtureSetUp]
public void SetUpFixture()
{
avalonEditTextEditor = new TextEditor();
consoleTextEditor = new RubyConsoleTextEditor(avalonEditTextEditor);
}
[Test]
public void RubyConsoleTextEditorImplementsIConsoleTextEditorInterface()
{
Assert.IsNotNull(consoleTextEditor as IConsoleTextEditor);
}
[Test]
public void MakeCurrentTextEditorContentReadOnlyExtendsReadOnlyRegionToEntireDocument()
{
avalonEditTextEditor.Text = String.Empty;
consoleTextEditor.Write("abc" + Environment.NewLine);
consoleTextEditor.MakeCurrentContentReadOnly();
IReadOnlySectionProvider readOnlySection = avalonEditTextEditor.TextArea.ReadOnlySectionProvider;
Assert.IsFalse(readOnlySection.CanInsert(2));
}
[Test]
public void WriteMethodUpdatesTextEditor()
{
avalonEditTextEditor.Text = String.Empty;
consoleTextEditor.Write("abc");
Assert.AreEqual("abc", avalonEditTextEditor.Text);
}
[Test]
public void ZeroBasedConsoleTextEditorColumnPositionIsOneLessThanAvalonTextEditorColumnPositionWhichIsOneBased()
{
avalonEditTextEditor.Text = "test";
avalonEditTextEditor.TextArea.Caret.Column = 3;
Assert.AreEqual(2, consoleTextEditor.Column);
}
[Test]
public void SettingConsoleTextEditorColumnPositionUpdatesAvalonTextEditorColumnPosition()
{
avalonEditTextEditor.Text = "test";
avalonEditTextEditor.TextArea.Caret.Column = 0;
consoleTextEditor.Column = 1;
Assert.AreEqual(2, avalonEditTextEditor.TextArea.Caret.Column);
}
[Test]
public void GetSelectionStartAndLengthWhenThreeCharactersSelected()
{
avalonEditTextEditor.Text = "te000xt";
int startOffset = 2;
int endOffset = 5;
SimpleSelection expectedSelection = new SimpleSelection(startOffset, endOffset);
avalonEditTextEditor.SelectionStart = expectedSelection.StartOffset;
avalonEditTextEditor.SelectionLength = expectedSelection.Length;
// Sanity check.
Assert.AreEqual("000", avalonEditTextEditor.SelectedText);
AssertSelectionsAreEqual(expectedSelection, consoleTextEditor);
}
void AssertSelectionsAreEqual(SimpleSelection expectedSelection, IConsoleTextEditor consoleTextEditor)
{
int selectionLength = consoleTextEditor.SelectionStart + consoleTextEditor.SelectionLength;
SimpleSelection actualSelection = new SimpleSelection(consoleTextEditor.SelectionStart, selectionLength);
Assert.AreEqual(expectedSelection, actualSelection);
}
[Test]
public void GetSelectionStartAndLengthWhenNothingSelected()
{
avalonEditTextEditor.Text = "text";
avalonEditTextEditor.TextArea.Caret.Column = 1;
avalonEditTextEditor.SelectionLength = 0;
SimpleSelection expectedSelection = new SimpleSelection(1, 1);
AssertSelectionsAreEqual(expectedSelection, consoleTextEditor);
}
[Test]
public void ConsoleTextEditorLineEqualsOneLessThanAvalonTextEditorCaretLine()
{
avalonEditTextEditor.Text = "abc\r\ndef";
avalonEditTextEditor.TextArea.Caret.Line = 2;
Assert.AreEqual(1, consoleTextEditor.Line);
}
[Test]
public void ConsoleTextEditorTotalLinesEqualsAvalonTextEditorTotalLines()
{
avalonEditTextEditor.Text = "abc\r\ndef\r\nghi";
Assert.AreEqual(3, consoleTextEditor.TotalLines);
}
[Test]
public void GetLineForZerothLineReturnsFirstLineInAvalonTextEditor()
{
avalonEditTextEditor.Text = "abc\r\ndef\r\nghi";
Assert.AreEqual("abc", consoleTextEditor.GetLine(0));
}
[Test]
public void ReplaceTextReplacesTextInAvalonEditTextEditor()
{
avalonEditTextEditor.Text = "abc\r\ndef";
avalonEditTextEditor.TextArea.Caret.Line = 2;
int lineOffset = 1;
int length = 1;
consoleTextEditor.Replace(lineOffset, length, "test");
Assert.AreEqual("abc\r\ndtestf", avalonEditTextEditor.Text);
}
}
}

111
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/ConsoleTextEditorThreadSafetyTestFixture.cs

@ -0,0 +1,111 @@ @@ -0,0 +1,111 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows.Input;
using ICSharpCode.AvalonEdit;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
using RubyBinding.Tests.Utils.Tests;
namespace RubyBinding.Tests.Console
{
[TestFixture]
public class ConsoleTextEditorThreadSafetyTestFixture
{
RubyConsoleTextEditor consoleTextEditor;
TextEditor avalonEditTextEditor;
MockControlDispatcher dispatcher;
[TestFixtureSetUp]
public void SetUpFixture()
{
avalonEditTextEditor = new TextEditor();
dispatcher = new MockControlDispatcher();
consoleTextEditor = new RubyConsoleTextEditor(avalonEditTextEditor, dispatcher);
}
[Test]
public void IfDispatcherCheckAccessReturnsFalseWriteMethodIsInvoked()
{
dispatcher.CheckAccessReturnValue = false;
dispatcher.MethodInvoked = null;
consoleTextEditor.Write("abc");
Assert.IsNotNull(dispatcher.MethodInvoked);
}
[Test]
public void IfDispatcherCheckAccessReturnsFalseWriteMethodIsInvokedWithTextAsArg()
{
dispatcher.CheckAccessReturnValue = false;
dispatcher.MethodInvokedArgs = null;
consoleTextEditor.Write("abc");
object[] expectedArgs = new object[] { "abc" };
Assert.AreEqual(expectedArgs, dispatcher.MethodInvokedArgs);
}
[Test]
public void IfDispatcherCheckAccessReturnsFalseGetLineMethodIsInvoked()
{
dispatcher.CheckAccessReturnValue = false;
dispatcher.MethodInvoked = null;
consoleTextEditor.GetLine(0);
Assert.IsNotNull(dispatcher.MethodInvoked);
}
[Test]
public void IfDispatcherCheckAccessReturnsFalseGetLineMethodIsInvokedWithLineNumberAsArg()
{
dispatcher.CheckAccessReturnValue = false;
dispatcher.MethodInvokedArgs = null;
consoleTextEditor.GetLine(0);
object[] expectedArgs = new object[] { 0 };
Assert.AreEqual(expectedArgs, dispatcher.MethodInvokedArgs);
}
[Test]
public void IfDispatcherCheckAccessReturnsFalseReplaceMethodIsInvoked()
{
dispatcher.CheckAccessReturnValue = false;
dispatcher.MethodInvoked = null;
avalonEditTextEditor.Text = "abcd";
consoleTextEditor.Replace(0, 2, "12");
Assert.IsNotNull(dispatcher.MethodInvoked);
}
[Test]
public void IfDispatcherCheckAccessReturnsFalseReplaceethodIsInvokedWithThreeArgs()
{
dispatcher.CheckAccessReturnValue = false;
dispatcher.MethodInvokedArgs = null;
avalonEditTextEditor.Text = "abcd";
consoleTextEditor.Replace(0, 2, "12");
object[] expectedArgs = new object[] { 0, 2, "12" };
Assert.AreEqual(expectedArgs, dispatcher.MethodInvokedArgs);
}
[Test]
public void IfDispatcherCheckAccessReturnsFalseMakeCurrentContentReadOnlyIsInvoked()
{
dispatcher.CheckAccessReturnValue = false;
dispatcher.MethodInvoked = null;
consoleTextEditor.MakeCurrentContentReadOnly();
Assert.IsNotNull(dispatcher.MethodInvoked);
}
}
}

5
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/DisposedRubyConsoleTestFixture.cs

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
using System;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests.Console
{
@ -20,14 +21,14 @@ namespace RubyBinding.Tests.Console @@ -20,14 +21,14 @@ namespace RubyBinding.Tests.Console
[Test]
public void RubyConsoleImplementsIDisposable()
{
RubyConsole console = new RubyConsole(new MockTextEditor(), null);
RubyConsole console = new RubyConsole(new MockConsoleTextEditor(), null);
Assert.IsNotNull(console as IDisposable);
}
[Test]
public void ReadLineReturnsNullWhenConsoleDisposed()
{
RubyConsole console = new RubyConsole(new MockTextEditor(), null);
RubyConsole console = new RubyConsole(new MockConsoleTextEditor(), null);
console.Dispose();
Assert.IsNull(console.ReadLine(0));
}

47
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/InsertConsoleCompletionDataTestFixture.cs

@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.AvalonEdit;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
namespace RubyBinding.Tests.Console
{
[TestFixture]
public class InsertConsoleCompletionDataTestFixture
{
RubyConsoleCompletionData completionData;
TextEditor textEditor;
[SetUp]
public void Init()
{
textEditor = new TextEditor();
}
[Test]
public void TextInsertedAtCursor()
{
textEditor.Text = "abc.n";
textEditor.CaretOffset = 4;
int startOffset = 4;
int endOffset = 5;
SimpleSelection selection = new SimpleSelection(startOffset, endOffset);
completionData = new RubyConsoleCompletionData("new");
completionData.Complete(textEditor.TextArea, selection, null);
string expectedText =
"abc.new";
Assert.AreEqual(expectedText, textEditor.Text);
}
}
}

27
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/KeysPressedWhenCompletionWindowOpenTestFixture.cs

@ -6,11 +6,10 @@ @@ -6,11 +6,10 @@
// </file>
using System;
using System.Windows.Forms;
using System.Windows.Input;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using Microsoft.Scripting.Hosting.Shell;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
@ -24,22 +23,22 @@ namespace RubyBinding.Tests.Console @@ -24,22 +23,22 @@ namespace RubyBinding.Tests.Console
[TestFixture]
public class KeysPressedWhenCompletionWindowOpenTestFixture
{
RubyConsole RubyConsole;
MockTextEditor textEditor;
RubyConsole rubyConsole;
MockConsoleTextEditor textEditor;
string prompt = ">>> ";
[SetUp]
public void Init()
{
textEditor = new MockTextEditor();
RubyConsole = new RubyConsole(textEditor, null);
RubyConsole.Write(prompt, Style.Prompt);
textEditor = new MockConsoleTextEditor();
rubyConsole = new RubyConsole(textEditor, null);
rubyConsole.Write(prompt, Style.Prompt);
textEditor.RaiseKeyPressEvent('a');
textEditor.RaiseDialogKeyPressEvent(Keys.Enter);
RubyConsole.Write(prompt, Style.Prompt);
textEditor.RaiseKeyPressEvent('b');
textEditor.RaiseKeyPressEvent('.');
textEditor.RaisePreviewKeyDownEvent(Key.A);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
rubyConsole.Write(prompt, Style.Prompt);
textEditor.RaisePreviewKeyDownEvent(Key.B);
textEditor.RaisePreviewKeyDownEvent(Key.OemPeriod);
}
[Test]
@ -51,13 +50,13 @@ namespace RubyBinding.Tests.Console @@ -51,13 +50,13 @@ namespace RubyBinding.Tests.Console
[Test]
public void UpKeyDoesNothing()
{
Assert.IsFalse(textEditor.RaiseDialogKeyPressEvent(Keys.Up));
Assert.IsFalse(textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Up));
}
[Test]
public void DownKeyDoesNothing()
{
Assert.IsFalse(textEditor.RaiseDialogKeyPressEvent(Keys.Down));
Assert.IsFalse(textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Down));
}
}
}

11
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleCodeCompletionTestFixture.cs

@ -7,11 +7,12 @@ @@ -7,11 +7,12 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Windows.Input;
using System.Threading;
using Microsoft.Scripting.Hosting.Shell;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests.Console
{
@ -21,7 +22,7 @@ namespace RubyBinding.Tests.Console @@ -21,7 +22,7 @@ namespace RubyBinding.Tests.Console
[TestFixture]
public class RubyConsoleCodeCompletionTestFixture
{
MockTextEditor textEditor;
MockConsoleTextEditor textEditor;
RubyConsole console;
string prompt = ">>> ";
bool showCompletionWindowCalledBeforeDotTypedIn;
@ -29,13 +30,13 @@ namespace RubyBinding.Tests.Console @@ -29,13 +30,13 @@ namespace RubyBinding.Tests.Console
[TestFixtureSetUp]
public void SetUpFixture()
{
textEditor = new MockTextEditor();
textEditor = new MockConsoleTextEditor();
console = new RubyConsole(textEditor, null);
console.WriteLine(prompt, Style.Prompt);
textEditor.RaiseKeyPressEvents("a");
textEditor.RaisePreviewKeyDownEvent(Key.A);
showCompletionWindowCalledBeforeDotTypedIn = textEditor.IsShowCompletionWindowCalled;
textEditor.RaiseKeyPressEvent('.');
textEditor.RaisePreviewKeyDownEvent(Key.OemPeriod);
}
[Test]

49
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleCommandLineHistoryTestFixture.cs

@ -6,13 +6,14 @@ @@ -6,13 +6,14 @@
// </file>
using System;
using System.Windows.Forms;
using System.Windows.Input;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Hosting.Shell;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests.Console
{
@ -22,43 +23,43 @@ namespace RubyBinding.Tests.Console @@ -22,43 +23,43 @@ namespace RubyBinding.Tests.Console
[TestFixture]
public class RubyConsoleCommandLineHistoryTestFixture
{
RubyConsole RubyConsole;
MockTextEditor textEditor;
RubyConsole rubyConsole;
MockConsoleTextEditor textEditor;
string prompt = ">>> ";
[SetUp]
public void Init()
{
textEditor = new MockTextEditor();
RubyConsole = new RubyConsole(textEditor, null);
RubyConsole.Write(prompt, Style.Prompt);
textEditor = new MockConsoleTextEditor();
rubyConsole = new RubyConsole(textEditor, null);
rubyConsole.Write(prompt, Style.Prompt);
textEditor.RaiseKeyPressEvent('a');
textEditor.RaiseDialogKeyPressEvent(Keys.Enter);
RubyConsole.Write(prompt, Style.Prompt);
textEditor.RaiseKeyPressEvent('b');
textEditor.RaiseKeyPressEvent('c');
textEditor.RaiseDialogKeyPressEvent(Keys.Enter);
RubyConsole.Write(prompt, Style.Prompt);
textEditor.RaisePreviewKeyDownEvent(Key.A);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
rubyConsole.Write(prompt, Style.Prompt);
textEditor.RaisePreviewKeyDownEvent(Key.B);
textEditor.RaisePreviewKeyDownEvent(Key.C);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
rubyConsole.Write(prompt, Style.Prompt);
}
[Test]
public void UpArrowKeyPressed()
{
Assert.IsTrue(textEditor.RaiseDialogKeyPressEvent(Keys.Up));
Assert.IsTrue(textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Up));
}
[Test]
public void CurrentLineAfterUpArrowKeyPressed()
{
textEditor.RaiseDialogKeyPressEvent(Keys.Up);
Assert.AreEqual("bc", RubyConsole.GetCurrentLine());
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Up);
Assert.AreEqual("BC", rubyConsole.GetCurrentLine());
}
[Test]
public void TextEditorCursorIsAtEndOfLineAfterUpArrowKeyPressed()
{
textEditor.RaiseDialogKeyPressEvent(Keys.Up);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Up);
Assert.AreEqual(prompt.Length + 2, textEditor.Column);
}
@ -66,28 +67,28 @@ namespace RubyBinding.Tests.Console @@ -66,28 +67,28 @@ namespace RubyBinding.Tests.Console
public void TextAfterUpArrowKeyPressedTwiceThenDownArrowKey()
{
UpArrowKeyPressedTwiceThenDownArrowKey();
Assert.AreEqual("bc", RubyConsole.GetCurrentLine());
Assert.AreEqual("BC", rubyConsole.GetCurrentLine());
}
[Test]
public void TextEditorCursorAfterUpArrowKeyPressedTwice()
{
textEditor.RaiseDialogKeyPressEvent(Keys.Up);
textEditor.RaiseDialogKeyPressEvent(Keys.Up);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Up);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Up);
Assert.AreEqual(prompt.Length + 1, textEditor.Column);
}
[Test]
public void DownArrowKeyHandled()
{
Assert.IsTrue(textEditor.RaiseDialogKeyPressEvent(Keys.Down));
Assert.IsTrue(textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Down));
}
void UpArrowKeyPressedTwiceThenDownArrowKey()
{
textEditor.RaiseDialogKeyPressEvent(Keys.Up);
textEditor.RaiseDialogKeyPressEvent(Keys.Up);
textEditor.RaiseDialogKeyPressEvent(Keys.Down);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Up);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Up);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Down);
}
}
}

18
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleCurrentLineTestFixture.cs

@ -6,12 +6,14 @@ @@ -6,12 +6,14 @@
// </file>
using System;
using System.Windows.Input;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Hosting.Shell;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests.Console
{
@ -21,29 +23,29 @@ namespace RubyBinding.Tests.Console @@ -21,29 +23,29 @@ namespace RubyBinding.Tests.Console
[TestFixture]
public class RubyConsoleCurrentLineTestFixture
{
RubyConsole RubyConsole;
MockTextEditor textEditor;
RubyConsole rubyConsole;
MockConsoleTextEditor textEditor;
string prompt = ">>> ";
[SetUp]
public void Init()
{
textEditor = new MockTextEditor();
RubyConsole = new RubyConsole(textEditor, null);
RubyConsole.Write(prompt, Style.Prompt);
textEditor = new MockConsoleTextEditor();
rubyConsole = new RubyConsole(textEditor, null);
rubyConsole.Write(prompt, Style.Prompt);
}
[Test]
public void CurrentLineIsEmpty()
{
Assert.AreEqual(String.Empty, RubyConsole.GetCurrentLine());
Assert.AreEqual(String.Empty, rubyConsole.GetCurrentLine());
}
[Test]
public void SingleCharacterAddedToTextEditor()
{
textEditor.RaiseKeyPressEvent('a');
Assert.AreEqual("a", RubyConsole.GetCurrentLine());
textEditor.RaisePreviewKeyDownEvent(Key.A);
Assert.AreEqual("A", rubyConsole.GetCurrentLine());
}
}
}

28
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleEnterKeyTestFixture.cs

@ -6,10 +6,11 @@ @@ -6,10 +6,11 @@
// </file>
using System;
using System.Windows.Forms;
using System.Windows.Input;
using Microsoft.Scripting.Hosting.Shell;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests.Console
{
@ -21,14 +22,14 @@ namespace RubyBinding.Tests.Console @@ -21,14 +22,14 @@ namespace RubyBinding.Tests.Console
[TestFixture]
public class RubyConsoleEnterKeyTestFixture
{
MockTextEditor textEditor;
MockConsoleTextEditor textEditor;
RubyConsole console;
string prompt = ">>> ";
[SetUp]
public void Init()
{
textEditor = new MockTextEditor();
textEditor = new MockConsoleTextEditor();
console = new RubyConsole(textEditor, null);
console.Write(prompt, Style.Prompt);
}
@ -36,29 +37,30 @@ namespace RubyBinding.Tests.Console @@ -36,29 +37,30 @@ namespace RubyBinding.Tests.Console
[Test]
public void EnterKeyDoesNotBreakUpExistingLine()
{
textEditor.RaiseKeyPressEvent('a');
textEditor.RaiseKeyPressEvent('b');
textEditor.RaisePreviewKeyDownEvent(Key.A);
textEditor.RaisePreviewKeyDownEvent(Key.B);
textEditor.SelectionStart = 1 + prompt.Length;
textEditor.Column = 1 + prompt.Length;
textEditor.RaiseDialogKeyPressEvent(Keys.Enter);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
Assert.AreEqual(">>> ab\r\n", textEditor.Text);
Assert.AreEqual(">>> AB\r\n", textEditor.Text);
}
[Test]
public void PreviousLineIsReadOnlyAfterEnterPressed()
{
textEditor.RaiseKeyPressEvent('a');
textEditor.RaiseKeyPressEvent('b');
textEditor.RaiseDialogKeyPressEvent(Keys.Enter);
textEditor.RaisePreviewKeyDownEvent(Key.A);
textEditor.RaisePreviewKeyDownEvent(Key.B);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
console.Write(prompt, Style.Prompt);
// Move up a line with cursor.
textEditor.Line = 0;
Assert.IsTrue(textEditor.RaiseKeyPressEvent('c'));
textEditor.RaisePreviewKeyDownEvent(Key.C);
string expectedText = ">>> ab\r\n" +
">>> ";
string expectedText =
">>> AB\r\n" +
">>> ";
Assert.AreEqual(expectedText, textEditor.Text);
}
}

13
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleHomeKeyTestFixture.cs

@ -7,11 +7,12 @@ @@ -7,11 +7,12 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Windows.Input;
using System.Threading;
using Microsoft.Scripting.Hosting.Shell;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests.Console
{
@ -21,14 +22,14 @@ namespace RubyBinding.Tests.Console @@ -21,14 +22,14 @@ namespace RubyBinding.Tests.Console
[TestFixture]
public class RubyConsoleHomeKeyTestFixture
{
MockTextEditor textEditor;
MockConsoleTextEditor textEditor;
RubyConsole console;
string prompt = ">>> ";
[SetUp]
public void Init()
{
textEditor = new MockTextEditor();
textEditor = new MockConsoleTextEditor();
console = new RubyConsole(textEditor, null);
console.Write(prompt, Style.Prompt);
}
@ -36,7 +37,7 @@ namespace RubyBinding.Tests.Console @@ -36,7 +37,7 @@ namespace RubyBinding.Tests.Console
[Test]
public void HomeKeyPressedWhenNoUserTextInConsole()
{
textEditor.RaiseDialogKeyPressEvent(Keys.Home);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Home);
int expectedColumn = prompt.Length;
Assert.AreEqual(expectedColumn, textEditor.Column);
@ -45,8 +46,8 @@ namespace RubyBinding.Tests.Console @@ -45,8 +46,8 @@ namespace RubyBinding.Tests.Console
[Test]
public void HomeKeyPressedWhenTextInConsole()
{
textEditor.RaiseKeyPressEvent('a');
textEditor.RaiseDialogKeyPressEvent(Keys.Home);
textEditor.RaisePreviewKeyDownEvent(Key.A);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Home);
int expectedColumn = prompt.Length;
Assert.AreEqual(expectedColumn, textEditor.Column);

21
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleHostTests.cs

@ -7,14 +7,15 @@ @@ -7,14 +7,15 @@
using System;
using ICSharpCode.AvalonEdit;
using ICSharpCode.RubyBinding;
using ICSharpCode.TextEditor;
using IronRuby.Hosting;
using IronRuby.Runtime;
using NUnit.Framework;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Hosting.Shell;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests.Console
{
@ -25,24 +26,21 @@ namespace RubyBinding.Tests.Console @@ -25,24 +26,21 @@ namespace RubyBinding.Tests.Console
public class RubyConsoleHostTests
{
DerivedRubyConsoleHost host;
TextEditorControl textEditorControl;
TextEditor textEditor;
TextEditor textEditorControl;
RubyConsoleTextEditor textEditor;
[TestFixtureSetUp]
public void Init()
{
textEditorControl = new TextEditorControl();
textEditor = new TextEditor(textEditorControl);
textEditorControl = new TextEditor();
textEditor = new RubyConsoleTextEditor(textEditorControl);
host = new DerivedRubyConsoleHost(textEditor);
//ScriptRuntime runtime = IronRuby.Hosting.Ruby.CreateRuntime();
}
[TestFixtureTearDown]
public void TearDown()
{
host.Dispose();
textEditorControl.Dispose();
}
[Test]
@ -91,7 +89,7 @@ namespace RubyBinding.Tests.Console @@ -91,7 +89,7 @@ namespace RubyBinding.Tests.Console
[Test]
public void HostDisposesRubyConsole()
{
DerivedRubyConsoleHost host = new DerivedRubyConsoleHost(new MockTextEditor());
DerivedRubyConsoleHost host = new DerivedRubyConsoleHost(new MockConsoleTextEditor());
RubyConsole console = host.CallCreateConsole(null, null, null) as RubyConsole;
host.Dispose();
@ -104,13 +102,14 @@ namespace RubyBinding.Tests.Console @@ -104,13 +102,14 @@ namespace RubyBinding.Tests.Console
[Test]
public void DisposingRubyConsoleHostWithoutCreatingRubyConsole()
{
RubyConsoleHost host = new RubyConsoleHost(new MockTextEditor());
RubyConsoleHost host = new RubyConsoleHost(new MockConsoleTextEditor());
host.Dispose();
}
[Test]
public void DefaultOutputStreamReplacedByCustomStreamClass()
{
host.CallCreateConsole(null, null, null);
Assert.IsNotNull(host.OutputStream);
}
@ -118,6 +117,6 @@ namespace RubyBinding.Tests.Console @@ -118,6 +117,6 @@ namespace RubyBinding.Tests.Console
public void ProviderIsRubyContext()
{
Assert.AreEqual(typeof(RubyContext), host.GetProvider());
}
}
}
}

92
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleReadOnlyRegionsTestFixture.cs

@ -6,11 +6,12 @@ @@ -6,11 +6,12 @@
// </file>
using System;
using System.Windows.Forms;
using System.Windows.Input;
using ICSharpCode.RubyBinding;
using Microsoft.Scripting.Hosting.Shell;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests.Console
{
@ -22,13 +23,13 @@ namespace RubyBinding.Tests.Console @@ -22,13 +23,13 @@ namespace RubyBinding.Tests.Console
public class RubyConsoleReadOnlyRegionsTestFixture
{
RubyConsole console;
MockTextEditor textEditor;
MockConsoleTextEditor textEditor;
string prompt = ">>> ";
[SetUp]
public void Init()
{
textEditor = new MockTextEditor();
textEditor = new MockConsoleTextEditor();
console = new RubyConsole(textEditor, null);
console.Write(prompt, Style.Prompt);
}
@ -42,19 +43,19 @@ namespace RubyBinding.Tests.Console @@ -42,19 +43,19 @@ namespace RubyBinding.Tests.Console
[Test]
public void LeftArrowThenInsertNewCharacterInsertsText()
{
textEditor.RaiseKeyPressEvent('a');
textEditor.RaiseKeyPressEvent('b');
textEditor.RaiseDialogKeyPressEvent(Keys.Left);
textEditor.RaiseKeyPressEvent('c');
textEditor.RaisePreviewKeyDownEvent(Key.A);
textEditor.RaisePreviewKeyDownEvent(Key.B);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Left);
textEditor.RaisePreviewKeyDownEvent(Key.C);
Assert.AreEqual("acb", console.GetCurrentLine());
Assert.AreEqual("ACB", console.GetCurrentLine());
}
[Test]
public void MoveOneCharacterIntoPromptTypingShouldBePrevented()
{
textEditor.RaiseDialogKeyPressEvent(Keys.Left);
textEditor.RaiseKeyPressEvent('a');
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Left);
textEditor.RaisePreviewKeyDownEvent(Key.A);
Assert.AreEqual(String.Empty, console.GetCurrentLine());
}
@ -62,94 +63,105 @@ namespace RubyBinding.Tests.Console @@ -62,94 +63,105 @@ namespace RubyBinding.Tests.Console
[Test]
public void MoveOneCharacterIntoPromptAndBackspaceKeyShouldNotRemoveAnything()
{
textEditor.RaiseKeyPressEvent('a');
textEditor.RaiseDialogKeyPressEvent(Keys.Left);
textEditor.RaiseDialogKeyPressEvent(Keys.Back);
textEditor.RaisePreviewKeyDownEvent(Key.A);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Left);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Back);
Assert.AreEqual("a", console.GetCurrentLine());
Assert.AreEqual(prompt + "a", textEditor.Text);
Assert.AreEqual("A", console.GetCurrentLine());
Assert.AreEqual(prompt + "A", textEditor.Text);
}
[Test]
public void MoveTwoCharactersIntoPromptAndBackspaceKeyShouldNotRemoveAnything()
{
textEditor.RaiseKeyPressEvent('a');
textEditor.RaiseDialogKeyPressEvent(Keys.Left);
textEditor.RaiseDialogKeyPressEvent(Keys.Left);
textEditor.RaiseDialogKeyPressEvent(Keys.Back);
textEditor.RaisePreviewKeyDownEvent(Key.A);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Left);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Left);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Back);
Assert.AreEqual("a", console.GetCurrentLine());
Assert.AreEqual(prompt + "a", textEditor.Text);
Assert.AreEqual("A", console.GetCurrentLine());
Assert.AreEqual(prompt + "A", textEditor.Text);
}
[Test]
public void SelectLastCharacterOfPromptThenPressingTheBackspaceKeyShouldNotRemoveAnything()
{
textEditor.RaiseKeyPressEvent('a');
textEditor.RaisePreviewKeyDownEvent(Key.A);
textEditor.SelectionStart = prompt.Length - 1;
textEditor.SelectionLength = 2;
textEditor.Column += 2;
textEditor.RaiseDialogKeyPressEvent(Keys.Back);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Back);
Assert.AreEqual("a", console.GetCurrentLine());
Assert.AreEqual(prompt + "a", textEditor.Text);
Assert.AreEqual("A", console.GetCurrentLine());
Assert.AreEqual(prompt + "A", textEditor.Text);
}
[Test]
public void CanMoveIntoPromptRegionWithLeftCursorKey()
{
textEditor.RaiseDialogKeyPressEvent(Keys.Left);
Assert.IsFalse(textEditor.RaiseDialogKeyPressEvent(Keys.Left));
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Left);
Assert.IsFalse(textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Left));
}
[Test]
public void CanMoveOutOfPromptRegionWithRightCursorKey()
{
textEditor.Column = 0;
Assert.IsFalse(textEditor.RaiseDialogKeyPressEvent(Keys.Right));
Assert.IsFalse(textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Right));
}
[Test]
public void CanMoveOutOfPromptRegionWithUpCursorKey()
{
textEditor.RaiseDialogKeyPressEvent(Keys.Enter);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
console.Write(prompt, Style.Prompt);
textEditor.Column = 0;
Assert.IsFalse(textEditor.RaiseDialogKeyPressEvent(Keys.Up));
Assert.IsFalse(textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Up));
}
[Test]
public void CanMoveInReadOnlyRegionWithDownCursorKey()
{
textEditor.RaiseDialogKeyPressEvent(Keys.Enter);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
console.Write(prompt, Style.Prompt);
textEditor.Column = 0;
textEditor.Line = 0;
Assert.IsFalse(textEditor.RaiseDialogKeyPressEvent(Keys.Down));
Assert.IsFalse(textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Down));
}
[Test]
public void BackspaceKeyPressedIgnoredIfLineIsEmpty()
{
Assert.IsTrue(textEditor.RaiseDialogKeyPressEvent(Keys.Back));
Assert.IsTrue(textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Back));
}
[Test]
public void BackspaceOnPreviousLine()
{
textEditor.RaiseKeyPressEvent('a');
textEditor.RaiseKeyPressEvent('b');
textEditor.RaiseDialogKeyPressEvent(Keys.Enter);
textEditor.RaisePreviewKeyDownEvent(Key.A);
textEditor.RaisePreviewKeyDownEvent(Key.B);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
console.Write(prompt, Style.Prompt);
textEditor.RaiseKeyPressEvent('c');
textEditor.RaisePreviewKeyDownEvent(Key.C);
// Move up a line with cursor.
textEditor.Line = 0;
Assert.IsTrue(textEditor.RaiseDialogKeyPressEvent(Keys.Back));
Assert.AreEqual("c", console.GetCurrentLine());
}
Assert.IsTrue(textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Back));
Assert.AreEqual("C", console.GetCurrentLine());
}
[Test]
public void CanBackspaceFirstCharacterOnLine()
{
textEditor.RaisePreviewKeyDownEvent(Key.A);
textEditor.Column = 5;
textEditor.SelectionStart = 5;
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Back);
Assert.AreEqual(String.Empty, console.GetCurrentLine());
}
}
}

40
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleReadTestFixture.cs

@ -7,11 +7,11 @@ @@ -7,11 +7,11 @@
using System;
using System.Threading;
using System.Windows.Forms;
using System.Windows.Input;
using ICSharpCode.RubyBinding;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests.Console
{
@ -21,19 +21,19 @@ namespace RubyBinding.Tests.Console @@ -21,19 +21,19 @@ namespace RubyBinding.Tests.Console
[TestFixture]
public class RubyConsoleReadTestFixture
{
RubyConsole RubyConsole;
RubyConsole rubyConsole;
int initialAutoIndentSize = 4;
string readLine;
int autoIndentSize;
MockTextEditor mockTextEditor;
MockConsoleTextEditor mockTextEditor;
bool raiseKeyPressEvent;
bool raiseDialogKeyPressEvent;
[TestFixtureSetUp]
public void Init()
{
mockTextEditor = new MockTextEditor();
RubyConsole = new RubyConsole(mockTextEditor, null);
mockTextEditor = new MockConsoleTextEditor();
rubyConsole = new RubyConsole(mockTextEditor, null);
autoIndentSize = initialAutoIndentSize;
Thread thread = new Thread(ReadLineFromConsoleOnDifferentThread);
@ -42,13 +42,13 @@ namespace RubyBinding.Tests.Console @@ -42,13 +42,13 @@ namespace RubyBinding.Tests.Console
int sleepInterval = 10;
int maxWait = 2000;
int currentWait = 0;
while (mockTextEditor.Text.Length < autoIndentSize && currentWait < maxWait) {
while ((mockTextEditor.Text.Length < autoIndentSize) && (currentWait < maxWait)) {
Thread.Sleep(sleepInterval);
currentWait += sleepInterval;
}
raiseKeyPressEvent = mockTextEditor.RaiseKeyPressEvent('a');
raiseDialogKeyPressEvent = mockTextEditor.RaiseDialogKeyPressEvent(Keys.Enter);
raiseKeyPressEvent = mockTextEditor.RaisePreviewKeyDownEvent(Key.A);
raiseDialogKeyPressEvent = mockTextEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
currentWait = 0;
while ((mockTextEditor.Text.Length < autoIndentSize + 2) && (currentWait < maxWait)) {
@ -61,20 +61,20 @@ namespace RubyBinding.Tests.Console @@ -61,20 +61,20 @@ namespace RubyBinding.Tests.Console
[TestFixtureTearDown]
public void TearDown()
{
RubyConsole.Dispose();
rubyConsole.Dispose();
}
[Test]
public void ReadLineFromConsole()
{
string expectedString = String.Empty.PadLeft(initialAutoIndentSize) + "a";
string expectedString = String.Empty.PadLeft(initialAutoIndentSize) + "A";
Assert.AreEqual(expectedString, readLine);
}
[Test]
public void ReadLineWithNonZeroAutoIndentSizeWritesSpacesToTextEditor()
{
string expectedString = String.Empty.PadLeft(initialAutoIndentSize) + "a\r\n";
string expectedString = String.Empty.PadLeft(initialAutoIndentSize) + "A\r\n";
Assert.AreEqual(expectedString, mockTextEditor.Text);
}
@ -87,22 +87,16 @@ namespace RubyBinding.Tests.Console @@ -87,22 +87,16 @@ namespace RubyBinding.Tests.Console
[Test]
public void NoTextWrittenWhenAutoIndentSizeIsZero()
{
MockTextEditor textEditor = new MockTextEditor();
MockConsoleTextEditor textEditor = new MockConsoleTextEditor();
RubyConsole console = new RubyConsole(textEditor, null);
textEditor.RaiseKeyPressEvent('a');
textEditor.RaiseDialogKeyPressEvent(Keys.Enter);
textEditor.RaisePreviewKeyDownEvent(Key.A);
textEditor.RaisePreviewKeyDownEventForDialogKey(Key.Enter);
textEditor.IsWriteCalled = false;
console.ReadLine(0);
Assert.IsFalse(textEditor.IsWriteCalled);
}
[Test]
public void TextEditorIndentStyleSetToNone()
{
Assert.AreEqual(IndentStyle.None, mockTextEditor.IndentStyle);
}
/// <summary>
/// Should return false for any character that should be handled by the text editor itself.s
/// </summary>
@ -124,7 +118,7 @@ namespace RubyBinding.Tests.Console @@ -124,7 +118,7 @@ namespace RubyBinding.Tests.Console
void ReadLineFromConsoleOnDifferentThread()
{
System.Console.WriteLine("Reading on different thread");
readLine = RubyConsole.ReadLine(autoIndentSize);
readLine = rubyConsole.ReadLine(autoIndentSize);
System.Console.WriteLine("Finished reading on different thread");
}
}

29
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleUnreadLinesTestFixture.cs

@ -6,17 +6,16 @@ @@ -6,17 +6,16 @@
// </file>
using System;
using System.Windows.Forms;
using System.Windows.Input;
using ICSharpCode.RubyBinding;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using IronRuby.Hosting;
using IronRuby.Runtime;
using NUnit.Framework;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Hosting.Shell;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests.Console
{
@ -26,38 +25,38 @@ namespace RubyBinding.Tests.Console @@ -26,38 +25,38 @@ namespace RubyBinding.Tests.Console
[TestFixture]
public class RubyConsoleUnreadLinesTestFixture
{
RubyConsole RubyConsole;
MockTextEditor textEditor;
RubyConsole rubyConsole;
MockConsoleTextEditor textEditor;
[SetUp]
public void Init()
{
textEditor = new MockTextEditor();
RubyConsole = new RubyConsole(textEditor, null);
textEditor = new MockConsoleTextEditor();
rubyConsole = new RubyConsole(textEditor, null);
}
[Test]
public void NoUnreadLinesAtStart()
{
Assert.AreEqual(0, RubyConsole.GetUnreadLines().Length);
Assert.AreEqual(0, rubyConsole.GetUnreadLines().Length);
}
[Test]
public void HasUnreadLines()
{
Assert.IsFalse(RubyConsole.IsLineAvailable);
Assert.IsFalse(rubyConsole.IsLineAvailable);
}
[Test]
public void AddOneLine()
{
textEditor.RaiseKeyPressEvent('a');
textEditor.RaiseDialogKeyPressEvent(Keys.Enter);
textEditor.RaisePreviewKeyDownEvent(System.Windows.Input.Key.A);
textEditor.RaisePreviewKeyDownEventForDialogKey(System.Windows.Input.Key.Enter);
string[] expectedLines = new string[] {"a"};
string[] expectedLines = new string[] {"A"};
Assert.AreEqual(expectedLines, RubyConsole.GetUnreadLines());
Assert.IsTrue(RubyConsole.IsLineAvailable);
Assert.AreEqual(expectedLines, rubyConsole.GetUnreadLines());
Assert.IsTrue(rubyConsole.IsLineAvailable);
}
}
}

19
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyConsoleWriteTestFixture.cs

@ -10,6 +10,7 @@ using System.Drawing; @@ -10,6 +10,7 @@ using System.Drawing;
using ICSharpCode.RubyBinding;
using Microsoft.Scripting.Hosting.Shell;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests.Console
{
@ -19,43 +20,43 @@ namespace RubyBinding.Tests.Console @@ -19,43 +20,43 @@ namespace RubyBinding.Tests.Console
[TestFixture]
public class RubyConsoleWriteTestFixture
{
RubyConsole RubyConsole;
MockTextEditor mockTextEditor;
RubyConsole rubyConsole;
MockConsoleTextEditor mockTextEditor;
[SetUp]
public void Init()
{
mockTextEditor = new MockTextEditor();
mockTextEditor = new MockConsoleTextEditor();
mockTextEditor.Text = String.Empty;
RubyConsole = new RubyConsole(mockTextEditor, null);
rubyConsole = new RubyConsole(mockTextEditor, null);
}
[Test]
public void WriteLine()
{
RubyConsole.WriteLine();
rubyConsole.WriteLine();
Assert.AreEqual(Environment.NewLine, mockTextEditor.Text);
}
[Test]
public void WriteLineWithText()
{
RubyConsole.WriteLine("test", Style.Out);
rubyConsole.WriteLine("test", Style.Out);
Assert.AreEqual("test" + Environment.NewLine, mockTextEditor.Text);
}
[Test]
public void TwoWrites()
{
RubyConsole.Write("a", Style.Out);
RubyConsole.Write("b", Style.Out);
rubyConsole.Write("a", Style.Out);
rubyConsole.Write("b", Style.Out);
Assert.AreEqual("ab", mockTextEditor.Text);
}
[Test]
public void DoesNotHasLinesWaitingToBeRead()
{
Assert.IsFalse(RubyConsole.IsLineAvailable);
Assert.IsFalse(rubyConsole.IsLineAvailable);
}
}
}

5
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/RubyOutputStreamTestFixture.cs

@ -11,6 +11,7 @@ using System.Text; @@ -11,6 +11,7 @@ using System.Text;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests.Console
{
@ -18,12 +19,12 @@ namespace RubyBinding.Tests.Console @@ -18,12 +19,12 @@ namespace RubyBinding.Tests.Console
public class RubyOutputStreamTestFixture
{
RubyOutputStream stream;
MockTextEditor textEditor;
MockConsoleTextEditor textEditor;
[TestFixtureSetUp]
public void SetUpFixture()
{
textEditor = new MockTextEditor();
textEditor = new MockConsoleTextEditor();
stream = new RubyOutputStream(textEditor);
}

402
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/TextEditorTestFixture.cs

@ -1,402 +0,0 @@ @@ -1,402 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
namespace RubyBinding.Tests.Console
{
/// <summary>
/// Tests the TextEditor class.
/// </summary>
[TestFixture]
public class TextEditorTestFixture
{
TextEditorControl textEditorControl;
TextEditor textEditor;
IndentStyle defaultTextEditorControlIndentStyle;
IndentStyle defaultTextEditorIndentStyle;
char keyPressed = ' ';
Keys dialogKeyPressed;
Exception indentException;
Exception getLineException;
string lineReadOnDifferentThread = null;
[TestFixtureSetUp]
public void SetUpFixture()
{
textEditorControl = new TextEditorControl();
// Force creation of handle otherwise InvokeRequired always returns false.
textEditorControl.CreateControl();
textEditorControl.IndentStyle = IndentStyle.Smart;
defaultTextEditorControlIndentStyle = textEditorControl.IndentStyle;
textEditor = new TextEditor(textEditorControl);
defaultTextEditorIndentStyle = textEditor.IndentStyle;
}
[TestFixtureTearDown]
public void TearDownFixture()
{
textEditorControl.Dispose();
}
[Test]
public void DefaultTextEditorIndentStyleSameAsTextEditorControl()
{
Assert.AreEqual(defaultTextEditorControlIndentStyle, defaultTextEditorIndentStyle);
}
[Test]
public void TextEditorImplementsITextEditorInterface()
{
Assert.IsNotNull(textEditor as ITextEditor);
}
[Test]
public void IndentStyleUpdatesTextEditor()
{
textEditor.IndentStyle = IndentStyle.None;
Assert.AreEqual(IndentStyle.None, textEditorControl.IndentStyle);
}
[Test]
public void KeyPressEventHandlerImplemented()
{
textEditor.KeyPress += ProcessKeyPress;
try {
textEditorControl.ActiveTextAreaControl.TextArea.SimulateKeyPress('a');
Assert.AreEqual('a', keyPressed);
} finally {
textEditor.KeyPress -= ProcessKeyPress;
}
}
[Test]
public void KeyPressEventHandlerRemoved()
{
keyPressed = ' ';
textEditor.KeyPress += ProcessKeyPress;
textEditor.KeyPress -= ProcessKeyPress;
textEditorControl.ActiveTextAreaControl.TextArea.SimulateKeyPress('b');
Assert.AreEqual(' ', keyPressed);
}
[Test]
public void DialogKeyPressEventHandlerImplemented()
{
textEditor.DialogKeyPress += ProcessDialogKeyPress;
try {
textEditorControl.ActiveTextAreaControl.TextArea.ExecuteDialogKey(Keys.B);
Assert.AreEqual(dialogKeyPressed, Keys.B);
} finally {
textEditor.DialogKeyPress -= ProcessDialogKeyPress;
}
}
[Test]
public void DialogKeyPressEventHandlerRemoved()
{
dialogKeyPressed = Keys.Enter;
textEditor.DialogKeyPress += ProcessDialogKeyPress;
textEditor.DialogKeyPress -= ProcessDialogKeyPress;
textEditorControl.ActiveTextAreaControl.TextArea.ExecuteDialogKey(Keys.Alt);
Assert.AreEqual(Keys.Enter, dialogKeyPressed);
}
[Test]
public void MakeCurrentTextEditorContent()
{
textEditorControl.Text = String.Empty;
textEditor.Write("abc" + Environment.NewLine);
textEditor.MakeCurrentContentReadOnly();
TextMarker readOnlyTextMarker = GetReadOnlyTextMarker(textEditorControl);
Assert.IsNotNull(readOnlyTextMarker);
Assert.AreEqual(0, readOnlyTextMarker.Offset);
Assert.AreEqual(textEditorControl.Text.Length, readOnlyTextMarker.Length);
Assert.IsFalse(textEditorControl.Document.UndoStack.CanUndo);
}
[Test]
public void WriteMethodUpdatesTextEditor()
{
textEditorControl.Document.TextContent = String.Empty;
textEditor.Write("abc");
Assert.AreEqual("abc", textEditorControl.Document.TextContent);
}
[Test]
public void WriteOnDifferentThread()
{
textEditorControl.Document.TextContent = String.Empty;
Thread t = new Thread(WriteText);
t.Start();
// Make sure the GUI events are processed otherwise the
// unit test will never complete.
int maxWait = 2000;
int currentWait = 0;
int sleepInterval = 50;
Application.DoEvents();
while (textEditorControl.Text.Length == 0 && (currentWait < maxWait)) {
Application.DoEvents();
Thread.Sleep(sleepInterval);
currentWait += sleepInterval;
}
// Wait for thread to finish.
t.Join();
Assert.AreEqual("test", textEditorControl.Text);
}
[Test]
public void SetIndentStyleOnDifferentThread()
{
textEditorControl.IndentStyle = IndentStyle.Auto;
Thread t = new Thread(SetIndentStyle);
t.Start();
// Make sure the GUI events are processed otherwise the
// unit test will never complete.
int maxWait = 2000;
int currentWait = 0;
int sleepInterval = 50;
Application.DoEvents();
while (textEditorControl.IndentStyle == IndentStyle.Auto && (currentWait < maxWait)) {
Application.DoEvents();
Thread.Sleep(sleepInterval);
currentWait += sleepInterval;
}
// Wait for thread to finish.
t.Join();
string message = String.Empty;
if (indentException != null) {
message = indentException.ToString();
}
Assert.IsNull(indentException, message);
}
[Test]
public void GetColumnPosition()
{
textEditorControl.Document.TextContent = "test";
textEditorControl.ActiveTextAreaControl.TextArea.Caret.Column = 2;
Assert.AreEqual(2, textEditor.Column);
}
[Test]
public void SetColumnPosition()
{
textEditorControl.Document.TextContent = "test";
textEditorControl.ActiveTextAreaControl.TextArea.Caret.Column = 2;
textEditor.Column = 1;
Assert.AreEqual(1, textEditorControl.ActiveTextAreaControl.TextArea.Caret.Column);
}
[Test]
public void GetSelectionStartAndLength()
{
textEditorControl.Document.TextContent = "te000xt";
TextLocation start = new TextLocation(2, 0);
TextLocation end = new TextLocation(5, 0);
textEditorControl.ActiveTextAreaControl.SelectionManager.SetSelection(start, end);
// Sanity check.
Assert.AreEqual("000", textEditorControl.ActiveTextAreaControl.SelectionManager.SelectedText);
Assert.AreEqual(2, textEditor.SelectionStart);
Assert.AreEqual(3, textEditor.SelectionLength);
}
[Test]
public void GetSelectionStartAndLengthWhenNothingSelected()
{
textEditorControl.Document.TextContent = "text";
textEditorControl.ActiveTextAreaControl.SelectionManager.ClearSelection();
textEditorControl.ActiveTextAreaControl.Caret.Column = 1;
Assert.AreEqual(1, textEditor.SelectionStart);
Assert.AreEqual(0, textEditor.SelectionLength);
}
[Test]
public void TextEditorLineEqualsCaretLine()
{
textEditorControl.Document.TextContent = "abc\r\ndef";
textEditorControl.ActiveTextAreaControl.Caret.Line = 0;
Assert.AreEqual(0, textEditor.Line);
textEditorControl.ActiveTextAreaControl.Caret.Line = 1;
Assert.AreEqual(1, textEditor.Line);
}
[Test]
public void TextEditorTotalLines()
{
textEditorControl.Document.TextContent = "abc\r\ndef\r\nghi";
Assert.AreEqual(3, textEditor.TotalLines);
}
[Test]
public void GetFirstLine()
{
textEditorControl.Document.TextContent = "abc\r\ndef\r\nghi";
Assert.AreEqual("abc", textEditor.GetLine(0));
}
[Test]
public void GetLineOnDifferentThread()
{
textEditorControl.IndentStyle = IndentStyle.Auto;
Thread t = new Thread(GetLine);
t.Start();
// Make sure the GUI events are processed otherwise the
// unit test will never complete.
int maxWait = 2000;
int currentWait = 0;
int sleepInterval = 50;
Application.DoEvents();
while (lineReadOnDifferentThread == null && (currentWait < maxWait)) {
Application.DoEvents();
Thread.Sleep(sleepInterval);
currentWait += sleepInterval;
}
// Wait for thread to finish.
t.Join();
string message = String.Empty;
if (getLineException != null) {
message = getLineException.ToString();
}
Assert.IsNull(getLineException, message);
}
[Test]
public void WriteTextWithBackgroundColour()
{
textEditorControl.Document.TextContent = "abc\r\n>>>";
textEditorControl.ActiveTextAreaControl.Caret.Line = 1;
textEditor.Write(">>> ", Color.Blue);
int offset = textEditorControl.Document.PositionToOffset(new TextLocation(0, 1));
List<TextMarker> markers = textEditorControl.Document.MarkerStrategy.GetMarkers(offset);
TextMarker marker = markers[0];
Assert.AreEqual(Color.Blue, marker.Color);
Assert.AreEqual(TextMarkerType.SolidBlock, marker.TextMarkerType);
Assert.AreEqual(4, marker.Length);
}
[Test]
public void SupportReadOnlySegmentsIsTrue()
{
Assert.IsTrue(textEditorControl.TextEditorProperties.SupportReadOnlySegments);
}
[Test]
public void ReplaceText()
{
textEditorControl.Document.TextContent = "abc\r\ndef";
textEditorControl.ActiveTextAreaControl.Caret.Line = 1;
textEditor.Replace(1, 1, "test");
Assert.AreEqual("abc\r\ndtestf", textEditorControl.Document.TextContent);
}
/// <summary>
/// Run on different thread to set the text editor's indent style.
/// </summary>
void SetIndentStyle()
{
try {
textEditor.IndentStyle = IndentStyle.None;
} catch (Exception ex) {
indentException = ex;
}
}
/// <summary>
/// Run on different thread to set the text editor's indent style.
/// </summary>
void GetLine()
{
try {
lineReadOnDifferentThread = textEditor.GetLine(0);
} catch (Exception ex) {
getLineException = ex;
}
}
/// <summary>
/// Run on different thread to write text to the text editor.
/// </summary>
void WriteText()
{
try {
textEditor.Write("test");
} catch (Exception ex) {
System.Console.WriteLine("WriteText error: " + ex.ToString());
}
}
/// <summary>
/// Event handler for the text editor's DialogKeyPress event.
/// </summary>
bool ProcessDialogKeyPress(Keys keysData)
{
dialogKeyPressed = keysData;
return true;
}
/// <summary>
/// Event handler for the text editor's KeyPress event.
/// </summary>
bool ProcessKeyPress(char ch)
{
keyPressed = ch;
return false;
}
/// <summary>
/// Used to remove all text markers from the text editor.
/// </summary>
bool AllMarkersMatch(TextMarker marker)
{
return true;
}
TextMarker GetReadOnlyTextMarker(TextEditorControl textEditorControl)
{
foreach (TextMarker marker in textEditorControl.Document.MarkerStrategy.TextMarker) {
if (marker.IsReadOnly) {
return marker;
}
}
return null;
}
}
}

41
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/TwoRubyConsoleLinesWaitingTestFixture.cs

@ -7,17 +7,16 @@ @@ -7,17 +7,16 @@
using System;
using System.Threading;
using System.Windows.Forms;
using Input = System.Windows.Input;
using ICSharpCode.RubyBinding;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using IronRuby.Hosting;
using IronRuby.Runtime;
using NUnit.Framework;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Hosting.Shell;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests.Console
{
@ -30,7 +29,7 @@ namespace RubyBinding.Tests.Console @@ -30,7 +29,7 @@ namespace RubyBinding.Tests.Console
{
string line1;
string line2;
RubyConsole RubyConsole;
RubyConsole rubyConsole;
bool lineAvailableBeforeFirstEnterKey;
bool lineAvailableAfterFirstEnterKey;
bool lineAvailableAtEnd;
@ -38,20 +37,20 @@ namespace RubyBinding.Tests.Console @@ -38,20 +37,20 @@ namespace RubyBinding.Tests.Console
[TestFixtureSetUp]
public void SetUpFixture()
{
MockTextEditor textEditor = new MockTextEditor();
using (RubyConsole = new RubyConsole(textEditor, null)) {
MockConsoleTextEditor textEditor = new MockConsoleTextEditor();
using (rubyConsole = new RubyConsole(textEditor, null)) {
textEditor.RaiseKeyPressEvent('a');
textEditor.RaiseKeyPressEvent('=');
textEditor.RaiseKeyPressEvent('1');
lineAvailableBeforeFirstEnterKey = RubyConsole.IsLineAvailable;
textEditor.RaiseDialogKeyPressEvent(Keys.Enter);
lineAvailableAfterFirstEnterKey = RubyConsole.IsLineAvailable;
textEditor.RaisePreviewKeyDownEvent(Input.Key.A);
textEditor.RaisePreviewKeyDownEvent(Input.Key.B);
textEditor.RaisePreviewKeyDownEvent(Input.Key.C);
lineAvailableBeforeFirstEnterKey = rubyConsole.IsLineAvailable;
textEditor.RaisePreviewKeyDownEventForDialogKey(Input.Key.Enter);
lineAvailableAfterFirstEnterKey = rubyConsole.IsLineAvailable;
textEditor.RaiseKeyPressEvent('b');
textEditor.RaiseKeyPressEvent('=');
textEditor.RaiseKeyPressEvent('2');
textEditor.RaiseDialogKeyPressEvent(Keys.Enter);
textEditor.RaisePreviewKeyDownEvent(Input.Key.D);
textEditor.RaisePreviewKeyDownEvent(Input.Key.E);
textEditor.RaisePreviewKeyDownEvent(Input.Key.F);
textEditor.RaisePreviewKeyDownEventForDialogKey(Input.Key.Enter);
Thread t = new Thread(ReadLinesOnSeparateThread);
t.Start();
@ -65,20 +64,20 @@ namespace RubyBinding.Tests.Console @@ -65,20 +64,20 @@ namespace RubyBinding.Tests.Console
currentWait += sleepInterval;
}
lineAvailableAtEnd = RubyConsole.IsLineAvailable;
lineAvailableAtEnd = rubyConsole.IsLineAvailable;
}
}
[Test]
public void FirstLineRead()
{
Assert.AreEqual("a=1", line1);
Assert.AreEqual("ABC", line1);
}
[Test]
public void SecondLineRead()
{
Assert.AreEqual("b=2", line2);
Assert.AreEqual("DEF", line2);
}
[Test]
@ -101,8 +100,8 @@ namespace RubyBinding.Tests.Console @@ -101,8 +100,8 @@ namespace RubyBinding.Tests.Console
void ReadLinesOnSeparateThread()
{
line1 = RubyConsole.ReadLine(0);
line2 = RubyConsole.ReadLine(0);
line1 = rubyConsole.ReadLine(0);
line2 = rubyConsole.ReadLine(0);
}
}
}

9
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/ConvertCSharpToRubyMenuCommandTestFixture.cs

@ -45,11 +45,12 @@ namespace RubyBinding.Tests.Converter @@ -45,11 +45,12 @@ namespace RubyBinding.Tests.Converter
window.ActiveViewContent = mockViewContent;
workbench.ActiveWorkbenchWindow = window;
MockTextEditorProperties textEditorProperties = new MockTextEditorProperties();
textEditorProperties.IndentationSize = 4;
textEditorProperties.ConvertTabsToSpaces = true;
MockTextEditorOptions options = new MockTextEditorOptions();
options.IndentationSize = 4;
options.ConvertTabsToSpaces = true;
mockViewContent.TextEditorOptions = options;
Run(workbench, textEditorProperties);
Run(workbench);
}
[Test]

21
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/ConvertToRubyProjectCommandTestFixture.cs

@ -30,15 +30,15 @@ namespace RubyBinding.Tests.Converter @@ -30,15 +30,15 @@ namespace RubyBinding.Tests.Converter
RubyProject targetProject;
FileProjectItem textFileSource;
FileProjectItem textFileTarget;
MockTextEditorProperties mockTextEditorProperties;
ParseInformation parseInfo;
string sourceCode = "class Foo\r\n" +
"{\r\n" +
" static void Main()\r\n" +
" {\r\n" +
" }\r\n" +
"}";
string sourceCode =
"class Foo\r\n" +
"{\r\n" +
" static void Main()\r\n" +
" {\r\n" +
" }\r\n" +
"}";
[TestFixtureSetUp]
public void SetUpFixture()
@ -52,11 +52,10 @@ namespace RubyBinding.Tests.Converter @@ -52,11 +52,10 @@ namespace RubyBinding.Tests.Converter
}
ProjectBindingService.SetBindings(bindings);
mockTextEditorProperties = new MockTextEditorProperties();
convertProjectCommand = new DerivedConvertProjectToRubyProjectCommand(mockTextEditorProperties);
convertProjectCommand = new DerivedConvertProjectToRubyProjectCommand();
parseInfo = new ParseInformation(new DefaultCompilationUnit(new DefaultProjectContent()));
convertProjectCommand.ParseInfo = parseInfo;
mockTextEditorProperties.Encoding = Encoding.Unicode;
convertProjectCommand.FileServiceDefaultEncoding = Encoding.Unicode;
sourceProject = new MockProject();
sourceProject.Directory = @"d:\projects\test";
@ -111,7 +110,7 @@ namespace RubyBinding.Tests.Converter @@ -111,7 +110,7 @@ namespace RubyBinding.Tests.Converter
converter.GenerateMainMethodCall(converter.EntryPointMethods[0]);
List<ConvertedFile> expectedSavedFiles = new List<ConvertedFile>();
expectedSavedFiles.Add(new ConvertedFile(target.FileName, expectedCode, mockTextEditorProperties.Encoding));
expectedSavedFiles.Add(new ConvertedFile(target.FileName, expectedCode, Encoding.Unicode));
Assert.AreEqual(expectedSavedFiles, convertProjectCommand.SavedFiles);
}

9
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/ConvertVBNetToRubyMenuCommandTestFixture.cs

@ -42,11 +42,12 @@ namespace RubyBinding.Tests.Converter @@ -42,11 +42,12 @@ namespace RubyBinding.Tests.Converter
window.ActiveViewContent = mockViewContent;
workbench.ActiveWorkbenchWindow = window;
MockTextEditorProperties textEditorProperties = new MockTextEditorProperties();
textEditorProperties.ConvertTabsToSpaces = false;
textEditorProperties.IndentationSize = 2;
MockTextEditorOptions options = new MockTextEditorOptions();
options.ConvertTabsToSpaces = false;
options.IndentationSize = 2;
mockViewContent.TextEditorOptions = options;
Run(workbench, textEditorProperties);
Run(workbench);
}
[Test]

4
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/FormsDesignerDisplayBindingTestFixture.cs

@ -115,7 +115,7 @@ namespace RubyBinding.Tests @@ -115,7 +115,7 @@ namespace RubyBinding.Tests
public void CreatesRubyFormsDesigner()
{
MockTextEditorViewContent view = new MockTextEditorViewContent();
IViewContent[] views = displayBinding.CreateSecondaryViewContent(view, new MockTextEditorProperties());
IViewContent[] views = displayBinding.CreateSecondaryViewContent(view, new MockTextEditorOptions());
Assert.AreEqual(1, views.Length);
Assert.IsTrue(views[0] is FormsDesignerViewContent);
views[0].Dispose();
@ -128,7 +128,7 @@ namespace RubyBinding.Tests @@ -128,7 +128,7 @@ namespace RubyBinding.Tests
IViewContent[] views = null;
using (FormsDesignerViewContent formsDesigner = new FormsDesignerViewContent(view, new MockOpenedFile("test.rb"))) {
view.SecondaryViewContents.Add(formsDesigner);
views = displayBinding.CreateSecondaryViewContent(view, new MockTextEditorProperties());
views = displayBinding.CreateSecondaryViewContent(view, new MockTextEditorOptions());
}
Assert.AreEqual(0, views.Length);
}

1
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs

@ -38,7 +38,6 @@ namespace RubyBinding.Tests.Designer @@ -38,7 +38,6 @@ namespace RubyBinding.Tests.Designer
[TestFixtureSetUp]
public void SetUpFixture()
{
MockTextEditorProperties textEditorProperties = new MockTextEditorProperties();
generator = new DerivedRubyDesignerGenerator();
mockViewContent = new MockTextEditorViewContent();
viewContent = new FormsDesignerViewContent(mockViewContent, new MockOpenedFile("Test.rb"));

6
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/InsertEventHandlerTestFixtureBase.cs

@ -26,13 +26,13 @@ namespace RubyBinding.Tests.Designer @@ -26,13 +26,13 @@ namespace RubyBinding.Tests.Designer
protected DerivedFormDesignerViewContent viewContent;
protected string fileName = @"C:\Projects\Ruby\mainform.rb";
protected DerivedRubyDesignerGenerator generator;
protected MockTextEditorProperties textEditorProperties;
protected MockTextEditorOptions textEditorOptions;
[TestFixtureSetUp]
public void SetUpFixture()
{
textEditorProperties = new MockTextEditorProperties();
generator = new DerivedRubyDesignerGenerator(textEditorProperties);
textEditorOptions = new MockTextEditorOptions();
generator = new DerivedRubyDesignerGenerator(textEditorOptions);
mockViewContent = new MockTextEditorViewContent();
viewContent = new DerivedFormDesignerViewContent(mockViewContent, new MockOpenedFile(fileName));
generator.Attach(viewContent);

4
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/InsertEventHandlerWithSpaceIndentTestFixture.cs

@ -23,8 +23,8 @@ namespace RubyBinding.Tests.Designer @@ -23,8 +23,8 @@ namespace RubyBinding.Tests.Designer
{
public override void AfterSetUpFixture()
{
textEditorProperties.ConvertTabsToSpaces = true;
textEditorProperties.IndentationSize = 4;
textEditorOptions.ConvertTabsToSpaces = true;
textEditorOptions.IndentationSize = 4;
MockEventDescriptor mockEventDescriptor = new MockEventDescriptor("Click");
insertedEventHandler = generator.InsertComponentEvent(null, mockEventDescriptor, "button1_click", String.Empty, out file, out position);
}

42
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/MergeFormTestFixture.cs

@ -14,11 +14,12 @@ using System.Drawing; @@ -14,11 +14,12 @@ using System.Drawing;
using System.IO;
using System.Windows.Forms;
using AvalonEdit = ICSharpCode.AvalonEdit;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Refactoring;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
@ -31,7 +32,7 @@ namespace RubyBinding.Tests.Designer @@ -31,7 +32,7 @@ namespace RubyBinding.Tests.Designer
[TestFixture]
public class MergeFormTestFixture
{
IDocument document;
TextDocument document;
MockResourceService resourceService;
MockResourceWriter resourceWriter;
@ -42,26 +43,25 @@ namespace RubyBinding.Tests.Designer @@ -42,26 +43,25 @@ namespace RubyBinding.Tests.Designer
resourceService = new MockResourceService();
resourceService.SetResourceWriter(resourceWriter);
using (TextEditorControl textEditor = new TextEditorControl()) {
document = textEditor.Document;
textEditor.Text = GetTextEditorCode();
AvalonEdit.TextEditor textEditor = new AvalonEdit.TextEditor();
document = textEditor.Document;
textEditor.Text = GetTextEditorCode();
RubyParser parser = new RubyParser();
ICompilationUnit compilationUnit = parser.Parse(new DefaultProjectContent(), @"test.rb", document.TextContent);
RubyParser parser = new RubyParser();
ICompilationUnit compilationUnit = parser.Parse(new DefaultProjectContent(), @"test.rb", document.Text);
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(499, 309);
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(499, 309);
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
using (serializationManager.CreateSession()) {
RubyDesignerGenerator.Merge(host, new TextEditorDocument(document), compilationUnit, new MockTextEditorProperties(), serializationManager);
}
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
using (serializationManager.CreateSession()) {
RubyDesignerGenerator.Merge(host, new AvalonEditDocumentAdapter(document, null), compilationUnit, new MockTextEditorOptions(), serializationManager);
}
}
}
@ -70,7 +70,7 @@ namespace RubyBinding.Tests.Designer @@ -70,7 +70,7 @@ namespace RubyBinding.Tests.Designer
public void MergedDocumentText()
{
string expectedText = GetTextEditorCode().Replace(GetTextEditorInitializeComponentMethod(), GetGeneratedInitializeComponentMethod());
Assert.AreEqual(expectedText, document.TextContent);
Assert.AreEqual(expectedText, document.Text);
}
string GetGeneratedCode()

46
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/NoNewLineAfterInitializeComponentMethodTestFixture.cs

@ -14,11 +14,13 @@ using System.Drawing; @@ -14,11 +14,13 @@ using System.Drawing;
using System.IO;
using System.Windows.Forms;
using AvalonEdit = ICSharpCode.AvalonEdit;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Refactoring;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
@ -30,31 +32,31 @@ namespace RubyBinding.Tests.Designer @@ -30,31 +32,31 @@ namespace RubyBinding.Tests.Designer
[TestFixture]
public class NoNewLineAfterInitializeComponentMethodTestFixture
{
IDocument document;
TextDocument document;
[TestFixtureSetUp]
public void SetUpFixture()
{
using (TextEditorControl textEditor = new TextEditorControl()) {
document = textEditor.Document;
textEditor.Text = GetTextEditorCode();
AvalonEdit.TextEditor textEditor = new AvalonEdit.TextEditor();
document = textEditor.Document;
textEditor.Text = GetTextEditorCode();
RubyParser parser = new RubyParser();
ICompilationUnit compilationUnit = parser.Parse(new DefaultProjectContent(), @"test.py", document.TextContent);
RubyParser parser = new RubyParser();
ICompilationUnit compilationUnit = parser.Parse(new DefaultProjectContent(), @"test.py", document.Text);
using (DesignSurface designSurface = new DesignSurface(typeof(UserControl))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
UserControl userControl = (UserControl)host.RootComponent;
userControl.ClientSize = new Size(489, 389);
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(userControl);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(userControl, "userControl1");
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
using (serializationManager.CreateSession()) {
RubyDesignerGenerator.Merge(host, new TextEditorDocument(document), compilationUnit, new MockTextEditorProperties(), serializationManager);
}
using (DesignSurface designSurface = new DesignSurface(typeof(UserControl))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
UserControl userControl = (UserControl)host.RootComponent;
userControl.ClientSize = new Size(489, 389);
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(userControl);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(userControl, "userControl1");
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
using (serializationManager.CreateSession()) {
AvalonEditDocumentAdapter docAdapter = new AvalonEditDocumentAdapter(document, null);
RubyDesignerGenerator.Merge(host, docAdapter, compilationUnit, new MockTextEditorOptions(), serializationManager);
}
}
}
@ -81,7 +83,7 @@ namespace RubyBinding.Tests.Designer @@ -81,7 +83,7 @@ namespace RubyBinding.Tests.Designer
"\tend\r\n" +
"end";
Assert.AreEqual(expectedCode, document.TextContent);
Assert.AreEqual(expectedCode, document.Text);
}
/// <summary>

1
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/NullGeneratorPassedToLoader.cs

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
using System;
using ICSharpCode.RubyBinding;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
namespace RubyBinding.Tests.Designer

2
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/OneCompatibleMethodTestFixture.cs

@ -12,8 +12,6 @@ using System.Collections; @@ -12,8 +12,6 @@ using System.Collections;
using System.IO;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests.Utils;

158
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/ProjectRootNamespacePassedToMergeTestFixture.cs

@ -14,11 +14,13 @@ using System.Drawing; @@ -14,11 +14,13 @@ using System.Drawing;
using System.IO;
using System.Windows.Forms;
using AvalonEdit = ICSharpCode.AvalonEdit;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Refactoring;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
@ -30,48 +32,48 @@ namespace RubyBinding.Tests.Designer @@ -30,48 +32,48 @@ namespace RubyBinding.Tests.Designer
[TestFixture]
public class ProjectRootNamespacePassedToMergeTestFixture
{
IDocument document;
TextDocument document;
[TestFixtureSetUp]
public void SetUpFixture()
{
using (TextEditorControl textEditor = new TextEditorControl()) {
document = textEditor.Document;
textEditor.Text = GetTextEditorCode();
AvalonEdit.TextEditor textEditor = new AvalonEdit.TextEditor();
document = textEditor.Document;
textEditor.Text = GetTextEditorCode();
RubyParser parser = new RubyParser();
MockProjectContent projectContent = new MockProjectContent();
MockProject project = new MockProject();
project.RootNamespace = "RootNamespace";
projectContent.Project = project;
ICompilationUnit compilationUnit = parser.Parse(projectContent, @"test.py", document.TextContent);
RubyParser parser = new RubyParser();
MockProjectContent projectContent = new MockProjectContent();
MockProject project = new MockProject();
project.RootNamespace = "RootNamespace";
projectContent.Project = project;
ICompilationUnit compilationUnit = parser.Parse(projectContent, @"test.py", document.Text);
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
IEventBindingService eventBindingService = new MockEventBindingService(host);
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(200, 300);
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
IEventBindingService eventBindingService = new MockEventBindingService(host);
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(200, 300);
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
// Add picture box
PictureBox pictureBox = (PictureBox)host.CreateComponent(typeof(PictureBox), "pictureBox1");
pictureBox.Location = new Point(0, 0);
pictureBox.Image = new Bitmap(10, 10);
pictureBox.Size = new Size(100, 120);
pictureBox.TabIndex = 0;
form.Controls.Add(pictureBox);
MockTextEditorOptions options = new MockTextEditorOptions();
options.ConvertTabsToSpaces = true;
options.IndentationSize = 4;
// Add picture box
PictureBox pictureBox = (PictureBox)host.CreateComponent(typeof(PictureBox), "pictureBox1");
pictureBox.Location = new Point(0, 0);
pictureBox.Image = new Bitmap(10, 10);
pictureBox.Size = new Size(100, 120);
pictureBox.TabIndex = 0;
form.Controls.Add(pictureBox);
MockTextEditorProperties properties = new MockTextEditorProperties();
properties.ConvertTabsToSpaces = true;
properties.IndentationSize = 4;
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
using (serializationManager.CreateSession()) {
RubyDesignerGenerator.Merge(host, new TextEditorDocument(document), compilationUnit, properties, serializationManager);
}
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
using (serializationManager.CreateSession()) {
AvalonEditDocumentAdapter docAdapter = new AvalonEditDocumentAdapter(document, null);
RubyDesignerGenerator.Merge(host, docAdapter, compilationUnit, options, serializationManager);
}
}
}
@ -79,51 +81,53 @@ namespace RubyBinding.Tests.Designer @@ -79,51 +81,53 @@ namespace RubyBinding.Tests.Designer
[Test]
public void GeneratedCode()
{
string expectedCode = "require \"System.Windows.Forms\"\r\n" +
"\r\n" +
"class MainForm < Form\r\n" +
" def initialize()\r\n" +
" self.InitializeComponent()\r\n" +
" end\r\n" +
" \r\n" +
" def InitializeComponent()\r\n" +
" resources = System::Resources::ResourceManager.new(\"RootNamespace.MainForm\", System::Reflection::Assembly.GetEntryAssembly())\r\n" +
" @pictureBox1 = System::Windows::Forms::PictureBox.new()\r\n" +
" self.SuspendLayout()\r\n" +
" # \r\n" +
" # pictureBox1\r\n" +
" # \r\n" +
" @pictureBox1.Image = resources.GetObject(\"pictureBox1.Image\")\r\n" +
" @pictureBox1.Location = System::Drawing::Point.new(0, 0)\r\n" +
" @pictureBox1.Name = \"pictureBox1\"\r\n" +
" @pictureBox1.Size = System::Drawing::Size.new(100, 120)\r\n" +
" @pictureBox1.TabIndex = 0\r\n" +
" @pictureBox1.TabStop = false\r\n" +
" # \r\n" +
" # MainForm\r\n" +
" # \r\n" +
" self.ClientSize = System::Drawing::Size.new(200, 300)\r\n" +
" self.Controls.Add(@pictureBox1)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.ResumeLayout(false)\r\n" +
" end\r\n" +
"end";
Assert.AreEqual(expectedCode, document.TextContent, document.TextContent);
string expectedCode =
"require \"System.Windows.Forms\"\r\n" +
"\r\n" +
"class MainForm < Form\r\n" +
" def initialize()\r\n" +
" self.InitializeComponent()\r\n" +
" end\r\n" +
" \r\n" +
" def InitializeComponent()\r\n" +
" resources = System::Resources::ResourceManager.new(\"RootNamespace.MainForm\", System::Reflection::Assembly.GetEntryAssembly())\r\n" +
" @pictureBox1 = System::Windows::Forms::PictureBox.new()\r\n" +
" self.SuspendLayout()\r\n" +
" # \r\n" +
" # pictureBox1\r\n" +
" # \r\n" +
" @pictureBox1.Image = resources.GetObject(\"pictureBox1.Image\")\r\n" +
" @pictureBox1.Location = System::Drawing::Point.new(0, 0)\r\n" +
" @pictureBox1.Name = \"pictureBox1\"\r\n" +
" @pictureBox1.Size = System::Drawing::Size.new(100, 120)\r\n" +
" @pictureBox1.TabIndex = 0\r\n" +
" @pictureBox1.TabStop = false\r\n" +
" # \r\n" +
" # MainForm\r\n" +
" # \r\n" +
" self.ClientSize = System::Drawing::Size.new(200, 300)\r\n" +
" self.Controls.Add(@pictureBox1)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.ResumeLayout(false)\r\n" +
" end\r\n" +
"end";
Assert.AreEqual(expectedCode, document.Text, document.Text);
}
string GetTextEditorCode()
{
return "require \"System.Windows.Forms\"\r\n" +
"\r\n" +
"class MainForm < Form\r\n" +
" def initialize()\r\n" +
" self.InitializeComponent()\r\n" +
" end\r\n" +
" \r\n" +
" def InitializeComponent()\r\n" +
" end\r\n" +
"end";
return
"require \"System.Windows.Forms\"\r\n" +
"\r\n" +
"class MainForm < Form\r\n" +
" def initialize()\r\n" +
" self.InitializeComponent()\r\n" +
" end\r\n" +
" \r\n" +
" def InitializeComponent()\r\n" +
" end\r\n" +
"end";
}
}
}

1
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/RubyDesignerLoaderTestFixture.cs

@ -18,7 +18,6 @@ using System.Windows.Forms; @@ -18,7 +18,6 @@ using System.Windows.Forms;
using ICSharpCode.FormsDesigner;
using ICSharpCode.FormsDesigner.Services;
using ICSharpCode.RubyBinding;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests.Utils;

8
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/TextEditorIndentPassedToGeneratorTestFixture.cs

@ -60,11 +60,11 @@ namespace RubyBinding.Tests.Designer @@ -60,11 +60,11 @@ namespace RubyBinding.Tests.Designer
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
MockTextEditorProperties textEditorProperties = new MockTextEditorProperties();
textEditorProperties.ConvertTabsToSpaces = true;
textEditorProperties.IndentationSize = 1;
MockTextEditorOptions textEditorOptions = new MockTextEditorOptions();
textEditorOptions.ConvertTabsToSpaces = true;
textEditorOptions.IndentationSize = 1;
DerivedRubyDesignerGenerator generator = new DerivedRubyDesignerGenerator(textEditorProperties);
DerivedRubyDesignerGenerator generator = new DerivedRubyDesignerGenerator(textEditorOptions);
generator.ParseInfoToReturnFromParseFileMethod = parseInfo;
generator.Attach(viewContent);
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);

2
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/DebugRunRubyCommandTestFixture.cs → src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/DebugRunRubyCommandTestFixture.cs

@ -13,7 +13,7 @@ using ICSharpCode.RubyBinding; @@ -13,7 +13,7 @@ using ICSharpCode.RubyBinding;
using RubyBinding.Tests.Utils;
using NUnit.Framework;
namespace RubyBinding.Tests
namespace RubyBinding.Tests.Gui
{
[TestFixture]
public class DebugRubyCommandTestFixture

206
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyIndentationTests.cs → src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RubyIndentationTests.cs

@ -6,14 +6,15 @@ @@ -6,14 +6,15 @@
// </file>
using System;
using ICSharpCode.AvalonEdit;
using ICSharpCode.RubyBinding;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.TextEditor.Actions;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests
namespace RubyBinding.Tests.Gui
{
/// <summary>
/// Tests that the RubyFormattingStrategy indents the new line added after method and class definitions.
@ -21,39 +22,38 @@ namespace RubyBinding.Tests @@ -21,39 +22,38 @@ namespace RubyBinding.Tests
[TestFixture]
public class RubyNewMethodIndentationTestFixture
{
TextEditorControl textEditor;
TextEditor textEditor;
RubyFormattingStrategy formattingStrategy;
AvalonEditTextEditorAdapter textEditorAdapter;
[SetUp]
public void Init()
{
MockTextEditorProperties textEditorProperties = new MockTextEditorProperties();
textEditorProperties.IndentStyle = IndentStyle.Smart;
textEditorProperties.TabIndent = 4;
textEditor = new TextEditorControl();
textEditor.TextEditorProperties = textEditorProperties;
MockTextEditorOptions textEditorOptions = new MockTextEditorOptions();
textEditorOptions.IndentationSize = 4;
textEditor = new TextEditor();
textEditor.Options = textEditorOptions;
textEditorAdapter = new AvalonEditTextEditorAdapter(textEditor);
formattingStrategy = new RubyFormattingStrategy();
}
[TearDown]
public void TearDown()
{
textEditor.Dispose();
}
[Test]
public void NewMethodDefinition()
{
textEditor.Text =
"def newMethod\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"def newMethod\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -62,13 +62,15 @@ namespace RubyBinding.Tests @@ -62,13 +62,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"def newMethod()\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"def newMethod()\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -77,13 +79,15 @@ namespace RubyBinding.Tests @@ -77,13 +79,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"class MyClass\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"class MyClass\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -92,13 +96,15 @@ namespace RubyBinding.Tests @@ -92,13 +96,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"\tprint 'abc'\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"\tprint 'abc'\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -109,7 +115,9 @@ namespace RubyBinding.Tests @@ -109,7 +115,9 @@ namespace RubyBinding.Tests
"\treturn 0\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 2);
IDocumentLine line = textEditorAdapter.Document.GetLine(3);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"def method1\r\n" +
"\treturn 0\r\n" +
@ -125,7 +133,10 @@ namespace RubyBinding.Tests @@ -125,7 +133,10 @@ namespace RubyBinding.Tests
"def method1\r\n" +
"\treturn\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 2);
IDocumentLine line = textEditorAdapter.Document.GetLine(3);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"def method1\r\n" +
"\treturn\r\n" +
@ -139,7 +150,10 @@ namespace RubyBinding.Tests @@ -139,7 +150,10 @@ namespace RubyBinding.Tests
textEditor.Text =
"return\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"return\r\n" +
"";
@ -153,7 +167,10 @@ namespace RubyBinding.Tests @@ -153,7 +167,10 @@ namespace RubyBinding.Tests
textEditor.Text =
"\treturnValue\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"\treturnValue\r\n" +
"\t";
@ -168,7 +185,10 @@ namespace RubyBinding.Tests @@ -168,7 +185,10 @@ namespace RubyBinding.Tests
"def method1\r\n" +
"\traise 'a'\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 2);
IDocumentLine line = textEditorAdapter.Document.GetLine(3);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"def method1\r\n" +
"\traise 'a'\r\n" +
@ -184,7 +204,10 @@ namespace RubyBinding.Tests @@ -184,7 +204,10 @@ namespace RubyBinding.Tests
"def method1\r\n" +
"\traise\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 2);
IDocumentLine line = textEditorAdapter.Document.GetLine(3);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"def method1\r\n" +
"\traise\r\n" +
@ -200,7 +223,10 @@ namespace RubyBinding.Tests @@ -200,7 +223,10 @@ namespace RubyBinding.Tests
"def method1\r\n" +
"\traiseThis\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 2);
IDocumentLine line = textEditorAdapter.Document.GetLine(3);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"def method1\r\n" +
"\traiseThis\r\n" +
@ -216,7 +242,10 @@ namespace RubyBinding.Tests @@ -216,7 +242,10 @@ namespace RubyBinding.Tests
"def method1\r\n" +
"\tbreak\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 2);
IDocumentLine line = textEditorAdapter.Document.GetLine(3);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"def method1\r\n" +
"\tbreak\r\n" +
@ -232,7 +261,10 @@ namespace RubyBinding.Tests @@ -232,7 +261,10 @@ namespace RubyBinding.Tests
"def method1\r\n" +
"\tbreakThis\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 2);
IDocumentLine line = textEditorAdapter.Document.GetLine(3);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"def method1\r\n" +
"\tbreakThis\r\n" +
@ -247,13 +279,15 @@ namespace RubyBinding.Tests @@ -247,13 +279,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"if i > 0 then\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"if i > 0 then\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -262,13 +296,15 @@ namespace RubyBinding.Tests @@ -262,13 +296,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"if i > 0\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"if i > 0\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -277,13 +313,15 @@ namespace RubyBinding.Tests @@ -277,13 +313,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"else\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"else\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -292,13 +330,15 @@ namespace RubyBinding.Tests @@ -292,13 +330,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"elsif i > 0\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"elsif i > 0\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -307,13 +347,15 @@ namespace RubyBinding.Tests @@ -307,13 +347,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"loop do\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"loop do\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -322,13 +364,15 @@ namespace RubyBinding.Tests @@ -322,13 +364,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"unless i > 0\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"unless i > 0\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -337,13 +381,15 @@ namespace RubyBinding.Tests @@ -337,13 +381,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"until i > 0\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"until i > 0\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -352,13 +398,15 @@ namespace RubyBinding.Tests @@ -352,13 +398,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"for i in 1..5\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"for i in 1..5\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -367,13 +415,15 @@ namespace RubyBinding.Tests @@ -367,13 +415,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"expr do\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"expr do\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -382,13 +432,15 @@ namespace RubyBinding.Tests @@ -382,13 +432,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"expr {\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"expr {\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -397,13 +449,15 @@ namespace RubyBinding.Tests @@ -397,13 +449,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"begin\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"begin\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -412,13 +466,15 @@ namespace RubyBinding.Tests @@ -412,13 +466,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"rescue Exception => ex\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"rescue Exception => ex\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -427,13 +483,15 @@ namespace RubyBinding.Tests @@ -427,13 +483,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"rescue\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"rescue\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -442,13 +500,15 @@ namespace RubyBinding.Tests @@ -442,13 +500,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"ensure\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"ensure\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -457,13 +517,15 @@ namespace RubyBinding.Tests @@ -457,13 +517,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"module Foo\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"module Foo\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -473,14 +535,16 @@ namespace RubyBinding.Tests @@ -473,14 +535,16 @@ namespace RubyBinding.Tests
"case num\r\n" +
"\twhen 0\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 2);
IDocumentLine line = textEditorAdapter.Document.GetLine(3);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"case num\r\n" +
"\twhen 0\r\n" +
"\t\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(2, indentResult);
}
[Test]
@ -489,13 +553,15 @@ namespace RubyBinding.Tests @@ -489,13 +553,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"case num\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"case num\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
[Test]
@ -504,13 +570,15 @@ namespace RubyBinding.Tests @@ -504,13 +570,15 @@ namespace RubyBinding.Tests
textEditor.Text =
"value = case num\r\n" +
"";
int indentResult = formattingStrategy.IndentLine(textEditor.ActiveTextAreaControl.TextArea, 1);
IDocumentLine line = textEditorAdapter.Document.GetLine(2);
formattingStrategy.IndentLine(textEditorAdapter, line);
string expectedText =
"value = case num\r\n" +
"\t";
Assert.AreEqual(expectedText, textEditor.Text);
Assert.AreEqual(1, indentResult);
}
}
}

6
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyOptionsPanelTestFixture.cs → src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RubyOptionsPanelTestFixture.cs

@ -14,7 +14,7 @@ using ICSharpCode.SharpDevelop.Gui; @@ -14,7 +14,7 @@ using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Gui.OptionPanels;
using NUnit.Framework;
namespace RubyBinding.Tests
namespace RubyBinding.Tests.Gui
{
/// <summary>
/// Tests the RubyOptionsPanel.
@ -24,14 +24,14 @@ namespace RubyBinding.Tests @@ -24,14 +24,14 @@ namespace RubyBinding.Tests
{
RubyOptionsPanel optionsPanel;
Properties properties;
AddInOptions options;
RubyAddInOptions options;
TextBox fileNameTextBox;
[SetUp]
public void SetUp()
{
properties = new Properties();
options = new AddInOptions(properties);
options = new RubyAddInOptions(properties);
options.RubyFileName = @"C:\Ruby\ir.exe";
optionsPanel = new RubyOptionsPanel(options);
optionsPanel.LoadPanelContents();

2
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RunRubyCommandTestFixture.cs → src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RunRubyCommandTestFixture.cs

@ -13,7 +13,7 @@ using ICSharpCode.SharpDevelop.Gui; @@ -13,7 +13,7 @@ using ICSharpCode.SharpDevelop.Gui;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests
namespace RubyBinding.Tests.Gui
{
/// <summary>
/// Tests that the RunRubyCommand class runs the Ruby console

1
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseClassMethodWithBodyTestFixture.cs

@ -15,7 +15,6 @@ using ICSharpCode.AvalonEdit.Folding; @@ -15,7 +15,6 @@ using ICSharpCode.AvalonEdit.Folding;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests;

1
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseClassWithBaseClassTestFixture.cs

@ -10,7 +10,6 @@ using System.Collections.Generic; @@ -10,7 +10,6 @@ using System.Collections.Generic;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests;

1
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseClassWithCtorTestFixture.cs

@ -15,7 +15,6 @@ using ICSharpCode.AvalonEdit.Folding; @@ -15,7 +15,6 @@ using ICSharpCode.AvalonEdit.Folding;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests;

8
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseClassWithNewLineBeforeMethodTestFixture.cs

@ -15,7 +15,6 @@ using ICSharpCode.AvalonEdit.Folding; @@ -15,7 +15,6 @@ using ICSharpCode.AvalonEdit.Folding;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests;
@ -56,11 +55,6 @@ namespace RubyBinding.Tests.Parsing @@ -56,11 +55,6 @@ namespace RubyBinding.Tests.Parsing
// Get folds.
ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(textArea);
DocumentFactory docFactory = new DocumentFactory();
IDocument doc = docFactory.CreateDocument();
doc.TextContent = ruby;
ParseInformation parseInfo = new ParseInformation(compilationUnit);
foldingStrategy.UpdateFoldings(parseInfo);
List<FoldingSection> folds = new List<FoldingSection>(foldingStrategy.FoldingManager.AllFoldings);
@ -73,7 +67,7 @@ namespace RubyBinding.Tests.Parsing @@ -73,7 +67,7 @@ namespace RubyBinding.Tests.Parsing
}
}
}
[Test]
public void ClassBodyRegion()
{

1
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseClassWithSingleMethodTestFixture.cs

@ -15,7 +15,6 @@ using ICSharpCode.AvalonEdit.Folding; @@ -15,7 +15,6 @@ using ICSharpCode.AvalonEdit.Folding;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests;

1
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseMethodWithOptionalParametersTestFixture.cs

@ -10,7 +10,6 @@ using System.Collections.Generic; @@ -10,7 +10,6 @@ using System.Collections.Generic;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests;

1
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseMethodWithParametersTestFixture.cs

@ -10,7 +10,6 @@ using System.Collections.Generic; @@ -10,7 +10,6 @@ using System.Collections.Generic;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests;

1
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseMethodsWithNoClassTestFixture.cs

@ -15,7 +15,6 @@ using ICSharpCode.AvalonEdit.Folding; @@ -15,7 +15,6 @@ using ICSharpCode.AvalonEdit.Folding;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests;

1
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseModuleTestFixture.cs

@ -15,7 +15,6 @@ using ICSharpCode.AvalonEdit.Folding; @@ -15,7 +15,6 @@ using ICSharpCode.AvalonEdit.Folding;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests;

1
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseRequireFollowedByCommentTestFixture.cs

@ -10,7 +10,6 @@ using System.Collections.Generic; @@ -10,7 +10,6 @@ using System.Collections.Generic;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests;

1
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Parsing/ParseRequireTestFixture.cs

@ -10,7 +10,6 @@ using System.Collections.Generic; @@ -10,7 +10,6 @@ using System.Collections.Generic;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using RubyBinding.Tests;

45
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj

@ -70,15 +70,16 @@ @@ -70,15 +70,16 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="AddInOptionsTestFixture.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Configuration\RubyAddInOptionsTestFixture.cs" />
<Compile Include="Console\CodeCompletionTests.cs" />
<Compile Include="Console\CommandLineHistoryTestFixture.cs" />
<Compile Include="Console\ConsoleTextEditorThreadSafetyTestFixture.cs" />
<Compile Include="Console\DisposedRubyConsoleTestFixture.cs" />
<Compile Include="Console\EmptyCommandLineHistoryTestFixture.cs" />
<Compile Include="Console\InsertConsoleCompletionDataTestFixture.cs" />
<Compile Include="Console\KeysPressedWhenCompletionWindowOpenTestFixture.cs" />
<Compile Include="Console\MockMemberProvider.cs" />
<Compile Include="Console\MockTextEditor.cs" />
<Compile Include="Console\OneItemCommandLineHistoryTestFixture.cs" />
<Compile Include="Console\RubyConsoleCodeCompletionTestFixture.cs" />
<Compile Include="Console\RubyConsoleCommandLineHistoryTestFixture.cs" />
@ -91,7 +92,7 @@ @@ -91,7 +92,7 @@
<Compile Include="Console\RubyConsoleUnreadLinesTestFixture.cs" />
<Compile Include="Console\RubyConsoleWriteTestFixture.cs" />
<Compile Include="Console\RubyOutputStreamTestFixture.cs" />
<Compile Include="Console\TextEditorTestFixture.cs" />
<Compile Include="Console\ConsoleTextEditorTestFixture.cs" />
<Compile Include="Console\TwoRubyConsoleLinesWaitingTestFixture.cs" />
<Compile Include="Converter\AddHandlerConversionTestFixture.cs" />
<Compile Include="Converter\ArrayCastConversionTestFixture.cs" />
@ -169,7 +170,6 @@ @@ -169,7 +170,6 @@
<Compile Include="Converter\VBStringConcatTestFixture.cs" />
<Compile Include="Converter\WhileLoopConversionTestFixture.cs" />
<Compile Include="Converter\XmlDocCommentConversionTestFixture.cs" />
<Compile Include="DebugRunRubyCommandTestFixture.cs" />
<Compile Include="Designer\AppendNullPropertyValueTestFixture.cs" />
<Compile Include="Designer\CallBeginInitOnLoadTestFixture.cs" />
<Compile Include="Designer\ConvertCustomClassUsingTypeConverterTestFixture.cs" />
@ -295,7 +295,10 @@ @@ -295,7 +295,10 @@
<Compile Include="Designer\TextBoxNotAddedToFormTestFixture.cs" />
<Compile Include="Designer\TextEditorIndentPassedToGeneratorTestFixture.cs" />
<Compile Include="Designer\UnknownTypeTestFixture.cs" />
<Compile Include="ProjectBindingTestFixture.cs" />
<Compile Include="Gui\DebugRunRubyCommandTestFixture.cs" />
<Compile Include="Gui\RubyIndentationTests.cs" />
<Compile Include="Gui\RubyOptionsPanelTestFixture.cs" />
<Compile Include="Gui\RunRubyCommandTestFixture.cs" />
<Compile Include="Parsing\ParseClassWithBaseClassTestFixture.cs" />
<Compile Include="Parsing\ParseMethodWithOptionalParametersTestFixture.cs" />
<Compile Include="Parsing\ParseMethodWithParametersTestFixture.cs" />
@ -309,14 +312,11 @@ @@ -309,14 +312,11 @@
<Compile Include="Parsing\ParseRequireFollowedByCommentTestFixture.cs" />
<Compile Include="Parsing\ParseRequireTestFixture.cs" />
<Compile Include="Parsing\ParseSingleClassTestFixture.cs" />
<Compile Include="RubyAddInOptionsTestFixture.cs" />
<Compile Include="CreateNewRubyProjectTestFixture.cs" />
<Compile Include="Parsing\RubyParserTestFixture.cs" />
<Compile Include="RubyBindingAddInFile.cs" />
<Compile Include="RubyIndentationTests.cs" />
<Compile Include="RubyLanguagePropertiesTests.cs" />
<Compile Include="RubyOptionsPanelTestFixture.cs" />
<Compile Include="RunRubyCommandTestFixture.cs" />
<Compile Include="RubyLanguage\CreateNewRubyProjectTestFixture.cs" />
<Compile Include="RubyLanguage\ProjectBindingTestFixture.cs" />
<Compile Include="RubyLanguage\RubyLanguageBindingTestFixture.cs" />
<Compile Include="RubyLanguage\RubyLanguagePropertiesTests.cs" />
<Compile Include="Utils\AddedComponent.cs" />
<Compile Include="Utils\AddInHelper.cs" />
<Compile Include="Utils\BarItemCollection.cs" />
@ -324,7 +324,6 @@ @@ -324,7 +324,6 @@
<Compile Include="Utils\CreatedComponent.cs" />
<Compile Include="Utils\CreatedInstance.cs" />
<Compile Include="Utils\CustomUserControl.cs" />
<Compile Include="Utils\DerivedAddInOptions.cs" />
<Compile Include="Utils\DerivedConvertProjectToRubyProjectCommand.cs" />
<Compile Include="Utils\DerivedFormDesignerViewContent.cs" />
<Compile Include="Utils\DerivedRubyAddInOptions.cs" />
@ -336,6 +335,8 @@ @@ -336,6 +335,8 @@
<Compile Include="Utils\DoublePropertyUserControl.cs" />
<Compile Include="Utils\FooItemCollection.cs" />
<Compile Include="Utils\MockComponentCreator.cs" />
<Compile Include="Utils\MockConsoleTextEditorKeyEventArgs.cs" />
<Compile Include="Utils\MockControlDispatcher.cs" />
<Compile Include="Utils\MockDebugger.cs" />
<Compile Include="Utils\MockDesignerGenerator.cs" />
<Compile Include="Utils\MockDesignerLoaderHost.cs" />
@ -343,8 +344,10 @@ @@ -343,8 +344,10 @@
<Compile Include="Utils\MockEventBindingService.cs" />
<Compile Include="Utils\MockEventDescriptor.cs" />
<Compile Include="Utils\MockExtenderProviderService.cs" />
<Compile Include="Utils\MockKeyboardDevice.cs" />
<Compile Include="Utils\MockMethod.cs" />
<Compile Include="Utils\MockOpenedFile.cs" />
<Compile Include="Utils\MockPresentationSource.cs" />
<Compile Include="Utils\MockProject.cs" />
<Compile Include="Utils\MockProjectContent.cs" />
<Compile Include="Utils\MockPropertyDescriptor.cs" />
@ -352,7 +355,9 @@ @@ -352,7 +355,9 @@
<Compile Include="Utils\MockResourceService.cs" />
<Compile Include="Utils\MockResourceWriter.cs" />
<Compile Include="Utils\MockSite.cs" />
<Compile Include="Utils\MockTextEditorProperties.cs" />
<Compile Include="Utils\MockConsoleTextEditor.cs" />
<Compile Include="Utils\MockTextEditor.cs" />
<Compile Include="Utils\MockTextEditorOptions.cs" />
<Compile Include="Utils\MockTextEditorViewContent.cs" />
<Compile Include="Utils\MockTypeResolutionService.cs" />
<Compile Include="Utils\MockViewContent.cs" />
@ -360,8 +365,12 @@ @@ -360,8 +365,12 @@
<Compile Include="Utils\MockWorkbenchWindow.cs" />
<Compile Include="Utils\MSBuildEngineHelper.cs" />
<Compile Include="Utils\NullPropertyUserControl.cs" />
<Compile Include="Utils\RubyBindingAddInFile.cs" />
<Compile Include="Utils\RubyParserHelper.cs" />
<Compile Include="Utils\SupportInitCustomControl.cs" />
<Compile Include="Utils\Tests\MockControlDispatcherTestFixture.cs" />
<Compile Include="Utils\Tests\MockConsoleTextEditorTestFixture.cs" />
<Compile Include="Utils\Tests\MockEditableViewContentTestFixture.cs" />
<EmbeddedResource Include="..\Project\RubyBinding.addin">
<Link>RubyBinding.addin</Link>
</EmbeddedResource>
@ -370,14 +379,11 @@ @@ -370,14 +379,11 @@
<EmbeddedResource Include="Strings.resx" />
</ItemGroup>
<ItemGroup>
<Folder Include="Utils\Tests" />
<ProjectReference Include="..\..\..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj">
<Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project>
<Name>ICSharpCode.AvalonEdit</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj">
<Project>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</Project>
<Name>ICSharpCode.TextEditor</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name>
@ -413,6 +419,9 @@ @@ -413,6 +419,9 @@
<Folder Include="Converter" />
<Folder Include="Console" />
<Folder Include="Designer" />
<Folder Include="Configuration" />
<Folder Include="Gui" />
<Folder Include="RubyLanguage" />
<Folder Include="Utils" />
<Folder Include="Parsing" />
</ItemGroup>

2
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/CreateNewRubyProjectTestFixture.cs → src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyLanguage/CreateNewRubyProjectTestFixture.cs

@ -16,7 +16,7 @@ using ICSharpCode.SharpDevelop.Project; @@ -16,7 +16,7 @@ using ICSharpCode.SharpDevelop.Project;
using Microsoft.Build.Construction;
using NUnit.Framework;
namespace RubyBinding.Tests
namespace RubyBinding.Tests.RubyLanguage
{
/// <summary>
/// Tests the initial properties set in a newly created RubyProject.

2
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/ProjectBindingTestFixture.cs → src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyLanguage/ProjectBindingTestFixture.cs

@ -11,7 +11,7 @@ using ICSharpCode.SharpDevelop.Project; @@ -11,7 +11,7 @@ using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Internal.Templates;
using NUnit.Framework;
namespace RubyBinding.Tests
namespace RubyBinding.Tests.RubyLanguage
{
/// <summary>
/// Tests the RubyProjectBinding class.

44
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyLanguage/RubyLanguageBindingTestFixture.cs

@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop;
using NUnit.Framework;
namespace RubyBinding.Tests.RubyLanguage
{
[TestFixture]
public class RubyLanguageBindingTestFixture
{
RubyLanguageBinding languageBinding;
[SetUp]
public void Init()
{
languageBinding = new RubyLanguageBinding();
}
[Test]
public void FormattingStrategyIsRubyFormattingStrategy()
{
Assert.IsInstanceOf(typeof(RubyFormattingStrategy), languageBinding.FormattingStrategy);
}
[Test]
public void ImplementsILanguageBinding()
{
Assert.IsNotNull(languageBinding as ILanguageBinding);
}
[Test]
public void LanguagePropertiesIsRubyLanguageProperties()
{
Assert.IsInstanceOf(typeof(RubyLanguageProperties), languageBinding.Properties);
}
}
}

2
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyLanguagePropertiesTests.cs → src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyLanguage/RubyLanguagePropertiesTests.cs

@ -10,7 +10,7 @@ using ICSharpCode.RubyBinding; @@ -10,7 +10,7 @@ using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
namespace RubyBinding.Tests
namespace RubyBinding.Tests.RubyLanguage
{
[TestFixture]
public class RubyLanguagePropertiesTests

52
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/DerivedAddInOptions.cs

@ -1,52 +0,0 @@ @@ -1,52 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.Core;
using ICSharpCode.RubyBinding;
namespace RubyBinding.Tests.Utils
{
/// <summary>
/// Overrides the AddInOptions GetAddInPath method to return
/// some dummy data used for testing.
/// </summary>
public class DerivedAddInOptions : AddInOptions
{
string addInPath = String.Empty;
string addInPathRequested = String.Empty;
public DerivedAddInOptions(Properties properties) : base(properties)
{
}
/// <summary>
/// Gets the addin path string passed to the GetAddInPath method.
/// </summary>
public string AddInPathRequested {
get { return addInPathRequested; }
}
/// <summary>
/// Gets or sets the addin path that should be returned from the
/// GetAddInPath method.
/// </summary>
public string AddInPath {
get { return addInPath; }
set { addInPath = value; }
}
/// <summary>
/// Returns our dummy AddInPath.
/// </summary>
protected override string GetAddInPath(string addIn)
{
addInPathRequested = addIn;
return addInPath;
}
}
}

20
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/DerivedConvertProjectToRubyProjectCommand.cs

@ -8,11 +8,11 @@ @@ -8,11 +8,11 @@
using System;
using System.Collections.Generic;
using System.Text;
using ICSharpCode.RubyBinding;
using ICSharpCode.Core;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.TextEditor.Document;
namespace RubyBinding.Tests.Utils
{
@ -39,11 +39,7 @@ namespace RubyBinding.Tests.Utils @@ -39,11 +39,7 @@ namespace RubyBinding.Tests.Utils
IProjectContent projectContent;
ParseInformation parseInfo;
List<string> filesPassedToGetParseInfo = new List<string>();
public DerivedConvertProjectToRubyProjectCommand(ITextEditorProperties textEditorProperties)
: base(textEditorProperties)
{
}
Encoding fileServiceDefaultEncoding = Encoding.ASCII;
public List<SourceAndTargetFile> SourceAndTargetFilesPassedToBaseClass {
get { return sourceAndTargetFilesPassedToBaseClass; }
@ -69,6 +65,11 @@ namespace RubyBinding.Tests.Utils @@ -69,6 +65,11 @@ namespace RubyBinding.Tests.Utils
set { parseInfo = value; }
}
public Encoding FileServiceDefaultEncoding {
get { return fileServiceDefaultEncoding; }
set { fileServiceDefaultEncoding = value; }
}
public List<string> FilesPassedToGetParseInfo {
get { return filesPassedToGetParseInfo; }
}
@ -123,5 +124,10 @@ namespace RubyBinding.Tests.Utils @@ -123,5 +124,10 @@ namespace RubyBinding.Tests.Utils
{
return projectContent;
}
protected override Encoding GetDefaultFileEncoding()
{
return fileServiceDefaultEncoding;
}
}
}

7
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/DerivedRubyConsoleHost.cs

@ -8,23 +8,22 @@ @@ -8,23 +8,22 @@
using System;
using System.IO;
using ICSharpCode.TextEditor;
using ICSharpCode.RubyBinding;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Hosting.Shell;
namespace RubyBinding.Tests.Console
{
{
public class DerivedRubyConsoleHost : RubyConsoleHost
{
RubyOutputStream outputStream;
public DerivedRubyConsoleHost(ITextEditor textEditor) : base(textEditor)
public DerivedRubyConsoleHost(IConsoleTextEditor textEditor) : base(textEditor)
{
}
public Type GetProvider()
public Type GetProvider()
{
return base.Provider;
}

9
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/DerivedRubyDesignerGenerator.cs

@ -16,8 +16,7 @@ using ICSharpCode.FormsDesigner; @@ -16,8 +16,7 @@ using ICSharpCode.FormsDesigner;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.SharpDevelop.Editor;
namespace RubyBinding.Tests.Utils
{
@ -31,12 +30,12 @@ namespace RubyBinding.Tests.Utils @@ -31,12 +30,12 @@ namespace RubyBinding.Tests.Utils
string textContentPassedToParseFile;
ParseInformation parseInfoToReturnFromParseFile;
public DerivedRubyDesignerGenerator() : this(new MockTextEditorProperties())
public DerivedRubyDesignerGenerator() : this(new MockTextEditorOptions())
{
}
public DerivedRubyDesignerGenerator(ITextEditorProperties textEditorProperties)
: base(textEditorProperties)
public DerivedRubyDesignerGenerator(ITextEditorOptions textEditorOptions)
: base(textEditorOptions)
{
}

1
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/DerivedRubyDesignerLoader.cs

@ -14,7 +14,6 @@ using System.ComponentModel.Design.Serialization; @@ -14,7 +14,6 @@ using System.ComponentModel.Design.Serialization;
using System.IO;
using ICSharpCode.RubyBinding;
using ICSharpCode.FormsDesigner;
using ICSharpCode.TextEditor.Document;
namespace RubyBinding.Tests.Utils
{

120
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Console/MockTextEditor.cs → src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockConsoleTextEditor.cs

@ -7,20 +7,16 @@ @@ -7,20 +7,16 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Windows.Input;
using System.Text;
using ICSharpCode.RubyBinding;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.TextEditor.Document;
namespace RubyBinding.Tests.Console
namespace RubyBinding.Tests.Utils
{
public class MockTextEditor : ITextEditor
public class MockConsoleTextEditor : IConsoleTextEditor
{
IndentStyle indentStyle = IndentStyle.Auto;
StringBuilder previousLines = new StringBuilder();
StringBuilder lineBuilder = new StringBuilder();
bool writeCalled;
@ -29,23 +25,16 @@ namespace RubyBinding.Tests.Console @@ -29,23 +25,16 @@ namespace RubyBinding.Tests.Console
int selectionLength;
int line;
int totalLines = 1;
List<Color> textColors = new List<Color>();
bool showCompletionWindowCalled;
bool completionWindowDisplayed;
bool makeReadOnlyCalled;
ICompletionDataProvider completionProvider;
RubyConsoleCompletionDataProvider completionProvider;
public MockTextEditor()
public MockConsoleTextEditor()
{
}
public event ICSharpCode.TextEditor.KeyEventHandler KeyPress;
public event DialogKeyProcessor DialogKeyPress;
public IndentStyle IndentStyle {
get { return indentStyle; }
set { indentStyle = value; }
}
public event ConsoleTextEditorKeyEventHandler PreviewKeyDown;
public void Write(string text)
{
@ -54,12 +43,6 @@ namespace RubyBinding.Tests.Console @@ -54,12 +43,6 @@ namespace RubyBinding.Tests.Console
column += text.Length;
}
public void Write(string text, Color backgroundColor)
{
textColors.Add(backgroundColor);
Write(text);
}
public bool IsWriteCalled {
get { return writeCalled; }
set { writeCalled = value; }
@ -76,7 +59,7 @@ namespace RubyBinding.Tests.Console @@ -76,7 +59,7 @@ namespace RubyBinding.Tests.Console
/// <summary>
/// Returns the code completion data provider passed to the ShowCompletionWindow method.
/// </summary>
public ICompletionDataProvider CompletionDataProvider {
public RubyConsoleCompletionDataProvider CompletionDataProvider {
get { return completionProvider; }
}
@ -99,76 +82,75 @@ namespace RubyBinding.Tests.Console @@ -99,76 +82,75 @@ namespace RubyBinding.Tests.Console
}
}
public bool RaiseKeyPressEvent(char ch)
public bool RaisePreviewKeyDownEvent(Key key)
{
bool keyHandled = KeyPress(ch);
if (!keyHandled) {
MockConsoleTextEditorKeyEventArgs e = new MockConsoleTextEditorKeyEventArgs(key);
OnPreviewKeyDown(e);
if (!e.Handled) {
KeyConverter converter = new KeyConverter();
string text = converter.ConvertToString(key);
if (IsCursorAtEnd) {
lineBuilder.Append(ch);
lineBuilder.Append(text);
} else {
lineBuilder.Insert(column, ch);
lineBuilder.Insert(column, text);
}
column++;
selectionStart = column;
}
return keyHandled;
return e.Handled;
}
/// <summary>
/// Calls RaiseKeyPressEvent for each character in the string.
/// </summary>
public void RaiseKeyPressEvents(string text)
void OnPreviewKeyDown(MockConsoleTextEditorKeyEventArgs e)
{
foreach (char ch in text) {
RaiseKeyPressEvent(ch);
if (PreviewKeyDown != null) {
PreviewKeyDown(this, e);
}
}
public bool RaiseDialogKeyPressEvent(Keys keyData)
public bool RaisePreviewKeyDownEventForDialogKey(Key key)
{
bool keyHandled = DialogKeyPress(keyData);
if (!keyHandled) {
switch (keyData) {
case Keys.Enter: {
if (!KeyPress('\n')) {
if (IsCursorAtEnd) {
lineBuilder.Append(Environment.NewLine);
previousLines.Append(lineBuilder.ToString());
lineBuilder = new StringBuilder();
column = 0;
selectionStart = column;
} else {
int length = lineBuilder.Length;
string currentLine = lineBuilder.ToString();
previousLines.Append(currentLine.Substring(0, column) + Environment.NewLine);
lineBuilder = new StringBuilder();
lineBuilder.Append(currentLine.Substring(column));
column = length - column;
selectionStart = column;
}
totalLines++;
line++;
MockConsoleTextEditorKeyEventArgs e = new MockConsoleTextEditorKeyEventArgs(key);
OnPreviewKeyDown(e);
if (!e.Handled) {
switch (key) {
case Key.Enter: {
if (IsCursorAtEnd) {
lineBuilder.Append(Environment.NewLine);
previousLines.Append(lineBuilder.ToString());
lineBuilder = new StringBuilder();
column = 0;
selectionStart = column;
} else {
int length = lineBuilder.Length;
string currentLine = lineBuilder.ToString();
previousLines.Append(currentLine.Substring(0, column) + Environment.NewLine);
lineBuilder = new StringBuilder();
lineBuilder.Append(currentLine.Substring(column));
column = length - column;
selectionStart = column;
}
totalLines++;
line++;
}
break;
case Keys.Back: {
case Key.Back: {
OnBackspaceKeyPressed();
}
break;
case Keys.Left: {
case Key.Left: {
column--;
selectionStart = column;
}
break;
case Keys.Right: {
case Key.Right: {
column++;
selectionStart = column;
}
break;
}
}
return keyHandled;
}
return e.Handled;
}
public int Column {
get { return column; }
@ -208,7 +190,7 @@ namespace RubyBinding.Tests.Console @@ -208,7 +190,7 @@ namespace RubyBinding.Tests.Console
lineBuilder.Insert(index, text);
}
public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider)
public void ShowCompletionWindow(RubyConsoleCompletionDataProvider completionDataProvider)
{
showCompletionWindowCalled = true;
completionWindowDisplayed = true;
@ -223,10 +205,6 @@ namespace RubyBinding.Tests.Console @@ -223,10 +205,6 @@ namespace RubyBinding.Tests.Console
public void MakeCurrentContentReadOnly()
{
makeReadOnlyCalled = true;
}
public List<Color> WrittenTextColors {
get { return textColors; }
}
bool IsCursorAtEnd {

28
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockConsoleTextEditorKeyEventArgs.cs

@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Input;
using ICSharpCode.RubyBinding;
namespace RubyBinding.Tests.Utils
{
public class MockConsoleTextEditorKeyEventArgs : ConsoleTextEditorKeyEventArgs
{
bool handled;
public MockConsoleTextEditorKeyEventArgs(Key key)
: base(key)
{
}
public override bool Handled {
get { return handled; }
set { handled = value; }
}
}
}

50
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockControlDispatcher.cs

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.RubyBinding;
namespace RubyBinding.Tests.Utils.Tests
{
public class MockControlDispatcher : IControlDispatcher
{
Delegate methodInvoked;
object[] methodInvokedArgs;
bool checkAccessReturnValue;
public MockControlDispatcher()
{
}
public bool CheckAccess()
{
return checkAccessReturnValue;
}
public bool CheckAccessReturnValue {
get { return checkAccessReturnValue; }
set { checkAccessReturnValue = value; }
}
public object Invoke(Delegate method, params object[] args)
{
methodInvoked = method;
methodInvokedArgs = args;
return null;
}
public Delegate MethodInvoked {
get { return methodInvoked; }
set { methodInvoked = null; }
}
public object[] MethodInvokedArgs {
get { return methodInvokedArgs; }
set { methodInvokedArgs = value; }
}
}
}

4
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockDesignerLoaderHost.cs

@ -86,7 +86,6 @@ namespace RubyBinding.Tests.Utils @@ -86,7 +86,6 @@ namespace RubyBinding.Tests.Utils
public void EndLoad(string baseClassName, bool successful, ICollection errorCollection)
{
System.Console.WriteLine("DesignerLoaderHost.EndLoad");
}
public void Reload()
@ -133,13 +132,11 @@ namespace RubyBinding.Tests.Utils @@ -133,13 +132,11 @@ namespace RubyBinding.Tests.Utils
public Type GetType(string typeName)
{
System.Console.WriteLine("DesignerLoaderHost.GetType: " + typeName);
return typeResolutionService.GetType(typeName);
}
public void AddService(Type serviceType, object serviceInstance)
{
System.Console.WriteLine("DesignerLoaderHost.AddService: " + serviceType.Name + " IsNull: " + (serviceInstance == null));
serviceContainer.AddService(serviceType, serviceInstance);
}
@ -165,7 +162,6 @@ namespace RubyBinding.Tests.Utils @@ -165,7 +162,6 @@ namespace RubyBinding.Tests.Utils
public object GetService(Type serviceType)
{
System.Console.WriteLine("DesignerLoaderHost.GetService: " + serviceType.Name);
return serviceContainer.GetService(serviceType);
}

19
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockEditableViewContent.cs

@ -6,7 +6,9 @@ @@ -6,7 +6,9 @@
// </file>
using System;
using ICSharpCode.AvalonEdit;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
namespace RubyBinding.Tests.Utils
@ -14,8 +16,9 @@ namespace RubyBinding.Tests.Utils @@ -14,8 +16,9 @@ namespace RubyBinding.Tests.Utils
/// <summary>
/// Mock implementation of the IEditable and IViewContent.
/// </summary>
public class MockEditableViewContent : MockViewContent, IEditable
public class MockEditableViewContent : MockViewContent, IEditable, ITextEditorProvider
{
MockTextEditor textEditor = new MockTextEditor();
string text = String.Empty;
public MockEditableViewContent()
@ -31,5 +34,19 @@ namespace RubyBinding.Tests.Utils @@ -31,5 +34,19 @@ namespace RubyBinding.Tests.Utils
{
return new StringTextBuffer(text);
}
public ITextEditorOptions TextEditorOptions {
get { return textEditor.Options; }
set { textEditor.Options = value; }
}
public ITextEditor TextEditor {
get { return textEditor; }
}
public IDocument GetDocumentForFile(OpenedFile file)
{
throw new NotImplementedException();
}
}
}

25
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockKeyboardDevice.cs

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Input;
namespace RubyBinding.Tests.Utils
{
public class MockKeyboardDevice : KeyboardDevice
{
public MockKeyboardDevice()
: base(InputManager.Current)
{
}
protected override KeyStates GetKeyStatesFromSystem(Key key)
{
throw new NotImplementedException();
}
}
}

41
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockPresentationSource.cs

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
namespace RubyBinding.Tests.Utils
{
public class MockPresentationSource : PresentationSource
{
public MockPresentationSource()
{
}
public override Visual RootVisual {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public override bool IsDisposed {
get {
throw new NotImplementedException();
}
}
protected override CompositionTarget GetCompositionTargetCore()
{
throw new NotImplementedException();
}
}
}

2
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockProject.cs

@ -292,7 +292,7 @@ namespace RubyBinding.Tests.Utils @@ -292,7 +292,7 @@ namespace RubyBinding.Tests.Utils
throw new NotImplementedException();
}
public void StartBuild(ThreadSafeServiceContainer serviceContainer, ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink)
public void StartBuild(ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink)
{
throw new NotImplementedException();
}

10
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockProjectContent.cs

@ -360,5 +360,15 @@ namespace RubyBinding.Tests.Utils @@ -360,5 +360,15 @@ namespace RubyBinding.Tests.Utils
throw new NotImplementedException();
}
}
public List<ICompletionEntry> GetAllContents()
{
throw new NotImplementedException();
}
public void AddAllContents(List<ICompletionEntry> list, LanguageProperties language, bool lookInReferences)
{
throw new NotImplementedException();
}
}
}

138
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockTextEditor.cs

@ -0,0 +1,138 @@ @@ -0,0 +1,138 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Input;
using ICSharpCode.SharpDevelop.Editor;
namespace RubyBinding.Tests.Utils
{
public class MockTextEditor : ITextEditor
{
ITextEditorOptions options;
public MockTextEditor()
{
}
public event EventHandler SelectionChanged;
protected virtual void OnSelectionChanged(EventArgs e)
{
if (SelectionChanged != null) {
SelectionChanged(this, e);
}
}
public event KeyEventHandler KeyPress;
protected virtual void OnKeyPress(KeyEventArgs e)
{
if (KeyPress != null) {
KeyPress(this, e);
}
}
public ITextEditor PrimaryView {
get {
throw new NotImplementedException();
}
}
public IDocument Document {
get {
throw new NotImplementedException();
}
}
public ITextEditorCaret Caret {
get {
throw new NotImplementedException();
}
}
public ITextEditorOptions Options {
get { return options; }
set { options = value; }
}
public ICSharpCode.SharpDevelop.ILanguageBinding Language {
get {
throw new NotImplementedException();
}
}
public int SelectionStart {
get {
throw new NotImplementedException();
}
}
public int SelectionLength {
get {
throw new NotImplementedException();
}
}
public string SelectedText {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public ICSharpCode.Core.FileName FileName {
get {
throw new NotImplementedException();
}
}
public ICSharpCode.SharpDevelop.Editor.CodeCompletion.ICompletionListWindow ActiveCompletionWindow {
get {
throw new NotImplementedException();
}
}
public ICSharpCode.SharpDevelop.Editor.CodeCompletion.IInsightWindow ActiveInsightWindow {
get {
throw new NotImplementedException();
}
}
public void Select(int selectionStart, int selectionLength)
{
throw new NotImplementedException();
}
public void JumpTo(int line, int column)
{
throw new NotImplementedException();
}
public ICSharpCode.SharpDevelop.Editor.CodeCompletion.ICompletionListWindow ShowCompletionWindow(ICSharpCode.SharpDevelop.Editor.CodeCompletion.ICompletionItemList data)
{
throw new NotImplementedException();
}
public ICSharpCode.SharpDevelop.Editor.CodeCompletion.IInsightWindow ShowInsightWindow(System.Collections.Generic.IEnumerable<ICSharpCode.SharpDevelop.Editor.CodeCompletion.IInsightItem> items)
{
throw new NotImplementedException();
}
public System.Collections.Generic.IEnumerable<ICSharpCode.SharpDevelop.Editor.CodeCompletion.ICompletionItem> GetSnippets()
{
throw new NotImplementedException();
}
public object GetService(Type serviceType)
{
return null;
}
}
}

38
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockTextEditorOptions.cs

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.AvalonEdit;
using ICSharpCode.SharpDevelop.Editor;
namespace RubyBinding.Tests.Utils
{
public class MockTextEditorOptions : TextEditorOptions, ITextEditorOptions
{
public MockTextEditorOptions()
{
}
public bool AutoInsertBlockEnd {
get {
throw new NotImplementedException();
}
}
public int VerticalRulerColumn {
get {
throw new NotImplementedException();
}
}
public bool UnderlineErrors {
get {
throw new NotImplementedException();
}
}
}
}

85
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockTextEditorProperties.cs

@ -1,85 +0,0 @@ @@ -1,85 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Drawing;
using System.Drawing.Text;
using System.Text;
using ICSharpCode.TextEditor.Document;
namespace RubyBinding.Tests.Utils
{
public class MockTextEditorProperties : ITextEditorProperties
{
public MockTextEditorProperties()
{
FontContainer = new FontContainer(SystemFonts.MenuFont);
}
public bool CaretLine { get; set; }
public bool AutoInsertCurlyBracket { get; set; }
public bool HideMouseCursor { get; set; }
public bool IsIconBarVisible { get; set; }
public bool AllowCaretBeyondEOL { get; set; }
public bool ShowMatchingBracket { get; set; }
public bool CutCopyWholeLine { get; set; }
public TextRenderingHint TextRenderingHint { get; set; }
public bool MouseWheelScrollDown { get; set; }
public bool MouseWheelTextZoom { get; set; }
public string LineTerminator { get; set; }
public LineViewerStyle LineViewerStyle { get; set; }
public bool ShowInvalidLines { get; set; }
public int VerticalRulerRow { get; set; }
public bool ShowSpaces { get; set; }
public bool ShowTabs { get; set; }
public bool ShowEOLMarker { get; set; }
public bool ConvertTabsToSpaces { get; set; }
public bool ShowHorizontalRuler { get; set; }
public bool ShowVerticalRuler { get; set; }
public Encoding Encoding { get; set; }
public bool EnableFolding{ get; set; }
public bool ShowLineNumbers { get; set; }
public int TabIndent { get; set; }
public int IndentationSize { get; set; }
public IndentStyle IndentStyle{ get; set; }
public DocumentSelectionMode DocumentSelectionMode { get; set; }
public Font Font { get; set; }
public FontContainer FontContainer { get; set; }
public BracketMatchingStyle BracketMatchingStyle { get; set; }
public bool SupportReadOnlySegments { get; set; }
}
}

13
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockTextEditorViewContent.cs

@ -5,12 +5,13 @@ @@ -5,12 +5,13 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using ICSharpCode.AvalonEdit;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit ;
using ICSharpCode.SharpDevelop.Dom.Refactoring;
using ICSharpCode.TextEditor;
namespace RubyBinding.Tests.Utils
{
@ -24,16 +25,14 @@ namespace RubyBinding.Tests.Utils @@ -24,16 +25,14 @@ namespace RubyBinding.Tests.Utils
public MockTextEditorViewContent()
{
textEditor = new ICSharpCode.SharpDevelop.Editor.AvalonEdit.AvalonEditTextEditorAdapter(
new ICSharpCode.AvalonEdit.TextEditor()
);
textEditor = new AvalonEditTextEditorAdapter(new TextEditor());
}
public ICSharpCode.SharpDevelop.Editor.ITextEditor TextEditor {
public ITextEditor TextEditor {
get { return textEditor; }
}
public ICSharpCode.SharpDevelop.Editor.IDocument GetDocumentForFile(OpenedFile file)
public IDocument GetDocumentForFile(OpenedFile file)
{
throw new NotImplementedException();
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save