Browse Source

Added support for running tests with Ruby's unit testing framework.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6095 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Matt Ward 15 years ago
parent
commit
dea2074160
  1. 2
      src/AddIns/Analysis/UnitTesting/Src/ITestResultsMonitor.cs
  2. 9
      src/AddIns/Analysis/UnitTesting/Src/TestResultsMonitor.cs
  3. 6
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestResultsMonitor.cs
  4. 8
      src/AddIns/Analysis/UnitTesting/UnitTesting.sln
  5. 18
      src/AddIns/BackendBindings/Ruby/RubyBinding.sln
  6. 22
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Resources/RubyOptionsPanel.xfrm
  7. 139
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/RubyBinding.addin
  8. 31
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/RubyBinding.csproj
  9. 65
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/CreateTextWriterInfo.cs
  10. 20
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/IRubyFileService.cs
  11. 10
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyAddInOptions.cs
  12. 120
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsoleApplication.cs
  13. 31
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyFileService.cs
  14. 4
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyOptionsPanel.cs
  15. 71
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestDebugger.cs
  16. 64
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestFramework.cs
  17. 69
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestResult.cs
  18. 70
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunner.cs
  19. 131
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunnerApplication.cs
  20. 83
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunnerResponseFile.cs
  21. 21
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RunRubyCommand.cs
  22. 32
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdselectedtestsfile.rb
  23. 27
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtest.rb
  24. 64
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtestresult.rb
  25. 31
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtestresultwriter.rb
  26. 145
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtestrunner.rb
  27. 37
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Configuration/RubyAddInOptionsTestFixture.cs
  28. 2
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/FormsDesignerDisplayBindingTestFixture.cs
  29. 3
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs
  30. 3
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/RubyDesignerGeneratorTestFixture.cs
  31. 6
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/DebugRunRubyCommandTestFixture.cs
  32. 20
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RubyOptionsPanelTestFixture.cs
  33. 11
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RunRubyCommandTestFixture.cs
  34. 27
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj
  35. 52
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/CreateRubyTestRunnerTestFixture.cs
  36. 41
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/CreateTextWriterFromCreateTextWriterInfoTestFixture.cs
  37. 57
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/CreateTextWriterInfoEqualsTestFixture.cs
  38. 95
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyConsoleApplicationTestFixture.cs
  39. 149
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestDebuggerRunsSelectedTestMethodTestFixture.cs
  40. 75
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestFrameworkIsTestClassTests.cs
  41. 49
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestFrameworkIsTestMethodTests.cs
  42. 66
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestFrameworkIsTestProjectTests.cs
  43. 94
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestResultFailureTestFixture.cs
  44. 129
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerApplicationTests.cs
  45. 115
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerResponseFileTestFixture.cs
  46. 200
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerRunsSelectedTestMethodTestFixture.cs
  47. 60
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/AddInPathHelper.cs
  48. 297
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockMethod.cs
  49. 58
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockRubyFileService.cs
  50. 33
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/RubySelectedTestsHelper.cs
  51. 50
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/Tests/AddInPathHelperTestFixture.cs
  52. 65
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/Tests/MockRubyFileServiceTestFixture.cs

2
src/AddIns/Analysis/UnitTesting/Src/ITestResultsMonitor.cs

@ -18,5 +18,7 @@ namespace ICSharpCode.UnitTesting @@ -18,5 +18,7 @@ namespace ICSharpCode.UnitTesting
void Stop();
void Start();
void Read();
long InitialFilePosition { get; set; }
}
}

9
src/AddIns/Analysis/UnitTesting/Src/TestResultsMonitor.cs

@ -21,7 +21,9 @@ namespace ICSharpCode.UnitTesting @@ -21,7 +21,9 @@ namespace ICSharpCode.UnitTesting
TestResultsReader testResultsReader;
FileSystemWatcher fileSystemWatcher;
long initialFilePosition = 3;
long filePosition;
const int BytesBufferLength = 1024;
byte[] bytes = new byte[BytesBufferLength];
@ -42,6 +44,11 @@ namespace ICSharpCode.UnitTesting @@ -42,6 +44,11 @@ namespace ICSharpCode.UnitTesting
ResetFilePosition();
}
public long InitialFilePosition {
get { return initialFilePosition; }
set { initialFilePosition = value; }
}
/// <summary>
/// Gets or sets the test results filename.
/// </summary>
@ -169,7 +176,7 @@ namespace ICSharpCode.UnitTesting @@ -169,7 +176,7 @@ namespace ICSharpCode.UnitTesting
void ResetFilePosition()
{
filePosition = 3; // Use 3 to ignores UTF-8 preamble.
filePosition = initialFilePosition;
}
}
}

6
src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestResultsMonitor.cs

@ -17,6 +17,7 @@ namespace UnitTesting.Tests.Utils @@ -17,6 +17,7 @@ namespace UnitTesting.Tests.Utils
bool disposeMethodCalled;
bool readMethodCalled;
string fileName;
long filePosition;
public MockTestResultsMonitor()
{
@ -24,6 +25,11 @@ namespace UnitTesting.Tests.Utils @@ -24,6 +25,11 @@ namespace UnitTesting.Tests.Utils
public event TestFinishedEventHandler TestFinished;
public long InitialFilePosition {
get { return filePosition; }
set { filePosition = value; }
}
public bool IsStartMethodCalled {
get { return startMethodCalled; }
}

8
src/AddIns/Analysis/UnitTesting/UnitTesting.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.5840
# SharpDevelop 4.0.0.5967
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting.Tests", "Test\UnitTesting.Tests.csproj", "{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}"
@ -12,8 +12,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", @@ -12,8 +12,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Dom", "..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj", "{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "..\..\..\Libraries\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}"
@ -44,10 +42,6 @@ Global @@ -44,10 +42,6 @@ Global
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.Build.0 = Release|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.Build.0 = Release|Any CPU
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU

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

@ -16,12 +16,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Do @@ -16,12 +16,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Do
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "..\..\..\Libraries\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "..\..\DisplayBindings\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj", "{0162E499-42D0-409B-AA25-EED21F75336B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.AvalonEdit", "..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj", "{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "..\..\Analysis\UnitTesting\UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting.Tests", "..\..\Analysis\UnitTesting\Test\UnitTesting.Tests.csproj", "{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -58,10 +60,6 @@ Global @@ -58,10 +60,6 @@ Global
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.Build.0 = Release|Any CPU
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.Build.0 = Release|Any CPU
@ -70,5 +68,13 @@ Global @@ -70,5 +68,13 @@ Global
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.Build.0 = Release|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F261725-6318-4434-A1B1-6C70CE4CD324}.Release|Any CPU.Build.0 = Release|Any CPU
{1F261725-6318-4434-A1B1-6C70CE4CD324}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Release|Any CPU.Build.0 = Release|Any CPU
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal

22
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Resources/RubyOptionsPanel.xfrm

@ -7,25 +7,39 @@ @@ -7,25 +7,39 @@
<Name value="configurationGroupBox" />
<Location value="3, 12" />
<Text value="Ruby Configuration" />
<Anchor value="Top, Left, Right" />
<Size value="320, 229" />
<Anchor value="Top, Left, Right" />
<TabIndex value="0" />
<Controls>
<System.Windows.Forms.TextBox>
<Name value="rubyLibraryPathTextBox" />
<TabIndex value="4" />
<Location value="95, 51" />
<Anchor value="Top, Left, Right" />
<Size value="217, 20" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Label>
<Name value="rubyLibraryPathLabel" />
<Location value="6, 54" />
<Text value="Path:" />
<Size value="83, 23" />
<TabIndex value="3" />
</System.Windows.Forms.Label>
<System.Windows.Forms.Button>
<Name value="browseButton" />
<Location value="288, 25" />
<Text value="..." />
<Anchor value="Top, Right" />
<UseVisualStyleBackColor value="True" />
<Size value="24, 23" />
<Anchor value="Top, Right" />
<TabIndex value="2" />
</System.Windows.Forms.Button>
<System.Windows.Forms.TextBox>
<Name value="rubyFileNameTextBox" />
<TabIndex value="1" />
<Size value="187, 20" />
<Location value="95, 25" />
<Anchor value="Top, Left, Right" />
<Size value="187, 20" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Label>
<Name value="commandLabel" />
@ -38,4 +52,4 @@ @@ -38,4 +52,4 @@
</System.Windows.Forms.GroupBox>
</Controls>
</System.Windows.Forms.UserControl>
</Components>
</Components>

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

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
<AddIn name = "Ruby Binding"
author = "Matt Ward"
copyright = "prj:///doc/copyright.txt"
description = "IronRuby addin"
addInManagerHidden = "preinstalled">
author = "Matt Ward"
copyright = "prj:///doc/copyright.txt"
description = "IronRuby addin"
addInManagerHidden = "preinstalled">
<Manifest>
<Identity name="ICSharpCode.RubyBinding"/>
@ -12,33 +12,34 @@ @@ -12,33 +12,34 @@
<Runtime>
<Import assembly=":ICSharpCode.SharpDevelop"/>
<Import assembly="$ICSharpCode.FormsDesigner/FormsDesigner.dll"/>
<Import assembly="$ICSharpCode.UnitTesting/UnitTesting.dll"/>
<Import assembly="IronRuby.Libraries.dll"/>
<Import assembly="RubyBinding.dll"/>
</Runtime>
<Path name="/SharpDevelop/ViewContent/AvalonEdit/SyntaxModes">
<SyntaxMode id="Ruby.SyntaxMode"
extensions=".rb"
name="Ruby"
resource="ICSharpCode.RubyBinding.Resources.Ruby.xshd"/>
</Path>
extensions=".rb"
name="Ruby"
resource="ICSharpCode.RubyBinding.Resources.Ruby.xshd"/>
</Path>
<!-- Add the "Ruby" entry to the Open File Dialog -->
<Path name="/SharpDevelop/Workbench/FileFilter">
<FileFilter id="Ruby"
insertbefore="Resources"
insertafter="Icons"
name="Ruby Files (*.rb)"
extensions="*.rb"/>
insertbefore="Resources"
insertafter="Icons"
name="Ruby Files (*.rb)"
extensions="*.rb"/>
</Path>
<!-- Add the "Ruby" entry to the Open Project Dialog -->
<Path name = "/SharpDevelop/Workbench/Combine/FileFilter">
<FileFilter id="RubyProject"
insertbefore="AllFiles"
name="Ruby Project Files (*.rbproj)"
class="ICSharpCode.SharpDevelop.Project.LoadProject"
extensions="*.rbproj"/>
insertbefore="AllFiles"
name="Ruby Project Files (*.rbproj)"
class="ICSharpCode.SharpDevelop.Project.LoadProject"
extensions="*.rbproj"/>
</Path>
<!-- File templates -->
@ -50,27 +51,27 @@ @@ -50,27 +51,27 @@
<Path name="/SharpDevelop/Workbench/MainMenu">
<Condition name="ActiveContentExtension" activeextension=".rb">
<MenuItem id="Ruby"
insertafter="Search"
insertbefore="Tools"
label="&amp;Ruby"
type="Menu">
insertafter="Search"
insertbefore="Tools"
label="&amp;Ruby"
type="Menu">
<Condition name="IsProcessRunning" isprocessrunning="False" isdebugging="False" action="Disable">
<MenuItem id="Run"
icon="Icons.16x16.RunProgramIcon"
class="ICSharpCode.RubyBinding.RunDebugRubyCommand"
label="${res:XML.MainMenu.RunMenu.Run}"
shortcut="Control|Shift|R"/>
icon="Icons.16x16.RunProgramIcon"
class="ICSharpCode.RubyBinding.RunDebugRubyCommand"
label="${res:XML.MainMenu.RunMenu.Run}"
shortcut="Control|Shift|R"/>
<MenuItem id="RunWithoutDebugger"
icon="Icons.16x16.Debug.StartWithoutDebugging"
class="ICSharpCode.RubyBinding.RunRubyCommand"
label="${res:XML.MainMenu.DebugMenu.RunWithoutDebug}"
shortcut="Control|Shift|W"/>
icon="Icons.16x16.Debug.StartWithoutDebugging"
class="ICSharpCode.RubyBinding.RunRubyCommand"
label="${res:XML.MainMenu.DebugMenu.RunWithoutDebug}"
shortcut="Control|Shift|W"/>
</Condition>
<Condition name="IsProcessRunning" isdebugging="True" action="Disable">
<MenuItem id="Stop"
icon="Icons.16x16.StopProcess"
class="ICSharpCode.SharpDevelop.Project.Commands.StopDebuggingCommand"
label="${res:XML.MainMenu.DebugMenu.Stop}"/>
icon="Icons.16x16.StopProcess"
class="ICSharpCode.SharpDevelop.Project.Commands.StopDebuggingCommand"
label="${res:XML.MainMenu.DebugMenu.Stop}"/>
</Condition>
</MenuItem>
</Condition>
@ -79,24 +80,24 @@ @@ -79,24 +80,24 @@
<!-- Ruby parser -->
<Path name="/Workspace/Parser">
<Parser id="Ruby"
supportedextensions=".rb"
projectfileextension=".rbproj"
class="ICSharpCode.RubyBinding.RubyParser"/>
supportedextensions=".rb"
projectfileextension=".rbproj"
class="ICSharpCode.RubyBinding.RubyParser"/>
</Path>
<!-- Register Ruby MSBuild project (.rbproj) -->
<Path name="/SharpDevelop/Workbench/ProjectBindings">
<ProjectBinding id="Ruby"
guid="{BD8E9625-815A-4BDB-B228-5D4F9C2541A1}"
supportedextensions=".rb"
projectfileextension=".rbproj"
class="ICSharpCode.RubyBinding.RubyProjectBinding" />
guid="{BD8E9625-815A-4BDB-B228-5D4F9C2541A1}"
supportedextensions=".rb"
projectfileextension=".rbproj"
class="ICSharpCode.RubyBinding.RubyProjectBinding" />
</Path>
<Path name="/SharpDevelop/Workbench/LanguageBindings">
<LanguageBinding id="Ruby"
class="ICSharpCode.RubyBinding.RubyLanguageBinding"
extensions=".rb" />
extensions=".rb" />
</Path>
<!-- The Ruby code completion binding -->
@ -109,24 +110,24 @@ @@ -109,24 +110,24 @@
<!-- Options panel -->
<Path name="/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions">
<OptionPanel id="RubyOptionsPanel"
label="Ruby"
class="ICSharpCode.RubyBinding.RubyOptionsPanel"/>
label="Ruby"
class="ICSharpCode.RubyBinding.RubyOptionsPanel"/>
</Path>
<!-- Project options panels -->
<Path path="/SharpDevelop/BackendBindings/ProjectOptions/Ruby">
<OptionPanel id="DebugOptions"
label="${res:Dialog.ProjectOptions.DebugOptions}"
class="ICSharpCode.SharpDevelop.Gui.OptionPanels.DebugOptions"/>
label="${res:Dialog.ProjectOptions.DebugOptions}"
class="ICSharpCode.SharpDevelop.Gui.OptionPanels.DebugOptions"/>
</Path>
<!-- Ruby display binding -->
<Path name="/SharpDevelop/Workbench/DisplayBindings">
<DisplayBinding id="RubyDisplayBinding"
type="Secondary"
fileNamePattern="\.rb$"
languagePattern="^Ruby$"
class="ICSharpCode.RubyBinding.RubyFormsDesignerDisplayBinding" />
type="Secondary"
fileNamePattern="\.rb$"
languagePattern="^Ruby$"
class="ICSharpCode.RubyBinding.RubyFormsDesignerDisplayBinding" />
</Path>
<Path name="/AddIns/DefaultTextEditor/Formatter/Ruby">
@ -140,43 +141,49 @@ @@ -140,43 +141,49 @@
<Condition name="ActiveContentExtension" activeextension=".vb"/>
</Or>
<MenuItem id="ConvertToRuby"
insertafter="CSharp"
insertbefore="VBNet"
label="Ruby"
class="ICSharpCode.RubyBinding.ConvertToRubyMenuCommand"/>
insertafter="CSharp"
insertbefore="VBNet"
label="Ruby"
class="ICSharpCode.RubyBinding.ConvertToRubyMenuCommand"/>
</ComplexCondition>
</Path>
<Path name = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/ProjectActions/Convert">
<Condition name="ProjectActive" activeproject="C#">
<MenuItem id="CSharpProjectToRubyProjectConverter"
label="From C# to Ruby"
class="ICSharpCode.RubyBinding.ConvertProjectToRubyProjectCommand"/>
label="From C# to Ruby"
class="ICSharpCode.RubyBinding.ConvertProjectToRubyProjectCommand"/>
</Condition>
<Condition name="ProjectActive" activeproject="VBNet">
<MenuItem id="VBNetProjectToRubyProjectConverter"
label="From VB.NET to Ruby"
class="ICSharpCode.RubyBinding.ConvertProjectToRubyProjectCommand"/>
label="From VB.NET to Ruby"
class="ICSharpCode.RubyBinding.ConvertProjectToRubyProjectCommand"/>
</Condition>
</Path>
<Path name = "/SharpDevelop/Workbench/Pads">
<Pad id="RubyConsole"
category="Tools"
title="Ruby Console"
insertafter="Bookmarks"
insertbefore="DefinitionView"
icon="PadIcons.Output"
defaultPosition = "Bottom, Hidden"
class="ICSharpCode.RubyBinding.RubyConsolePad"/>
category="Tools"
title="Ruby Console"
insertafter="Bookmarks"
insertbefore="DefinitionView"
icon="PadIcons.Output"
defaultPosition = "Bottom, Hidden"
class="ICSharpCode.RubyBinding.RubyConsolePad"/>
</Path>
<Path name = "/Workspace/Icons">
<Icon id="RubyFileIcon"
extensions=".rb"
resource="Ruby.ProjectBrowser.File" />
extensions=".rb"
resource="Ruby.ProjectBrowser.File" />
<Icon id="RubyProjectIcon"
language="Ruby"
resource="Ruby.ProjectBrowser.Project" />
language="Ruby"
resource="Ruby.ProjectBrowser.Project" />
</Path>
<Path name="/SharpDevelop/UnitTesting/TestFrameworks">
<TestFramework id="rbunit"
class="ICSharpCode.RubyBinding.RubyTestFramework"
supportedProjects=".rbproj" />
</Path>
</AddIn>

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

@ -83,7 +83,10 @@ @@ -83,7 +83,10 @@
<Compile Include="Src\CommandLineHistory.cs" />
<Compile Include="Src\ConsoleTextEditorKeyEventArgs.cs" />
<Compile Include="Src\ControlDispatcher.cs" />
<Compile Include="Src\CreateTextWriterInfo.cs" />
<Compile Include="Src\IControlDispatcher.cs" />
<Compile Include="Src\IRubyFileService.cs" />
<Compile Include="Src\RubyConsoleApplication.cs" />
<Compile Include="Src\RubyConsoleCompletionData.cs" />
<Compile Include="Src\ConvertProjectToRubyProjectCommand.cs" />
<Compile Include="Src\ConvertToRubyMenuCommand.cs" />
@ -109,6 +112,7 @@ @@ -109,6 +112,7 @@
<Compile Include="Src\RubyDesignerGenerator.cs" />
<Compile Include="Src\RubyDesignerLoader.cs" />
<Compile Include="Src\RubyDesignerLoaderProvider.cs" />
<Compile Include="Src\RubyFileService.cs" />
<Compile Include="Src\RubyFormattingStrategy.cs" />
<Compile Include="Src\RubyFormsDesignerDisplayBinding.cs" />
<Compile Include="Src\RubyLanguageBinding.cs" />
@ -120,6 +124,12 @@ @@ -120,6 +124,12 @@
<Compile Include="Src\RubyParser.cs" />
<Compile Include="Src\RubyProject.cs" />
<Compile Include="Src\RubyPropertyValueAssignment.cs" />
<Compile Include="Src\RubyTestDebugger.cs" />
<Compile Include="Src\RubyTestFramework.cs" />
<Compile Include="Src\RubyTestResult.cs" />
<Compile Include="Src\RubyTestRunner.cs" />
<Compile Include="Src\RubyTestRunnerApplication.cs" />
<Compile Include="Src\RubyTestRunnerResponseFile.cs" />
<Compile Include="Src\RubyTextEditorViewContent.cs" />
<Compile Include="Src\RunDebugRubyCommand.cs" />
<Compile Include="Src\RunRubyCommand.cs" />
@ -154,8 +164,24 @@ @@ -154,8 +164,24 @@
<None Include="Templates\LibraryProject.xpt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TestRunner\sdselectedtestsfile.rb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TestRunner\sdtest.rb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TestRunner\sdtestresult.rb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TestRunner\sdtestresultwriter.rb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TestRunner\sdtestrunner.rb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="TestRunner" />
<Folder Include="Resources" />
<Folder Include="Src" />
<Folder Include="Templates" />
@ -184,6 +210,11 @@ @@ -184,6 +210,11 @@
<Name>ICSharpCode.SharpDevelop.Dom</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Analysis\UnitTesting\UnitTesting.csproj">
<Project>{1F261725-6318-4434-A1B1-6C70CE4CD324}</Project>
<Name>UnitTesting</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\DisplayBindings\FormsDesigner\Project\FormsDesigner.csproj">
<Project>{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}</Project>
<Name>FormsDesigner</Name>

65
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/CreateTextWriterInfo.cs

@ -0,0 +1,65 @@ @@ -0,0 +1,65 @@
// <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 System.Text;
namespace ICSharpCode.RubyBinding
{
public class CreateTextWriterInfo
{
string fileName;
Encoding encoding;
bool append;
public CreateTextWriterInfo(string fileName, Encoding encoding, bool append)
{
this.fileName = fileName;
this.encoding = encoding;
this.append = append;
}
public string FileName {
get { return fileName; }
}
public Encoding Encoding {
get { return encoding; }
}
public bool Append {
get { return append; }
}
public override bool Equals(object obj)
{
CreateTextWriterInfo rhs = obj as CreateTextWriterInfo;
if (rhs != null) {
return Equals(rhs);
}
return false;
}
bool Equals(CreateTextWriterInfo rhs)
{
return (fileName == rhs.fileName) &&
(encoding == rhs.encoding) &&
(append == rhs.append);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public TextWriter CreateTextWriter()
{
return new StreamWriter(fileName, append, encoding);
}
}
}

20
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/IRubyFileService.cs

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
// <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 System.Text;
namespace ICSharpCode.RubyBinding
{
public interface IRubyFileService
{
string GetTempFileName();
TextWriter CreateTextWriter(CreateTextWriterInfo createTextWriterInfo);
void DeleteFile(string fileName);
}
}

10
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyAddInOptions.cs

@ -26,6 +26,7 @@ namespace ICSharpCode.RubyBinding @@ -26,6 +26,7 @@ namespace ICSharpCode.RubyBinding
#region Property names
public static readonly string RubyFileNameProperty = "RubyFileName";
public static readonly string RubyLibraryPathProperty = "RubyLibraryPath";
#endregion
Properties properties;
@ -43,6 +44,15 @@ namespace ICSharpCode.RubyBinding @@ -43,6 +44,15 @@ namespace ICSharpCode.RubyBinding
{
this.properties = properties;
}
public string RubyLibraryPath {
get { return properties.Get<string>(RubyLibraryPathProperty, String.Empty); }
set { properties.Set(RubyLibraryPathProperty, value.Trim()); }
}
public bool HasRubyLibraryPath {
get { return !String.IsNullOrEmpty(RubyLibraryPath); }
}
/// <summary>
/// Gets or sets the ruby console filename.

120
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsoleApplication.cs

@ -0,0 +1,120 @@ @@ -0,0 +1,120 @@
// <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.Diagnostics;
using System.Text;
namespace ICSharpCode.RubyBinding
{
public class RubyConsoleApplication
{
string fileName;
bool debug;
List<string> loadPaths = new List<string>();
string rubyScriptFileName = String.Empty;
string rubyScriptCommandLineArguments = String.Empty;
string workingDirectory = String.Empty;
string loadPath = String.Empty;
StringBuilder arguments;
public RubyConsoleApplication(RubyAddInOptions options)
{
this.fileName = options.RubyFileName;
}
public string FileName {
get { return fileName; }
}
public bool Debug {
get { return debug; }
set { debug = value; }
}
public void AddLoadPath(string path)
{
loadPaths.Add(path);
}
public string RubyScriptFileName {
get { return rubyScriptFileName; }
set { rubyScriptFileName = value; }
}
public string RubyScriptCommandLineArguments {
get { return rubyScriptCommandLineArguments; }
set { rubyScriptCommandLineArguments = value; }
}
public string WorkingDirectory {
get { return workingDirectory; }
set { workingDirectory = value; }
}
public ProcessStartInfo GetProcessStartInfo()
{
ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.FileName = fileName;
processStartInfo.Arguments = GetArguments();
processStartInfo.WorkingDirectory = workingDirectory;
return processStartInfo;
}
public string GetArguments()
{
arguments = new StringBuilder();
AppendBooleanOptionIfTrue("-D", debug);
AppendLoadPaths();
AppendQuotedStringIfNotEmpty(rubyScriptFileName);
AppendStringIfNotEmpty(rubyScriptCommandLineArguments);
return arguments.ToString().TrimEnd();
}
void AppendBooleanOptionIfTrue(string option, bool flag)
{
if (flag) {
AppendOption(option);
}
}
void AppendOption(string option)
{
arguments.Append(option + " ");
}
void AppendLoadPaths()
{
foreach (string path in loadPaths) {
AppendQuotedString("-I" + path);
}
}
void AppendQuotedStringIfNotEmpty(string option)
{
if (!String.IsNullOrEmpty(option)) {
AppendQuotedString(option);
}
}
void AppendQuotedString(string option)
{
string quotedOption = String.Format("\"{0}\"", option);
AppendOption(quotedOption);
}
void AppendStringIfNotEmpty(string option)
{
if (!String.IsNullOrEmpty(option)) {
AppendOption(option);
}
}
}
}

31
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyFileService.cs

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
// <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 System.Text;
namespace ICSharpCode.RubyBinding
{
public class RubyFileService : IRubyFileService
{
public string GetTempFileName()
{
return Path.GetTempFileName();
}
public TextWriter CreateTextWriter(CreateTextWriterInfo createTextWriterInfo)
{
return createTextWriterInfo.CreateTextWriter();
}
public void DeleteFile(string fileName)
{
File.Delete(fileName);
}
}
}

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

@ -21,6 +21,7 @@ namespace ICSharpCode.RubyBinding @@ -21,6 +21,7 @@ namespace ICSharpCode.RubyBinding
{
RubyAddInOptions options;
TextBox rubyFileNameTextBox;
TextBox rubyLibraryPathTextBox;
public RubyOptionsPanel() : this(new RubyAddInOptions())
{
@ -37,6 +38,8 @@ namespace ICSharpCode.RubyBinding @@ -37,6 +38,8 @@ namespace ICSharpCode.RubyBinding
rubyFileNameTextBox = (TextBox)ControlDictionary["rubyFileNameTextBox"];
rubyFileNameTextBox.Text = options.RubyFileName;
rubyLibraryPathTextBox = (TextBox)ControlDictionary["rubyLibraryPathTextBox"];
rubyLibraryPathTextBox.Text = options.RubyLibraryPath;
ConnectBrowseButton("browseButton", "rubyFileNameTextBox", "${res:SharpDevelop.FileFilter.ExecutableFiles}|*.exe", TextBoxEditMode.EditRawProperty);
}
@ -44,6 +47,7 @@ namespace ICSharpCode.RubyBinding @@ -44,6 +47,7 @@ namespace ICSharpCode.RubyBinding
public override bool StorePanelContents()
{
options.RubyFileName = rubyFileNameTextBox.Text;
options.RubyLibraryPath = rubyLibraryPathTextBox.Text;
return true;
}
}

71
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestDebugger.cs

@ -0,0 +1,71 @@ @@ -0,0 +1,71 @@
// <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.Diagnostics;
using ICSharpCode.Core.Services;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.RubyBinding
{
public class RubyTestDebugger : TestDebuggerBase
{
RubyAddInOptions options;
IRubyFileService fileService;
RubyTestRunnerApplication testRunnerApplication;
public RubyTestDebugger()
: this(new UnitTestDebuggerService(),
ServiceManager.Instance.MessageService,
new TestResultsMonitor(),
new RubyAddInOptions(),
new RubyFileService())
{
}
public RubyTestDebugger(IUnitTestDebuggerService debuggerService,
IMessageService messageService,
ITestResultsMonitor testResultsMonitor,
RubyAddInOptions options,
IRubyFileService fileService)
: base(debuggerService, messageService, testResultsMonitor)
{
this.options = options;
this.fileService = fileService;
testResultsMonitor.InitialFilePosition = 0;
}
public override void Start(SelectedTests selectedTests)
{
CreateTestRunnerApplication();
testRunnerApplication.CreateResponseFile(selectedTests);
base.Start(selectedTests);
}
void CreateTestRunnerApplication()
{
testRunnerApplication = new RubyTestRunnerApplication(base.TestResultsMonitor.FileName, options, fileService);
}
protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests)
{
testRunnerApplication.Debug = true;
return testRunnerApplication.CreateProcessStartInfo(selectedTests);
}
public override void Dispose()
{
testRunnerApplication.Dispose();
base.Dispose();
}
protected override TestResult CreateTestResultForTestFramework(TestResult testResult)
{
return new RubyTestResult(testResult);
}
}
}

64
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestFramework.cs

@ -0,0 +1,64 @@ @@ -0,0 +1,64 @@
// <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.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.RubyBinding
{
public class RubyTestFramework : ITestFramework
{
public bool IsTestMethod(IMember member)
{
if (member != null) {
return member.Name.StartsWith("test");
}
return false;
}
public bool IsTestClass(IClass c)
{
while (c != null) {
if (HasTestCaseBaseType(c)) {
return true;
}
c = c.BaseClass;
}
return false;
}
bool HasTestCaseBaseType(IClass c)
{
if (c.BaseTypes.Count > 0) {
string baseTypeName = c.BaseTypes[0].FullyQualifiedName;
return (baseTypeName == "Test.Unit.TestCase");
}
return false;
}
public bool IsTestProject(IProject project)
{
return project is RubyProject;
}
public ITestRunner CreateTestRunner()
{
return new RubyTestRunner();
}
public ITestRunner CreateTestDebugger()
{
return new RubyTestDebugger();
}
public bool IsBuildNeededBeforeTestRun {
get { return false; }
}
}
}

69
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestResult.cs

@ -0,0 +1,69 @@ @@ -0,0 +1,69 @@
// <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.SharpDevelop.Dom;
using System.Text.RegularExpressions;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.RubyBinding
{
public class RubyTestResult : TestResult
{
public RubyTestResult(TestResult testResult)
: base(testResult.Name)
{
ResultType = testResult.ResultType;
Message = testResult.Message;
StackTrace = testResult.StackTrace;
}
protected override void OnStackTraceChanged()
{
if (String.IsNullOrEmpty(StackTrace)) {
ResetStackTraceFilePosition();
} else {
GetFilePositionFromStackTrace();
}
}
void ResetStackTraceFilePosition()
{
StackTraceFilePosition = FilePosition.Empty;
}
/// <summary>
/// Stack trace: Failure:
/// test_fail(SecondTests)
/// [d:\temp\test\rubytests\SecondTests.rb:6:in `test_fail'
/// d:\temp\test\rubytests/sdtestrunner.rb:73:in `start_mediator'
/// d:\temp\test\rubytests/sdtestrunner.rb:47:in `start']:
/// Assertion was false.
/// <false> is not true.
/// </summary>
void GetFilePositionFromStackTrace()
{
Match match = Regex.Match(StackTrace, "\\s\\[(.*?):(\\d+):", RegexOptions.Multiline);
if (match.Success) {
try {
SetStackTraceFilePosition(match.Groups);
} catch (OverflowException) {
// Ignore.
}
}
}
void SetStackTraceFilePosition(GroupCollection groups)
{
string fileName = groups[1].Value;
int line = Convert.ToInt32(groups[2].Value);
int column = 1;
StackTraceFilePosition = new FilePosition(fileName, line, column);
}
}
}

70
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunner.cs

@ -0,0 +1,70 @@ @@ -0,0 +1,70 @@
// <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.Diagnostics;
using System.IO;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.RubyBinding
{
public class RubyTestRunner : TestProcessRunnerBase
{
RubyAddInOptions options;
IRubyFileService fileService;
RubyTestRunnerApplication testRunnerApplication;
public RubyTestRunner()
: this(new UnitTestProcessRunner(),
new TestResultsMonitor(),
new RubyAddInOptions(),
new RubyFileService())
{
}
public RubyTestRunner(IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor,
RubyAddInOptions options,
IRubyFileService fileService)
: base(processRunner, testResultsMonitor)
{
this.options = options;
this.fileService = fileService;
testResultsMonitor.InitialFilePosition = 0;
}
public override void Start(SelectedTests selectedTests)
{
CreateTestRunnerApplication();
testRunnerApplication.CreateResponseFile(selectedTests);
base.Start(selectedTests);
}
void CreateTestRunnerApplication()
{
testRunnerApplication = new RubyTestRunnerApplication(base.TestResultsMonitor.FileName, options, fileService);
}
protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests)
{
return testRunnerApplication.CreateProcessStartInfo(selectedTests);
}
public override void Dispose()
{
testRunnerApplication.Dispose();
base.Dispose();
}
protected override TestResult CreateTestResultForTestFramework(TestResult testResult)
{
return new RubyTestResult(testResult);
}
}
}

131
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunnerApplication.cs

@ -0,0 +1,131 @@ @@ -0,0 +1,131 @@
// <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.Diagnostics;
using System.IO;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.RubyBinding
{
public class RubyTestRunnerApplication
{
string testResultsFileName = String.Empty;
RubyAddInOptions options;
RubyTestRunnerResponseFile responseFile;
IRubyFileService fileService;
CreateTextWriterInfo textWriterInfo;
RubyConsoleApplication consoleApplication;
StringBuilder arguments;
public RubyTestRunnerApplication(string testResultsFileName,
RubyAddInOptions options,
IRubyFileService fileService)
{
this.testResultsFileName = testResultsFileName;
this.options = options;
this.fileService = fileService;
consoleApplication = new RubyConsoleApplication(options);
}
public bool Debug {
get { return consoleApplication.Debug; }
set { consoleApplication.Debug = value; }
}
public void CreateResponseFile(SelectedTests selectedTests)
{
CreateResponseFile();
using (responseFile) {
WriteTests(selectedTests);
}
}
void CreateResponseFile()
{
TextWriter writer = CreateTextWriter();
responseFile = new RubyTestRunnerResponseFile(writer);
}
TextWriter CreateTextWriter()
{
string fileName = fileService.GetTempFileName();
textWriterInfo = new CreateTextWriterInfo(fileName, Encoding.ASCII, false);
return fileService.CreateTextWriter(textWriterInfo);
}
void WriteTests(SelectedTests selectedTests)
{
responseFile.WriteTests(selectedTests);
}
public ProcessStartInfo CreateProcessStartInfo(SelectedTests selectedTests)
{
consoleApplication.RubyScriptFileName = GetSharpDevelopTestRubyScriptFileName();
AddLoadPaths();
consoleApplication.RubyScriptCommandLineArguments = GetCommandLineArguments(selectedTests);
consoleApplication.WorkingDirectory = selectedTests.Project.Directory;
return consoleApplication.GetProcessStartInfo();
}
void AddLoadPaths()
{
if (options.HasRubyLibraryPath) {
consoleApplication.AddLoadPath(options.RubyLibraryPath);
}
string testRunnerLoadPath = Path.GetDirectoryName(consoleApplication.RubyScriptFileName);
consoleApplication.AddLoadPath(testRunnerLoadPath);
}
string GetSharpDevelopTestRubyScriptFileName()
{
string fileName = StringParser.Parse(@"${addinpath:ICSharpCode.RubyBinding}\TestRunner\sdtest.rb");
return Path.GetFullPath(fileName);
}
string GetCommandLineArguments(SelectedTests selectedTests)
{
arguments = new StringBuilder();
AppendSelectedTest(selectedTests);
AppendTestResultsFileNameAndResponseFileNameArgs();
return arguments.ToString();
}
void AppendSelectedTest(SelectedTests selectedTests)
{
if (selectedTests.Method != null) {
AppendSelectedTestMethod(selectedTests.Method);
} else if (selectedTests.Class != null) {
AppendSelectedTestClass(selectedTests.Class);
}
}
void AppendSelectedTestMethod(IMember method)
{
arguments.AppendFormat("--name={0} ", method.Name);
}
void AppendSelectedTestClass(IClass c)
{
arguments.AppendFormat("--testcase={0} ", c.FullyQualifiedName);
}
void AppendTestResultsFileNameAndResponseFileNameArgs()
{
arguments.AppendFormat("-- \"{0}\" \"{1}\"", testResultsFileName, textWriterInfo.FileName);
}
public void Dispose()
{
fileService.DeleteFile(textWriterInfo.FileName);
}
}
}

83
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunnerResponseFile.cs

@ -0,0 +1,83 @@ @@ -0,0 +1,83 @@
// <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.ObjectModel;
using System.IO;
using System.Text;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.RubyBinding
{
public class RubyTestRunnerResponseFile : IDisposable
{
TextWriter writer;
public RubyTestRunnerResponseFile(string fileName)
: this(new StreamWriter(fileName, false, Encoding.ASCII))
{
}
public RubyTestRunnerResponseFile(TextWriter writer)
{
this.writer = writer;
}
public void Dispose()
{
writer.Dispose();
}
public void WriteTests(SelectedTests selectedTests)
{
if (selectedTests.Method != null) {
WriteTestFileNameForMethod(selectedTests.Method);
} else if (selectedTests.Class != null) {
WriteTestFileNameForClass(selectedTests.Class);
} else if (selectedTests.Project != null) {
WriteTestsForProject(selectedTests.Project);
}
}
void WriteTestFileNameForMethod(IMember method)
{
WriteTestFileNameForCompilationUnit(method.CompilationUnit);
}
void WriteTestFileNameForClass(IClass c)
{
WriteTestFileNameForCompilationUnit(c.CompilationUnit);
}
void WriteTestFileNameForCompilationUnit(ICompilationUnit unit)
{
WriteTestFileName(unit.FileName);
}
void WriteTestsForProject(IProject project)
{
WriteTestsForProjectFileItems(project.Items);
}
void WriteTestsForProjectFileItems(ReadOnlyCollection<ProjectItem> items)
{
foreach (ProjectItem item in items) {
FileProjectItem fileItem = item as FileProjectItem;
if (fileItem != null) {
WriteTestFileName(fileItem.FileName);
}
}
}
void WriteTestFileName(string testFileName)
{
writer.WriteLine(testFileName);
}
}
}

21
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RunRubyCommand.cs

@ -57,21 +57,32 @@ namespace ICSharpCode.RubyBinding @@ -57,21 +57,32 @@ namespace ICSharpCode.RubyBinding
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = options.RubyFileName;
info.Arguments = GetArguments();
info.WorkingDirectory = Path.GetDirectoryName(workbench.ActiveWorkbenchWindow.ActiveViewContent.PrimaryFileName);
info.WorkingDirectory = GetWorkingDirectory();
return info;
}
string GetWorkingDirectory()
{
return Path.GetDirectoryName(WorkbenchPrimaryFileName);
}
FileName WorkbenchPrimaryFileName {
get { return workbench.ActiveWorkbenchWindow.ActiveViewContent.PrimaryFileName; }
}
string GetArguments()
{
// Get the Ruby script filename.
string rubyScriptFileName = Path.GetFileName(workbench.ActiveWorkbenchWindow.ActiveViewContent.PrimaryFileName);
string args = "-1.9 " + rubyScriptFileName;
string args = GetRubyScriptFileName();
if (Debug) {
return "-D " + args;
}
return args;
}
string GetRubyScriptFileName()
{
return Path.GetFileName(WorkbenchPrimaryFileName);
}
}
}

32
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdselectedtestsfile.rb

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@

module Test
module Unit
module UI
module SharpDevelopConsole
class SharpDevelopSelectedTestsFile
def initialize(filename)
@tests = []
read_tests(filename)
end
def read_tests(filename)
File.open(filename).each {|line|
line = line.strip
if line.length > 0 then
@tests.push(line)
end
}
end
def tests
return @tests
end
end
end
end
end
end

27
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtest.rb

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@

require 'test/unit'
require 'test/unit/autorunner'
require 'sdselectedtestsfile'
Test::Unit.run = false
Test::Unit::AutoRunner::RUNNERS[:console] =
proc do |r|
require 'sdtestrunner'
Test::Unit::UI::SharpDevelopConsole::TestRunner
end
standalone = true
runner = Test::Unit::AutoRunner.new(standalone)
runner.process_args(ARGV)
# Add files to run tests on.
selected_tests_filename = ARGV.last
print "selected_tests_filename: " + selected_tests_filename
selected_tests_file = Test::Unit::UI::SharpDevelopConsole::SharpDevelopSelectedTestsFile.new(selected_tests_filename)
selected_tests_file.tests.each {|filename|
runner.to_run.push(filename)
}
runner.run

64
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtestresult.rb

@ -0,0 +1,64 @@ @@ -0,0 +1,64 @@

module Test
module Unit
module UI
module SharpDevelopConsole
class SharpDevelopTestResult
def initialize(name)
@name = parse_name(name)
@result = 'Success'
@message = ''
@stacktrace = ''
end
def parse_name(name)
@name = name
open_bracket_index = name.index('(')
if open_bracket_index > 0 then
close_bracket_index = name.index(')', open_bracket_index)
if close_bracket_index > 0 then
length = close_bracket_index - open_bracket_index - 1
method_name = name[0, open_bracket_index]
class_name = name[open_bracket_index + 1, length]
@name = class_name + '.' + method_name
end
end
end
def name
return @name
end
def result
return @result
end
def message
return @message
end
def stacktrace
return @stacktrace
end
def update_fault(fault)
@result = 'Failure'
@message = format_text(fault.message)
@stacktrace = format_text(fault.long_display)
end
def format_text(text)
formatted_text = ''
text.each_line do |line|
formatted_text += " " + line
end
return formatted_text[1..-1]
end
end
end
end
end
end

31
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtestresultwriter.rb

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@

require 'sdtestresult'
module Test
module Unit
module UI
module SharpDevelopConsole
class SharpDevelopTestResultWriter
def initialize(filename)
@file = File.open(filename, 'w')
end
def write_test_result(test_result)
writeline("Name: " + test_result.name)
writeline("Result: " + test_result.result)
writeline("Message: " + test_result.message)
writeline("StackTrace: " + test_result.stacktrace)
end
def writeline(message)
@file.write(message + "\r\n")
@file.flush
end
end
end
end
end
end

145
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtestrunner.rb

@ -0,0 +1,145 @@ @@ -0,0 +1,145 @@
#--
#
# Author:: Nathaniel Talbott.
# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
# License:: Ruby license.
#
# Extended to support SharpDevelop
require 'test/unit/ui/testrunnermediator'
require 'test/unit/ui/testrunnerutilities'
require 'sdtestresultwriter'
require 'sdtestresult'
module Test
module Unit
module UI
module SharpDevelopConsole
# Runs a Test::Unit::TestSuite on the console.
class TestRunner
extend TestRunnerUtilities
# Creates a new TestRunner for running the passed
# suite. If quiet_mode is true, the output while
# running is limited to progress dots, errors and
# failures, and the final result. io specifies
# where runner output should go to; defaults to
# STDOUT.
def initialize(suite, output_level=NORMAL, io=STDOUT)
if (suite.respond_to?(:suite))
@suite = suite.suite
else
@suite = suite
end
@output_level = output_level
@io = io
@already_outputted = false
@faults = []
resultsfile = ARGV[0]
@test_result_writer = SharpDevelopTestResultWriter.new(resultsfile)
end
# Begins the test run.
def start
setup_mediator
attach_to_mediator
return start_mediator
end
private
def setup_mediator
@mediator = create_mediator(@suite)
suite_name = @suite.to_s
if ( @suite.kind_of?(Module) )
suite_name = @suite.name
end
output("Loaded suite #{suite_name}")
end
def create_mediator(suite)
return TestRunnerMediator.new(suite)
end
def attach_to_mediator
@mediator.add_listener(TestResult::FAULT, &method(:add_fault))
@mediator.add_listener(TestRunnerMediator::STARTED, &method(:started))
@mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished))
@mediator.add_listener(TestCase::STARTED, &method(:test_started))
@mediator.add_listener(TestCase::FINISHED, &method(:test_finished))
end
def start_mediator
return @mediator.run_suite
end
def add_fault(fault)
@test_result.update_fault(fault)
@faults << fault
output_single(fault.single_character_display, PROGRESS_ONLY)
@already_outputted = true
end
def started(result)
@result = result
output("Started")
end
def finished(elapsed_time)
nl
output("Finished in #{elapsed_time} seconds.")
@faults.each_with_index do |fault, index|
nl
output("%3d) %s" % [index + 1, fault.long_display])
end
nl
output(@result)
end
def test_started(name)
create_test_result(name)
output_single(name + ": ", VERBOSE)
end
def create_test_result(name)
@test_result = SharpDevelopTestResult.new(name)
end
def test_finished(name)
write_test_result()
output_single(".", PROGRESS_ONLY) unless (@already_outputted)
nl(VERBOSE)
@already_outputted = false
end
def nl(level=NORMAL)
output("", level)
end
def output(something, level=NORMAL)
@io.puts(something) if (output?(level))
@io.flush
end
def output_single(something, level=NORMAL)
@io.write(something) if (output?(level))
@io.flush
end
def output?(level)
level <= @output_level
end
def write_test_result()
@test_result_writer.write_test_result(@test_result)
end
end
end
end
end
end
if __FILE__ == $0
Test::Unit::UI::SharpDevelopConsole::TestRunner.start_command_line_test
end

37
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Configuration/RubyAddInOptionsTestFixture.cs

@ -67,5 +67,42 @@ namespace RubyBinding.Tests.Configuration @@ -67,5 +67,42 @@ namespace RubyBinding.Tests.Configuration
Assert.AreEqual(fileName, options.RubyFileName);
Assert.AreEqual(fileName, p["RubyFileName"]);
}
[Test]
public void RubyLibraryPathTakenFromProperties()
{
Properties p = new Properties();
RubyAddInOptions options = new RubyAddInOptions(p);
string expectedRubyLibraryPath = @"c:\ruby\lib;c:\ruby\lib\lib-tk";
p["RubyLibraryPath"] = expectedRubyLibraryPath;
Assert.AreEqual(expectedRubyLibraryPath, options.RubyLibraryPath);
}
[Test]
public void HasRubyLibraryPathReturnsTrueForNonEmptyPath()
{
Properties p = new Properties();
RubyAddInOptions options = new RubyAddInOptions(p);
options.RubyLibraryPath = @"c:\ruby\lib";
Assert.IsTrue(options.HasRubyLibraryPath);
}
[Test]
public void HasRubyLibraryPathReturnsFalseForEmptyPath()
{
Properties p = new Properties();
RubyAddInOptions options = new RubyAddInOptions(p);
options.RubyLibraryPath = String.Empty;
Assert.IsFalse(options.HasRubyLibraryPath);
}
[Test]
public void RubyLibraryPathTrimsPath()
{
Properties p = new Properties();
RubyAddInOptions options = new RubyAddInOptions(p);
options.RubyLibraryPath = " ";
Assert.AreEqual(String.Empty, options.RubyLibraryPath);
}
}
}

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

@ -14,7 +14,7 @@ using ICSharpCode.SharpDevelop.Gui; @@ -14,7 +14,7 @@ using ICSharpCode.SharpDevelop.Gui;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests
namespace RubyBinding.Tests.Designer
{
/// <summary>
/// Tests the RubyFormsDesignerDisplayBinding.

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

@ -20,6 +20,7 @@ using ICSharpCode.FormsDesigner; @@ -20,6 +20,7 @@ using ICSharpCode.FormsDesigner;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
using UnitTesting.Tests.Utils;
namespace RubyBinding.Tests.Designer
{
@ -70,7 +71,7 @@ namespace RubyBinding.Tests.Designer @@ -70,7 +71,7 @@ namespace RubyBinding.Tests.Designer
[Test]
public void GetDomRegion()
{
MockMethod method = new MockMethod();
MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes();
DomRegion bodyRegion = new DomRegion(0, 4, 1, 4);
method.BodyRegion = bodyRegion;
DomRegion expectedRegion = new DomRegion(bodyRegion.BeginLine + 1, 1, bodyRegion.EndLine, 1);

3
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/RubyDesignerGeneratorTestFixture.cs

@ -17,6 +17,7 @@ using ICSharpCode.SharpDevelop; @@ -17,6 +17,7 @@ using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
using UnitTesting.Tests.Utils;
namespace RubyBinding.Tests.Designer
{
@ -26,7 +27,7 @@ namespace RubyBinding.Tests.Designer @@ -26,7 +27,7 @@ namespace RubyBinding.Tests.Designer
[Test]
public void GetMethodReplaceRegion()
{
MockMethod method = new MockMethod();
MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes();
DomRegion bodyRegion = new DomRegion(0, 4, 1, 4);
method.BodyRegion = bodyRegion;
DomRegion expectedRegion = new DomRegion(bodyRegion.BeginLine + 1, 1, bodyRegion.EndLine, 1);

6
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/DebugRunRubyCommandTestFixture.cs

@ -49,15 +49,15 @@ namespace RubyBinding.Tests.Gui @@ -49,15 +49,15 @@ namespace RubyBinding.Tests.Gui
}
[Test]
public void ProcessInfoFileName()
public void ProcessInfoFileNameContainsPathToIronRubyConsole()
{
Assert.AreEqual(@"C:\IronRuby\ir.exe", debugger.ProcessStartInfo.FileName);
}
[Test]
public void ProcessInfoArgs()
public void ProcessInfoArgsHasDebugArgument()
{
Assert.AreEqual("-D -1.9 test.rb", debugger.ProcessStartInfo.Arguments);
Assert.AreEqual("-D test.rb", debugger.ProcessStartInfo.Arguments);
}
}
}

20
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RubyOptionsPanelTestFixture.cs

@ -26,6 +26,7 @@ namespace RubyBinding.Tests.Gui @@ -26,6 +26,7 @@ namespace RubyBinding.Tests.Gui
Properties properties;
RubyAddInOptions options;
TextBox fileNameTextBox;
TextBox rubyLibraryPathTextBox;
[SetUp]
public void SetUp()
@ -33,9 +34,11 @@ namespace RubyBinding.Tests.Gui @@ -33,9 +34,11 @@ namespace RubyBinding.Tests.Gui
properties = new Properties();
options = new RubyAddInOptions(properties);
options.RubyFileName = @"C:\Ruby\ir.exe";
options.RubyLibraryPath = @"C:\Ruby\lib";
optionsPanel = new RubyOptionsPanel(options);
optionsPanel.LoadPanelContents();
fileNameTextBox = (TextBox)optionsPanel.ControlDictionary["rubyFileNameTextBox"];
rubyLibraryPathTextBox = (TextBox)optionsPanel.ControlDictionary["rubyLibraryPathTextBox"];
}
[TearDown]
@ -50,6 +53,12 @@ namespace RubyBinding.Tests.Gui @@ -50,6 +53,12 @@ namespace RubyBinding.Tests.Gui
Assert.AreEqual(options.RubyFileName, fileNameTextBox.Text);
}
[Test]
public void RubyLibraryPathDisplayed()
{
Assert.AreEqual(options.RubyLibraryPath, rubyLibraryPathTextBox.Text);
}
[Test]
public void PanelIsOptionsPanel()
{
@ -57,12 +66,21 @@ namespace RubyBinding.Tests.Gui @@ -57,12 +66,21 @@ namespace RubyBinding.Tests.Gui
}
[Test]
public void SaveOptions()
public void SavingOptionsUpdatesRubyFileName()
{
string fileName = @"C:\Program Files\IronRuby\ir.exe";
fileNameTextBox.Text = fileName;
optionsPanel.StorePanelContents();
Assert.AreEqual(fileName, options.RubyFileName);
}
[Test]
public void SavingOptionsUpdatesRubyLibraryPath()
{
string path = @"c:\Program Files\Python\lib";
rubyLibraryPathTextBox.Text = path;
optionsPanel.StorePanelContents();
Assert.AreEqual(path, options.RubyLibraryPath);
}
}
}

11
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RunRubyCommandTestFixture.cs

@ -59,22 +59,19 @@ namespace RubyBinding.Tests.Gui @@ -59,22 +59,19 @@ namespace RubyBinding.Tests.Gui
}
[Test]
public void ProcessInfoFileName()
public void ProcessInfoFileNameIsIronRubyConsole()
{
Assert.AreEqual(@"C:\IronRuby\ir.exe", debugger.ProcessStartInfo.FileName);
}
/// <summary>
/// The -1.9 parameter is used to enable Ruby 1.9 mode otherwise UTF8 files cannot be processed.
/// </summary>
[Test]
public void ProcessInfoArgs()
public void ProcessInfoArgsContainsFileNameActiveInTextEditor()
{
Assert.AreEqual("-1.9 test.rb", debugger.ProcessStartInfo.Arguments);
Assert.AreEqual("test.rb", debugger.ProcessStartInfo.Arguments);
}
[Test]
public void WorkingDirectory()
public void WorkingDirectoryIsSameDirectoryAsFileBeingRun()
{
Assert.AreEqual(@"C:\Projects", debugger.ProcessStartInfo.WorkingDirectory);
}

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

@ -317,8 +317,21 @@ @@ -317,8 +317,21 @@
<Compile Include="RubyLanguage\ProjectBindingTestFixture.cs" />
<Compile Include="RubyLanguage\RubyLanguageBindingTestFixture.cs" />
<Compile Include="RubyLanguage\RubyLanguagePropertiesTests.cs" />
<Compile Include="Testing\CreateRubyTestRunnerTestFixture.cs" />
<Compile Include="Testing\CreateTextWriterInfoEqualsTestFixture.cs" />
<Compile Include="Testing\CreateTextWriterFromCreateTextWriterInfoTestFixture.cs" />
<Compile Include="Testing\RubyConsoleApplicationTestFixture.cs" />
<Compile Include="Testing\RubyTestDebuggerRunsSelectedTestMethodTestFixture.cs" />
<Compile Include="Testing\RubyTestFrameworkIsTestClassTests.cs" />
<Compile Include="Testing\RubyTestFrameworkIsTestMethodTests.cs" />
<Compile Include="Testing\RubyTestFrameworkIsTestProjectTests.cs" />
<Compile Include="Testing\RubyTestResultFailureTestFixture.cs" />
<Compile Include="Testing\RubyTestRunnerApplicationTests.cs" />
<Compile Include="Testing\RubyTestRunnerRunsSelectedTestMethodTestFixture.cs" />
<Compile Include="Testing\RubyTestRunnerResponseFileTestFixture.cs" />
<Compile Include="Utils\AddedComponent.cs" />
<Compile Include="Utils\AddInHelper.cs" />
<Compile Include="Utils\AddInPathHelper.cs" />
<Compile Include="Utils\BarItemCollection.cs" />
<Compile Include="Utils\ConvertedFile.cs" />
<Compile Include="Utils\CreatedComponent.cs" />
@ -344,7 +357,6 @@ @@ -344,7 +357,6 @@
<Compile Include="Utils\MockEventBindingService.cs" />
<Compile Include="Utils\MockEventDescriptor.cs" />
<Compile Include="Utils\MockExtenderProviderService.cs" />
<Compile Include="Utils\MockMethod.cs" />
<Compile Include="Utils\MockOpenedFile.cs" />
<Compile Include="Utils\MockProject.cs" />
<Compile Include="Utils\MockProjectContent.cs" />
@ -352,6 +364,7 @@ @@ -352,6 +364,7 @@
<Compile Include="Utils\MockResourceReader.cs" />
<Compile Include="Utils\MockResourceService.cs" />
<Compile Include="Utils\MockResourceWriter.cs" />
<Compile Include="Utils\MockRubyFileService.cs" />
<Compile Include="Utils\MockSite.cs" />
<Compile Include="Utils\MockConsoleTextEditor.cs" />
<Compile Include="Utils\MockTextEditor.cs" />
@ -365,10 +378,13 @@ @@ -365,10 +378,13 @@
<Compile Include="Utils\NullPropertyUserControl.cs" />
<Compile Include="Utils\RubyBindingAddInFile.cs" />
<Compile Include="Utils\RubyParserHelper.cs" />
<Compile Include="Utils\RubySelectedTestsHelper.cs" />
<Compile Include="Utils\SupportInitCustomControl.cs" />
<Compile Include="Utils\Tests\AddInPathHelperTestFixture.cs" />
<Compile Include="Utils\Tests\MockControlDispatcherTestFixture.cs" />
<Compile Include="Utils\Tests\MockConsoleTextEditorTestFixture.cs" />
<Compile Include="Utils\Tests\MockEditableViewContentTestFixture.cs" />
<Compile Include="Utils\Tests\MockRubyFileServiceTestFixture.cs" />
<EmbeddedResource Include="..\Project\RubyBinding.addin">
<Link>RubyBinding.addin</Link>
</EmbeddedResource>
@ -377,6 +393,7 @@ @@ -377,6 +393,7 @@
<EmbeddedResource Include="Strings.resx" />
</ItemGroup>
<ItemGroup>
<Folder Include="Testing" />
<Folder Include="Utils\Tests" />
<ProjectReference Include="..\..\..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj">
<Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project>
@ -402,6 +419,14 @@ @@ -402,6 +419,14 @@
<Project>{8035765F-D51F-4A0C-A746-2FD100E19419}</Project>
<Name>ICSharpCode.SharpDevelop.Widgets</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Analysis\UnitTesting\Test\UnitTesting.Tests.csproj">
<Project>{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}</Project>
<Name>UnitTesting.Tests</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Analysis\UnitTesting\UnitTesting.csproj">
<Project>{1F261725-6318-4434-A1B1-6C70CE4CD324}</Project>
<Name>UnitTesting</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\DisplayBindings\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj">
<Project>{0162E499-42D0-409B-AA25-EED21F75336B}</Project>
<Name>AvalonEdit.AddIn</Name>

52
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/CreateRubyTestRunnerTestFixture.cs

@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
// <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;
using NUnit.Framework;
namespace RubyBinding.Tests.Testing
{
[TestFixture]
public class CreateRubyTestRunnerTestFixture
{
RubyTestFramework testFramework;
[TestFixtureSetUp]
public void SetUpFixture()
{
if (!PropertyService.Initialized) {
PropertyService.InitializeService(String.Empty, String.Empty, String.Empty);
}
}
[SetUp]
public void Init()
{
testFramework = new RubyTestFramework();
}
[Test]
public void RubyTestFrameworkCreateTestRunnerReturnsRubyTestRunner()
{
Assert.IsInstanceOf(typeof(RubyTestRunner), testFramework.CreateTestRunner());
}
[Test]
public void RubyTestFrameworkCreateTestDebuggerReturnsRubyTestDebugger()
{
Assert.IsInstanceOf(typeof(RubyTestDebugger), testFramework.CreateTestDebugger());
}
[Test]
public void RubyTestFrameworkIsBuildNeededBeforeTestRunReturnsFalse()
{
Assert.IsFalse(testFramework.IsBuildNeededBeforeTestRun);
}
}
}

41
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/CreateTextWriterFromCreateTextWriterInfoTestFixture.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.IO;
using System.Text;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
namespace RubyBinding.Tests.Testing
{
[TestFixture]
public class CreateTextWriterFromCreateTextWriterInfoTestFixture
{
TextWriter textWriter;
[TestFixtureSetUp]
public void SetUpFixture()
{
string fileName = Path.GetTempFileName();
CreateTextWriterInfo info = new CreateTextWriterInfo(fileName, Encoding.UTF8, false);
textWriter = info.CreateTextWriter();
}
[TestFixtureTearDown]
public void TearDownFixture()
{
textWriter.Dispose();
}
[Test]
public void CreatedTextWriterEncodingIsUtf8()
{
Assert.AreEqual(Encoding.UTF8, textWriter.Encoding);
}
}
}

57
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/CreateTextWriterInfoEqualsTestFixture.cs

@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
// <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.Text;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
namespace RubyBinding.Tests.Testing
{
[TestFixture]
public class CreateTextWriterInfoEqualsTestFixture
{
[Test]
public void CreateTextWriterInfosAreEqualWhenFileNameAndEncodingAndAppendAreEqual()
{
CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true);
CreateTextWriterInfo rhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true);
Assert.AreEqual(lhs, rhs);
}
[Test]
public void CreateTextWriterInfosAreNotEqualWhenFileNamesAreDifferent()
{
CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true);
CreateTextWriterInfo rhs = new CreateTextWriterInfo("different-filename.txt", Encoding.UTF8, true);
Assert.AreNotEqual(lhs, rhs);
}
[Test]
public void CreateTextWriterInfosAreNotEqualWhenEncodingsAreDifferent()
{
CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true);
CreateTextWriterInfo rhs = new CreateTextWriterInfo("test.txt", Encoding.ASCII, true);
Assert.AreNotEqual(lhs, rhs);
}
[Test]
public void CreateTextWriterInfosAreNotEqualWhenAppendIsDifferent()
{
CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true);
CreateTextWriterInfo rhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, false);
Assert.AreNotEqual(lhs, rhs);
}
[Test]
public void CreateTextWriterInfoEqualsReturnsFalseWhenNullPassedAsParameter()
{
CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true);
Assert.IsFalse(lhs.Equals(null));
}
}
}

95
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyConsoleApplicationTestFixture.cs

@ -0,0 +1,95 @@ @@ -0,0 +1,95 @@
// <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.Diagnostics;
using ICSharpCode.Core;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests.Testing
{
[TestFixture]
public class RubyConsoleApplicationTestFixture
{
RubyConsoleApplication app;
RubyAddInOptions options;
[SetUp]
public void Init()
{
options = new RubyAddInOptions(new Properties());
options.RubyFileName = @"C:\IronRuby\ir.exe";
app = new RubyConsoleApplication(options);
}
[Test]
public void FileNameIsRubyFileNameFromAddInOptions()
{
string expectedFileName = @"C:\IronRuby\ir.exe";
Assert.AreEqual(expectedFileName, app.FileName);
}
[Test]
public void GetArgumentsReturnsDebugOptionWhenDebugIsTrue()
{
app.Debug = true;
string expectedCommandLine = "-D";
Assert.AreEqual(expectedCommandLine, app.GetArguments());
}
[Test]
public void GetArgumentsReturnsQuotedRubyScriptFileName()
{
app.RubyScriptFileName = @"d:\projects\my ruby\test.rb";
string expectedCommandLine = "\"d:\\projects\\my ruby\\test.rb\"";
Assert.AreEqual(expectedCommandLine, app.GetArguments());
}
[Test]
public void GetArgumentsReturnsQuotedRubyScriptFileNameAndItsCommandLineArguments()
{
app.Debug = true;
app.RubyScriptFileName = @"d:\projects\my ruby\test.rb";
app.RubyScriptCommandLineArguments = "-- responseFile.txt";
string expectedCommandLine =
"-D \"d:\\projects\\my ruby\\test.rb\" -- responseFile.txt";
Assert.AreEqual(expectedCommandLine, app.GetArguments());
}
[Test]
public void GetProcessStartInfoHasFileNameThatEqualsIronRubyConsoleApplicationExeFileName()
{
ProcessStartInfo startInfo = app.GetProcessStartInfo();
string expectedFileName = @"C:\IronRuby\ir.exe";
Assert.AreEqual(expectedFileName, startInfo.FileName);
}
[Test]
public void GetProcessStartInfoHasDebugFlagSetInArguments()
{
app.Debug = true;
ProcessStartInfo startInfo = app.GetProcessStartInfo();
string expectedCommandLine = "-D";
Assert.AreEqual(expectedCommandLine, startInfo.Arguments);
}
[Test]
public void GetProcessStartInfoHasWorkingDirectoryIfSet()
{
app.WorkingDirectory = @"d:\temp";
ProcessStartInfo startInfo = app.GetProcessStartInfo();
Assert.AreEqual(@"d:\temp", startInfo.WorkingDirectory);
}
}
}

149
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestDebuggerRunsSelectedTestMethodTestFixture.cs

@ -0,0 +1,149 @@ @@ -0,0 +1,149 @@
// <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.Diagnostics;
using System.IO;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.UnitTesting;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
using UnitTesting.Tests.Utils;
namespace RubyBinding.Tests.Testing
{
[TestFixture]
public class RubyTestDebuggerRunsSelectedTestMethodTestFixture
{
MockDebuggerService debuggerService;
UnitTesting.Tests.Utils.MockDebugger debugger;
MockMessageService messageService;
MockCSharpProject project;
RubyTestDebugger testDebugger;
MockTestResultsMonitor testResultsMonitor;
SelectedTests selectedTests;
MockMethod methodToTest;
RubyAddInOptions options;
MockRubyFileService fileService;
StringBuilder responseFileText;
StringWriter responseFileStringWriter;
[SetUp]
public void Init()
{
CreateTestDebugger();
CreateTestMethod();
}
void CreateTestDebugger()
{
debuggerService = new MockDebuggerService();
debugger = debuggerService.MockDebugger;
messageService = new MockMessageService();
testResultsMonitor = new MockTestResultsMonitor();
testResultsMonitor.InitialFilePosition = 3;
options = new RubyAddInOptions(new Properties());
options.RubyFileName = @"c:\ironruby\ir.exe";
fileService = new MockRubyFileService();
testDebugger = new RubyTestDebugger(debuggerService, messageService, testResultsMonitor, options, fileService);
}
void CreateTestMethod()
{
project = new MockCSharpProject();
MockClass c = new MockClass("MyNamespace.MyTestClass");
methodToTest = new MockMethod(c, "MyTestMethod");
}
void RunTestsOnSelectedTestMethod()
{
fileService.SetTempFileName(@"d:\temp\tmp66.tmp");
CreateTemporaryResponseFileWriter();
selectedTests = new SelectedTests(project, null, null, methodToTest);
testDebugger.Start(selectedTests);
}
void CreateTemporaryResponseFileWriter()
{
responseFileText = new StringBuilder();
responseFileStringWriter = new StringWriter(responseFileText);
fileService.SetTextWriter(responseFileStringWriter);
}
[Test]
public void TestDebuggerProcessFileNameIsIronRubyConsoleExeTakenFromAddInOptions()
{
RunTestsOnSelectedTestMethod();
string expectedFileName = @"c:\ironruby\ir.exe";
Assert.AreEqual(expectedFileName, debugger.ProcessStartInfo.FileName);
}
[Test]
public void DisposingTestRunnerDeletesTemporaryResponseFile()
{
fileService.FileNameDeleted = null;
RunTestsOnSelectedTestMethod();
testDebugger.Dispose();
string expectedFileName = @"d:\temp\tmp66.tmp";
Assert.AreEqual(expectedFileName, fileService.FileNameDeleted);
}
[Test]
public void DisposingTestRunnerDisposesTestResultsMonitor()
{
RunTestsOnSelectedTestMethod();
testDebugger.Dispose();
Assert.IsTrue(testResultsMonitor.IsDisposeMethodCalled);
}
[Test]
public void CommandLineArgumentHasSharpDevelopTestRubyScriptFileNameAndTestResultsFileNameResponseFileName()
{
AddIn addin = AddInPathHelper.CreateDummyRubyAddInInsideAddInTree();
addin.FileName = @"c:\sharpdevelop\addins\rubybinding\rubybinding.addin";
testResultsMonitor.FileName = @"d:\testresults.txt";
RunTestsOnSelectedTestMethod();
string expectedCommandLine =
"-D " +
"\"-Ic:\\sharpdevelop\\addins\\rubybinding\\TestRunner\" " +
"\"c:\\sharpdevelop\\addins\\rubybinding\\TestRunner\\sdtest.rb\" " +
"--name=MyTestMethod " +
"-- " +
"\"d:\\testresults.txt\" " +
"\"d:\\temp\\tmp66.tmp\"";
Assert.AreEqual(expectedCommandLine, debugger.ProcessStartInfo.Arguments);
}
[Test]
public void RubyTestResultReturnedFromTestFinishedEvent()
{
TestResult testResult = null;
testDebugger.TestFinished += delegate(object source, TestFinishedEventArgs e) {
testResult = e.Result;
};
TestResult testResultToFire = new TestResult("test");
testResultsMonitor.FireTestFinishedEvent(testResultToFire);
Assert.IsInstanceOf(typeof(RubyTestResult), testResult);
}
[Test]
public void TestResultsMonitorInitialFilePositionIsZero()
{
Assert.AreEqual(0, testResultsMonitor.InitialFilePosition);
}
}
}

75
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestFrameworkIsTestClassTests.cs

@ -0,0 +1,75 @@ @@ -0,0 +1,75 @@
// <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.Dom;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
using UnitTesting.Tests.Utils;
namespace RubyBinding.Tests.Testing
{
[TestFixture]
public class RubyTestFrameworkIsTestClassTests
{
RubyTestFramework testFramework;
[SetUp]
public void Init()
{
testFramework = new RubyTestFramework();
}
[Test]
public void CreateClassWithTestUnitTestCaseBaseTypeReturnsClassWithFirstBaseTypeEqualToTestCase()
{
IClass c = MockClass.CreateClassWithBaseType("Test.Unit.TestCase");
string name = c.BaseTypes[0].FullyQualifiedName;
string expectedName = "Test.Unit.TestCase";
Assert.AreEqual(expectedName, name);
}
[Test]
public void IsTestClassReturnsTrueWhenClassFirstBaseTypeIsUnitTestTestCase()
{
MockClass c = MockClass.CreateClassWithBaseType("Test.Unit.TestCase");
Assert.IsTrue(testFramework.IsTestClass(c));
}
[Test]
public void IsTestClassReturnsFalseWhenClassHasNoBaseTypes()
{
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
Assert.IsFalse(testFramework.IsTestClass(c));
}
[Test]
public void IsTestClassReturnsFalseForNull()
{
Assert.IsFalse(testFramework.IsTestClass(null));
}
[Test]
public void IsTestClassReturnsFalseWhenFirstBaseTypeIsSystemWindowsFormsForm()
{
MockClass c = MockClass.CreateClassWithBaseType("System.Windows.Forms.Form");
Assert.IsFalse(testFramework.IsTestClass(c));
}
[Test]
public void IsTestClassReturnsTrueWhenDerivedClassHasBaseClassDerivedFromTestCase()
{
MockClass baseClass = MockClass.CreateClassWithBaseType("Test.Unit.TestCase");
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
DefaultReturnType returnType = new DefaultReturnType(baseClass);
c.BaseTypes.Add(returnType);
Assert.IsTrue(testFramework.IsTestClass(c));
}
}
}

49
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestFrameworkIsTestMethodTests.cs

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
// <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 NUnit.Framework;
using RubyBinding.Tests.Utils;
using UnitTesting.Tests.Utils;
namespace RubyBinding.Tests.Testing
{
[TestFixture]
public class RubyTestFrameworkIsTestMethodTests
{
RubyTestFramework testFramework;
[SetUp]
public void Init()
{
testFramework = new RubyTestFramework();
}
[Test]
public void IsTestMethodReturnsTrueForMethodThatStartsWithTest()
{
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
MockMethod method = new MockMethod(c, "testRunThis");
Assert.IsTrue(testFramework.IsTestMethod(method));
}
[Test]
public void IsTestMethodReturnsFalseForNull()
{
Assert.IsFalse(testFramework.IsTestMethod(null));
}
[Test]
public void IsTestMethodReturnsFalseForMethodThatDoesNotStartWithTest()
{
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
MockMethod method = new MockMethod(c, "RunThis");
Assert.IsFalse(testFramework.IsTestMethod(method));
}
}
}

66
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestFrameworkIsTestProjectTests.cs

@ -0,0 +1,66 @@ @@ -0,0 +1,66 @@
// <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.Internal.Templates;
using ICSharpCode.SharpDevelop.Project;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
using UnitTesting.Tests.Utils;
namespace RubyBinding.Tests.Testing
{
[TestFixture]
public class RubyTestFrameworkIsTestProjectTests
{
RubyTestFramework testFramework;
[TestFixtureSetUp]
public void SetUpFixture()
{
MSBuildEngineHelper.InitMSBuildEngine();
}
[SetUp]
public void Init()
{
testFramework = new RubyTestFramework();
}
[Test]
public void IsTestProjectWhenPassedNullProjectReturnsFalse()
{
Assert.IsFalse(testFramework.IsTestProject(null));
}
[Test]
public void IsTestProjectWhenPassedRubyPythonProjectReturnsTrue()
{
ProjectCreateInformation createInfo = new ProjectCreateInformation();
createInfo.Solution = new Solution();
createInfo.OutputProjectFileName = @"C:\projects\test.rbproj";
RubyProject project = new RubyProject(createInfo);
Assert.IsTrue(testFramework.IsTestProject(project));
}
[Test]
public void IsTestProjectWhenPassedNonPythonProjectReturnsFalse()
{
MockProject project = new MockProject();
Assert.IsFalse(testFramework.IsTestProject(project));
}
[Test]
public void IsTestProjectWhenPassedNullRubyProjectReturnsFalse()
{
RubyProject project = null;
Assert.IsFalse(testFramework.IsTestProject(project));
}
}
}

94
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestResultFailureTestFixture.cs

@ -0,0 +1,94 @@ @@ -0,0 +1,94 @@
// <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.SharpDevelop.Dom;
using ICSharpCode.RubyBinding;
using ICSharpCode.UnitTesting;
using NUnit.Framework;
namespace RubyBinding.Tests.Testing
{
[TestFixture]
public class RubyTestResultFailureTestFixture
{
RubyTestResult RubyTestResult;
string stackTraceText;
[SetUp]
public void Init()
{
TestResult testResult = new TestResult("MyTest");
testResult.ResultType = TestResultType.Failure;
testResult.Message = "test failed";
stackTraceText =
"Failure:\r\n" +
"test_fail(SecondTests)\r\n" +
" [d:\\projects\\rubytests\\SecondTests.rb:6:in `test_fail'\r\n" +
" d:\\test\\rubytests/sdtestrunner.rb:73:in `start_mediator'\r\n" +
" d:\\test\\rubytests/sdtestrunner.rb:47:in `start']:\r\n" +
"Assertion was false.\r\n" +
"<false> is not true.\r\n" +
"";
testResult.StackTrace = stackTraceText;
RubyTestResult = new RubyTestResult(testResult);
}
[Test]
public void TestResultNameIsMyTest()
{
Assert.AreEqual("MyTest", RubyTestResult.Name);
}
[Test]
public void TestResultTypeIsFailure()
{
Assert.AreEqual(TestResultType.Failure, RubyTestResult.ResultType);
}
[Test]
public void TestResultMessageIsTestFailed()
{
Assert.AreEqual("test failed", RubyTestResult.Message);
}
[Test]
public void RubyTestResultHasStackTraceFromOriginalTestResult()
{
Assert.AreEqual(stackTraceText, RubyTestResult.StackTrace);
}
[Test]
public void StackTraceFilePositionHasExpectedFileName()
{
string expectedFileName = @"d:\projects\rubytests\SecondTests.rb";
Assert.AreEqual(expectedFileName, RubyTestResult.StackTraceFilePosition.FileName);
}
[Test]
public void StackTraceFilePositionLineIs6()
{
Assert.AreEqual(6, RubyTestResult.StackTraceFilePosition.Line);
}
[Test]
public void StackTraceFilePositionColumnIsOne()
{
Assert.AreEqual(1, RubyTestResult.StackTraceFilePosition.Column);
}
[Test]
public void ChangingStackTraceToEmptyStringSetsStackTraceFilePositionToEmpty()
{
RubyTestResult.StackTraceFilePosition = new FilePosition("test.rb", 10, 2);
RubyTestResult.StackTrace = String.Empty;
Assert.IsTrue(RubyTestResult.StackTraceFilePosition.IsEmpty);
}
}
}

129
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerApplicationTests.cs

@ -0,0 +1,129 @@ @@ -0,0 +1,129 @@
// <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 System.Diagnostics;
using ICSharpCode.Core;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.UnitTesting;
using NUnit.Framework;
using RubyBinding.Tests.Testing;
using RubyBinding.Tests.Utils;
using UnitTesting.Tests.Utils;
namespace RubyBinding.Tests.Testing
{
[TestFixture]
public class RubyTestRunnerApplicationTests
{
RubyTestRunnerApplication testRunner;
RubyAddInOptions options;
[SetUp]
public void Init()
{
string tempFileName = "temp.tmp";
MockRubyFileService fileService = new MockRubyFileService();
fileService.SetTempFileName(tempFileName);
fileService.SetTextWriter(new StringWriter());
Properties properties = new Properties();
options = new RubyAddInOptions(properties);
AddIn addin = AddInPathHelper.CreateDummyRubyAddInInsideAddInTree();
addin.FileName = @"c:\rubybinding\rubybinding.addin";
string testResultsFileName = "results.txt";
testRunner = new RubyTestRunnerApplication(testResultsFileName, options, fileService);
}
[Test]
public void CreateProcessInfoReturnsCommandLineWithTestClassOption()
{
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
c.FullyQualifiedName = "MyTests";
SelectedTests selectedTests = RubySelectedTestsHelper.CreateSelectedTests(c);
ProcessStartInfo processStartInfo = GetProcessStartInfoFromTestRunnerApp(selectedTests);
string expectedCommandLine =
"\"-Ic:\\rubybinding\\TestRunner\" " +
"\"c:\\rubybinding\\TestRunner\\sdtest.rb\" " +
"--testcase=MyTests " +
"-- " +
"\"results.txt\" " +
"\"temp.tmp\"";
Assert.AreEqual(expectedCommandLine, processStartInfo.Arguments);
}
ProcessStartInfo GetProcessStartInfoFromTestRunnerApp(SelectedTests selectedTests)
{
testRunner.CreateResponseFile(selectedTests);
return testRunner.CreateProcessStartInfo(selectedTests);
}
[Test]
public void CreateProcessInfoReturnsCommandLineWithTestMethodOption()
{
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
MockMethod method = new MockMethod(c, "MyMethod");
SelectedTests selectedTests = RubySelectedTestsHelper.CreateSelectedTests(method);
ProcessStartInfo processStartInfo = GetProcessStartInfoFromTestRunnerApp(selectedTests);
string expectedCommandLine =
"\"-Ic:\\rubybinding\\TestRunner\" " +
"\"c:\\rubybinding\\TestRunner\\sdtest.rb\" " +
"--name=MyMethod " +
"-- " +
"\"results.txt\" " +
"\"temp.tmp\"";
Assert.AreEqual(expectedCommandLine, processStartInfo.Arguments);
}
[Test]
public void CreateProcessInfoReturnsFixedTestRunnerFilePath()
{
AddIn addin = AddInPathHelper.CreateDummyRubyAddInInsideAddInTree();
addin.FileName = @"c:\rubybinding\bin\..\AddIns\rubybinding.addin";
MockCSharpProject project = new MockCSharpProject();
SelectedTests selectedTests = RubySelectedTestsHelper.CreateSelectedTests(project);
ProcessStartInfo processStartInfo = GetProcessStartInfoFromTestRunnerApp(selectedTests);
string expectedCommandLine =
"\"-Ic:\\rubybinding\\AddIns\\TestRunner\" " +
"\"c:\\rubybinding\\AddIns\\TestRunner\\sdtest.rb\" " +
"-- " +
"\"results.txt\" " +
"\"temp.tmp\"";
Assert.AreEqual(expectedCommandLine, processStartInfo.Arguments);
}
[Test]
public void CreateProcessInfoReturnsCommandLineWithLoadPathSpecifiedInRubyAddInOptions()
{
MockCSharpProject project = new MockCSharpProject();
options.RubyLibraryPath = @"c:\ruby\lib";
SelectedTests selectedTests = RubySelectedTestsHelper.CreateSelectedTests(project);
ProcessStartInfo processStartInfo = GetProcessStartInfoFromTestRunnerApp(selectedTests);
string expectedCommandLine =
"\"-Ic:\\ruby\\lib\" " +
"\"-Ic:\\rubybinding\\TestRunner\" " +
"\"c:\\rubybinding\\TestRunner\\sdtest.rb\" " +
"-- " +
"\"results.txt\" " +
"\"temp.tmp\"";
Assert.AreEqual(expectedCommandLine, processStartInfo.Arguments);
}
}
}

115
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerResponseFileTestFixture.cs

@ -0,0 +1,115 @@ @@ -0,0 +1,115 @@
// <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 System.Text;
using ICSharpCode.Core.Services;
using ICSharpCode.RubyBinding;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
using UnitTesting.Tests.Utils;
namespace RubyBinding.Tests.Testing
{
[TestFixture]
public class RubyTestRunnerResponseFileTestFixture
{
RubyTestRunnerResponseFile responseFile;
StringBuilder responseFileText;
StringWriter writer;
[SetUp]
public void Init()
{
responseFileText = new StringBuilder();
writer = new StringWriter(responseFileText);
responseFile = new RubyTestRunnerResponseFile(writer);
}
[Test]
public void DisposeMethodDisposesTextWriterPassedInConstructor()
{
responseFile.Dispose();
Assert.Throws<ObjectDisposedException>(delegate { writer.WriteLine("test"); });
}
[Test]
public void WriteTestsAddsTestClassFileNameToResponseFile()
{
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
c.CompilationUnit.FileName = @"d:\mytest.rb";
SelectedTests selectedTests = RubySelectedTestsHelper.CreateSelectedTests(c);
responseFile.WriteTests(selectedTests);
string expectedText = "d:\\mytest.rb\r\n";
Assert.AreEqual(expectedText, responseFileText.ToString());
}
[Test]
public void WriteTestsAddsTestMethodFileNameToResponseFile()
{
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
MockMethod method = new MockMethod(c, "MyTest");
method.CompilationUnit.FileName = @"d:\mytest.rb";
SelectedTests selectedTests = RubySelectedTestsHelper.CreateSelectedTests(method);
responseFile.WriteTests(selectedTests);
string expectedText = "d:\\mytest.rb\r\n";
Assert.AreEqual(expectedText, responseFileText.ToString());
}
[Test]
public void WriteTestsAddsFileNamesForFileInProject()
{
MockCSharpProject project = new MockCSharpProject(new Solution(), "mytests");
FileProjectItem item = new FileProjectItem(project, ItemType.Compile);
item.FileName = @"c:\projects\mytests\myTests.rb";
ProjectService.AddProjectItem(project, item);
SelectedTests selectedTests = RubySelectedTestsHelper.CreateSelectedTests(project);
responseFile.WriteTests(selectedTests);
string expectedText = "c:\\projects\\mytests\\myTests.rb\r\n";
Assert.AreEqual(expectedText, responseFileText.ToString());
}
[Test]
public void WriteTestsDoesNotThrowNullReferenceExceptionWhenNonFileProjectItemInProject()
{
MockCSharpProject project = new MockCSharpProject(new Solution(), "mytests");
WebReferenceUrl webRef = new WebReferenceUrl(project);
webRef.Include = "test";
ProjectService.AddProjectItem(project, webRef);
FileProjectItem item = new FileProjectItem(project, ItemType.Compile);
item.FileName = @"c:\projects\mytests\myTests.rb";
ProjectService.AddProjectItem(project, item);
SelectedTests tests = new SelectedTests(project);
responseFile.WriteTests(tests);
string expectedText = "c:\\projects\\mytests\\myTests.rb\r\n";
Assert.AreEqual(expectedText, responseFileText.ToString());
}
[Test]
public void WriteTestsDoesNotThrowNullReferenceExceptionWhenProjectIsNull()
{
SelectedTests tests = new SelectedTests(null);
responseFile.WriteTests(tests);
Assert.AreEqual(String.Empty, responseFileText.ToString());
}
}
}

200
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerRunsSelectedTestMethodTestFixture.cs

@ -0,0 +1,200 @@ @@ -0,0 +1,200 @@
// <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.Diagnostics;
using System.IO;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.UnitTesting;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
using UnitTesting.Tests.Utils;
namespace RubyBinding.Tests.Testing
{
[TestFixture]
public class RubyTestRunnerRunsSelectedTestMethodTestFixture
{
MockCSharpProject project;
RubyTestRunner testRunner;
MockProcessRunner processRunner;
MockTestResultsMonitor testResultsMonitor;
SelectedTests selectedTests;
MockMethod methodToTest;
RubyAddInOptions options;
MockRubyFileService fileService;
StringBuilder responseFileText;
StringWriter responseFileStringWriter;
[SetUp]
public void Init()
{
CreateTestRunner();
CreateTestMethod();
}
void CreateTestRunner()
{
processRunner = new MockProcessRunner();
testResultsMonitor = new MockTestResultsMonitor();
testResultsMonitor.InitialFilePosition = 3;
options = new RubyAddInOptions(new Properties());
options.RubyFileName = @"c:\ironruby\ir.exe";
fileService = new MockRubyFileService();
testRunner = new RubyTestRunner(processRunner, testResultsMonitor, options, fileService);
}
void CreateTestMethod()
{
project = new MockCSharpProject();
MockClass c = new MockClass("MyNamespace.MyTestClass");
methodToTest = new MockMethod(c, "MyTestMethod");
}
void RunTestsOnSelectedTestMethod()
{
fileService.SetTempFileName(@"d:\temp\tmp66.tmp");
CreateTemporaryResponseFileWriter();
selectedTests = new SelectedTests(project, null, null, methodToTest);
testRunner.Start(selectedTests);
}
void CreateTemporaryResponseFileWriter()
{
responseFileText = new StringBuilder();
responseFileStringWriter = new StringWriter(responseFileText);
fileService.SetTextWriter(responseFileStringWriter);
}
[Test]
public void TestRunnerProcessFileNameIsIronRubyConsoleExeTakenFromAddInOptions()
{
RunTestsOnSelectedTestMethod();
string expectedFileName = @"c:\ironruby\ir.exe";
Assert.AreEqual(expectedFileName, processRunner.CommandPassedToStartMethod);
}
[Test]
public void CommandLineArgumentHasSharpDevelopTestRubyScriptFileNameAndTestResultsFileNameAndResponseFileName()
{
AddIn addin = AddInPathHelper.CreateDummyRubyAddInInsideAddInTree();
addin.FileName = @"c:\sharpdevelop\addins\rubybinding\rubybinding.addin";
testResultsMonitor.FileName = @"d:\testresults.txt";
RunTestsOnSelectedTestMethod();
string expectedCommandLine =
"\"-Ic:\\sharpdevelop\\addins\\rubybinding\\TestRunner\" " +
"\"c:\\sharpdevelop\\addins\\rubybinding\\TestRunner\\sdtest.rb\" " +
"--name=MyTestMethod " +
"-- " +
"\"d:\\testresults.txt\" " +
"\"d:\\temp\\tmp66.tmp\"";
Assert.AreEqual(expectedCommandLine, processRunner.CommandArgumentsPassedToStartMethod);
}
[Test]
public void ResponseFileCreatedUsingTempFileName()
{
RunTestsOnSelectedTestMethod();
Assert.AreEqual(@"d:\temp\tmp66.tmp", fileService.CreateTextWriterInfoPassedToCreateTextWriter.FileName);
}
[Test]
public void ResponseFileCreatedWithAsciiEncoding()
{
RunTestsOnSelectedTestMethod();
Assert.AreEqual(Encoding.ASCII, fileService.CreateTextWriterInfoPassedToCreateTextWriter.Encoding);
}
[Test]
public void ResponseFileCreatedWithAppendSetToFalse()
{
RunTestsOnSelectedTestMethod();
Assert.IsFalse(fileService.CreateTextWriterInfoPassedToCreateTextWriter.Append);
}
[Test]
public void DisposingTestRunnerDeletesTemporaryResponseFile()
{
fileService.FileNameDeleted = null;
RunTestsOnSelectedTestMethod();
testRunner.Dispose();
string expectedFileName = @"d:\temp\tmp66.tmp";
Assert.AreEqual(expectedFileName, fileService.FileNameDeleted);
}
[Test]
public void DisposingTestRunnerDisposesTestResultsMonitor()
{
RunTestsOnSelectedTestMethod();
testRunner.Dispose();
Assert.IsTrue(testResultsMonitor.IsDisposeMethodCalled);
}
[Test]
public void ResponseFileTextContainsTestMethodFileName()
{
methodToTest.CompilationUnit.FileName = @"d:\projects\ruby\test.rb";
RunTestsOnSelectedTestMethod();
string expectedText =
"d:\\projects\\ruby\\test.rb\r\n";
Assert.AreEqual(expectedText, responseFileText.ToString());
}
[Test]
public void ResponseFileTextWriterDisposedAfterTestsRun()
{
RunTestsOnSelectedTestMethod();
Assert.Throws<ObjectDisposedException>(delegate { responseFileStringWriter.Write("test"); });
}
[Test]
public void ProcessRunnerWorkingDirectoryIsDirectoryContainingProject()
{
RunTestsOnSelectedTestMethod();
string expectedDirectory = @"c:\projects\MyTests";
string actualDirectory = processRunner.WorkingDirectory;
Assert.AreEqual(expectedDirectory, actualDirectory);
}
[Test]
public void RubyTestResultReturnedFromTestFinishedEvent()
{
TestResult testResult = null;
testRunner.TestFinished += delegate(object source, TestFinishedEventArgs e) {
testResult = e.Result;
};
TestResult testResultToFire = new TestResult("test");
testResultsMonitor.FireTestFinishedEvent(testResultToFire);
Assert.IsInstanceOf(typeof(RubyTestResult), testResult);
}
[Test]
public void TestResultsMonitorInitialFilePositionIsZero()
{
Assert.AreEqual(0, testResultsMonitor.InitialFilePosition);
}
}
}

60
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/AddInPathHelper.cs

@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
// <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;
namespace RubyBinding.Tests.Utils
{
public static class AddInPathHelper
{
public static AddIn CreateDummyRubyAddInInsideAddInTree()
{
RemoveOldAddIn();
AddIn addin = CreateAddIn();
AddInTree.InsertAddIn(addin);
return addin;
}
static void RemoveOldAddIn()
{
AddIn oldAddin = FindOldAddIn();
if (oldAddin != null) {
AddInTree.RemoveAddIn(oldAddin);
}
}
static AddIn FindOldAddIn()
{
foreach (AddIn addin in AddInTree.AddIns) {
if (addin.Manifest.PrimaryIdentity == "ICSharpCode.RubyBinding") {
return addin;
}
}
return null;
}
static AddIn CreateAddIn()
{
string xml = GetAddInXml();
AddIn addin = AddIn.Load(new StringReader(xml));
addin.FileName = @"C:\SharpDevelop\AddIns\RubyBinding\RubyBinding.addin";
return addin;
}
static string GetAddInXml()
{
return
"<AddIn name='RubyBinding' author= '' copyright='' description=''>\r\n" +
" <Manifest>\r\n" +
" <Identity name='ICSharpCode.RubyBinding'/>\r\n" +
" </Manifest>\r\n" +
"</AddIn>";
}
}
}

297
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockMethod.cs

@ -1,297 +0,0 @@ @@ -1,297 +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 ICSharpCode.SharpDevelop.Dom;
namespace RubyBinding.Tests.Utils
{
/// <summary>
/// Mock IMethod implementation.
/// </summary>
public class MockMethod : IMethod
{
public MockMethod()
{
}
public DomRegion BodyRegion { get; set; }
public IList<ITypeParameter> TypeParameters {
get {
throw new NotImplementedException();
}
}
public bool IsConstructor {
get {
throw new NotImplementedException();
}
}
public bool IsOperator {
get {
throw new NotImplementedException();
}
}
public IList<string> HandlesClauses {
get {
throw new NotImplementedException();
}
}
public IList<IParameter> Parameters {
get {
throw new NotImplementedException();
}
}
public bool IsExtensionMethod {
get {
throw new NotImplementedException();
}
}
public string FullyQualifiedName {
get {
throw new NotImplementedException();
}
}
public IReturnType DeclaringTypeReference {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public IMember GenericMember {
get {
throw new NotImplementedException();
}
}
public DomRegion Region {
get {
throw new NotImplementedException();
}
}
public string Name {
get {
throw new NotImplementedException();
}
}
public string Namespace {
get {
throw new NotImplementedException();
}
}
public string DotNetName {
get {
throw new NotImplementedException();
}
}
public IReturnType ReturnType {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public IList<ExplicitInterfaceImplementation> InterfaceImplementations {
get {
throw new NotImplementedException();
}
}
public IClass DeclaringType {
get {
throw new NotImplementedException();
}
}
public ModifierEnum Modifiers {
get {
throw new NotImplementedException();
}
}
public IList<IAttribute> Attributes {
get {
throw new NotImplementedException();
}
}
public string Documentation {
get {
throw new NotImplementedException();
}
}
public bool IsAbstract {
get {
throw new NotImplementedException();
}
}
public bool IsSealed {
get {
throw new NotImplementedException();
}
}
public bool IsStatic {
get {
throw new NotImplementedException();
}
}
public bool IsConst {
get {
throw new NotImplementedException();
}
}
public bool IsVirtual {
get {
throw new NotImplementedException();
}
}
public bool IsPublic {
get {
throw new NotImplementedException();
}
}
public bool IsProtected {
get {
throw new NotImplementedException();
}
}
public bool IsPrivate {
get {
throw new NotImplementedException();
}
}
public bool IsInternal {
get {
throw new NotImplementedException();
}
}
public bool IsReadonly {
get {
throw new NotImplementedException();
}
}
public bool IsProtectedAndInternal {
get {
throw new NotImplementedException();
}
}
public bool IsProtectedOrInternal {
get {
throw new NotImplementedException();
}
}
public bool IsOverride {
get {
throw new NotImplementedException();
}
}
public bool IsOverridable {
get {
throw new NotImplementedException();
}
}
public bool IsNew {
get {
throw new NotImplementedException();
}
}
public bool IsSynthetic {
get {
throw new NotImplementedException();
}
}
public object UserData {
get {
throw new NotImplementedException();
}
set {
throw new NotImplementedException();
}
}
public bool IsFrozen {
get {
throw new NotImplementedException();
}
}
public IMember CreateSpecializedMember()
{
throw new NotImplementedException();
}
public bool IsAccessible(IClass callingClass, bool isClassInInheritanceTree)
{
throw new NotImplementedException();
}
public void Freeze()
{
throw new NotImplementedException();
}
public int CompareTo(object obj)
{
throw new NotImplementedException();
}
public object Clone()
{
throw new NotImplementedException();
}
public ICompilationUnit CompilationUnit {
get {
throw new NotImplementedException();
}
}
public IProjectContent ProjectContent {
get {
throw new NotImplementedException();
}
}
public EntityType EntityType {
get { return EntityType.Method; }
}
}
}

58
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockRubyFileService.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 System.IO;
using System.Text;
using ICSharpCode.RubyBinding;
namespace RubyBinding.Tests.Utils
{
public class MockRubyFileService : IRubyFileService
{
CreateTextWriterInfo createTextWriterInfoPassedToCreateTextWriter;
string tempFileName;
TextWriter textWriter;
string fileNameDeleted;
public void SetTempFileName(string fileName)
{
this.tempFileName = fileName;
}
public string GetTempFileName()
{
return tempFileName;
}
public void SetTextWriter(TextWriter writer)
{
this.textWriter = writer;
}
public TextWriter CreateTextWriter(CreateTextWriterInfo textWriterInfo)
{
createTextWriterInfoPassedToCreateTextWriter = textWriterInfo;
return textWriter;
}
public CreateTextWriterInfo CreateTextWriterInfoPassedToCreateTextWriter {
get { return createTextWriterInfoPassedToCreateTextWriter; }
set { createTextWriterInfoPassedToCreateTextWriter = value; }
}
public void DeleteFile(string fileName)
{
fileNameDeleted = fileName;
}
public string FileNameDeleted {
get { return fileNameDeleted; }
set { fileNameDeleted = value; }
}
}
}

33
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/RubySelectedTestsHelper.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 ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
using UnitTesting.Tests.Utils;
namespace RubyBinding.Tests.Utils
{
public static class RubySelectedTestsHelper
{
public static SelectedTests CreateSelectedTests(IProject project)
{
return new SelectedTests(project, null, null, null);
}
public static SelectedTests CreateSelectedTests(MockMethod method)
{
return new SelectedTests(method.MockDeclaringType.Project, null, method.MockDeclaringType, method);
}
public static SelectedTests CreateSelectedTests(MockClass c)
{
return new SelectedTests(c.Project, null, c, null);
}
}
}

50
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/Tests/AddInPathHelperTestFixture.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.Core;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
namespace RubyBinding.Tests.Utils.Tests
{
[TestFixture]
public class AddInPathHelperTestFixture
{
AddIn rubyAddIn;
[SetUp]
public void Init()
{
rubyAddIn = AddInPathHelper.CreateDummyRubyAddInInsideAddInTree();
}
[Test]
public void AddInFileNameIsCDriveSharpDevelopAddInsRubyBindingRubyBindingAddIn()
{
string expectedFileName = @"C:\SharpDevelop\AddIns\RubyBinding\RubyBinding.addin";
Assert.AreEqual(expectedFileName, rubyAddIn.FileName);
}
[Test]
public void StringParserAddInPathIsCDriveSharpDevelopAddInsRubyBindingForRubyBindingAddIn()
{
string directory = StringParser.Parse("${addinpath:ICSharpCode.RubyBinding}");
string expectedDirectory = @"C:\SharpDevelop\AddIns\RubyBinding";
Assert.AreEqual(expectedDirectory, directory);
}
[Test]
public void ChangingAddInFileNameReturnsExpectedFileNameFromStringParserAddInPath()
{
rubyAddIn.FileName = @"c:\def\pythonbinding.addin";
string expectedDirectory = @"c:\def";
string actualDirectory = StringParser.Parse("${addinpath:ICSharpCode.RubyBinding}");
Assert.AreEqual(expectedDirectory, actualDirectory);
}
}
}

65
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/Tests/MockRubyFileServiceTestFixture.cs

@ -0,0 +1,65 @@ @@ -0,0 +1,65 @@
// <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 System.Text;
using ICSharpCode.RubyBinding;
using NUnit.Framework;
namespace RubyBinding.Tests.Utils.Tests
{
[TestFixture]
public class MockRubyFileServiceTestFixture
{
MockRubyFileService fileService;
[SetUp]
public void Init()
{
fileService = new MockRubyFileService();
}
[Test]
public void GetTempFileNameReturnsReturnsTemporaryFileName()
{
string expectedFileName = @"c:\temp\tmp1.tmp";
fileService.SetTempFileName(expectedFileName);
string tempFileName = fileService.GetTempFileName();
Assert.AreEqual(expectedFileName, tempFileName);
}
[Test]
public void TextWriterReturnedFromCreateTextWriter()
{
using (StringWriter stringWriter = new StringWriter(new StringBuilder())) {
fileService.SetTextWriter(stringWriter);
CreateTextWriterInfo info = new CreateTextWriterInfo(@"test.tmp", Encoding.UTF8, true);
Assert.AreEqual(stringWriter, fileService.CreateTextWriter(info));
}
}
[Test]
public void CreateTextWriterInfoIsSavedWhenCreateTextWriterMethodIsCalled()
{
fileService.CreateTextWriterInfoPassedToCreateTextWriter = null;
CreateTextWriterInfo info = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true);
fileService.CreateTextWriter(info);
Assert.AreEqual(info, fileService.CreateTextWriterInfoPassedToCreateTextWriter);
}
[Test]
public void DeleteFileSavesFileNameDeleted()
{
fileService.FileNameDeleted = null;
string expectedFileName = @"c:\temp\tmp66.tmp";
fileService.DeleteFile(expectedFileName);
Assert.AreEqual(expectedFileName, fileService.FileNameDeleted);
}
}
}
Loading…
Cancel
Save