diff --git a/src/AddIns/Analysis/UnitTesting/Src/ITestResultsMonitor.cs b/src/AddIns/Analysis/UnitTesting/Src/ITestResultsMonitor.cs
index ebd4549db3..d4918a529b 100644
--- a/src/AddIns/Analysis/UnitTesting/Src/ITestResultsMonitor.cs
+++ b/src/AddIns/Analysis/UnitTesting/Src/ITestResultsMonitor.cs
@@ -18,5 +18,7 @@ namespace ICSharpCode.UnitTesting
void Stop();
void Start();
void Read();
+
+ long InitialFilePosition { get; set; }
}
}
diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestResultsMonitor.cs b/src/AddIns/Analysis/UnitTesting/Src/TestResultsMonitor.cs
index d29efc4396..365eb6ab38 100644
--- a/src/AddIns/Analysis/UnitTesting/Src/TestResultsMonitor.cs
+++ b/src/AddIns/Analysis/UnitTesting/Src/TestResultsMonitor.cs
@@ -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
ResetFilePosition();
}
+ public long InitialFilePosition {
+ get { return initialFilePosition; }
+ set { initialFilePosition = value; }
+ }
+
///
/// Gets or sets the test results filename.
///
@@ -169,7 +176,7 @@ namespace ICSharpCode.UnitTesting
void ResetFilePosition()
{
- filePosition = 3; // Use 3 to ignores UTF-8 preamble.
+ filePosition = initialFilePosition;
}
}
}
diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestResultsMonitor.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestResultsMonitor.cs
index 13e3e94890..663b8b7272 100644
--- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestResultsMonitor.cs
+++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestResultsMonitor.cs
@@ -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
public event TestFinishedEventHandler TestFinished;
+ public long InitialFilePosition {
+ get { return filePosition; }
+ set { filePosition = value; }
+ }
+
public bool IsStartMethodCalled {
get { return startMethodCalled; }
}
diff --git a/src/AddIns/Analysis/UnitTesting/UnitTesting.sln b/src/AddIns/Analysis/UnitTesting/UnitTesting.sln
index 67a98ff275..97695523c6 100644
--- a/src/AddIns/Analysis/UnitTesting/UnitTesting.sln
+++ b/src/AddIns/Analysis/UnitTesting/UnitTesting.sln
@@ -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",
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
{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
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding.sln b/src/AddIns/BackendBindings/Ruby/RubyBinding.sln
index b9d7cdca7b..c59bc1eb3b 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding.sln
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding.sln
@@ -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
{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
{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
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Resources/RubyOptionsPanel.xfrm b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Resources/RubyOptionsPanel.xfrm
index f23830ad7d..e2bec0ef05 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Resources/RubyOptionsPanel.xfrm
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Resources/RubyOptionsPanel.xfrm
@@ -7,25 +7,39 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
@@ -38,4 +52,4 @@
-
+
\ No newline at end of file
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/RubyBinding.addin b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/RubyBinding.addin
index 246e53d9ea..502c9a8a07 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/RubyBinding.addin
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/RubyBinding.addin
@@ -1,8 +1,8 @@
+ author = "Matt Ward"
+ copyright = "prj:///doc/copyright.txt"
+ description = "IronRuby addin"
+ addInManagerHidden = "preinstalled">
@@ -12,33 +12,34 @@
+
-
+ extensions=".rb"
+ name="Ruby"
+ resource="ICSharpCode.RubyBinding.Resources.Ruby.xshd"/>
+
+ insertbefore="Resources"
+ insertafter="Icons"
+ name="Ruby Files (*.rb)"
+ extensions="*.rb"/>
+ insertbefore="AllFiles"
+ name="Ruby Project Files (*.rbproj)"
+ class="ICSharpCode.SharpDevelop.Project.LoadProject"
+ extensions="*.rbproj"/>
@@ -50,27 +51,27 @@
@@ -79,24 +80,24 @@
+ supportedextensions=".rb"
+ projectfileextension=".rbproj"
+ class="ICSharpCode.RubyBinding.RubyParser"/>
+ guid="{BD8E9625-815A-4BDB-B228-5D4F9C2541A1}"
+ supportedextensions=".rb"
+ projectfileextension=".rbproj"
+ class="ICSharpCode.RubyBinding.RubyProjectBinding" />
+ extensions=".rb" />
@@ -109,24 +110,24 @@
+ label="Ruby"
+ class="ICSharpCode.RubyBinding.RubyOptionsPanel"/>
+ label="${res:Dialog.ProjectOptions.DebugOptions}"
+ class="ICSharpCode.SharpDevelop.Gui.OptionPanels.DebugOptions"/>
+ type="Secondary"
+ fileNamePattern="\.rb$"
+ languagePattern="^Ruby$"
+ class="ICSharpCode.RubyBinding.RubyFormsDesignerDisplayBinding" />
@@ -140,43 +141,49 @@
+ insertafter="CSharp"
+ insertbefore="VBNet"
+ label="Ruby"
+ class="ICSharpCode.RubyBinding.ConvertToRubyMenuCommand"/>
+ label="From C# to Ruby"
+ class="ICSharpCode.RubyBinding.ConvertProjectToRubyProjectCommand"/>
+ label="From VB.NET to Ruby"
+ class="ICSharpCode.RubyBinding.ConvertProjectToRubyProjectCommand"/>
+ category="Tools"
+ title="Ruby Console"
+ insertafter="Bookmarks"
+ insertbefore="DefinitionView"
+ icon="PadIcons.Output"
+ defaultPosition = "Bottom, Hidden"
+ class="ICSharpCode.RubyBinding.RubyConsolePad"/>
+ extensions=".rb"
+ resource="Ruby.ProjectBrowser.File" />
+ language="Ruby"
+ resource="Ruby.ProjectBrowser.Project" />
+
+
+
+
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/RubyBinding.csproj b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/RubyBinding.csproj
index 4d3c478113..895511f51a 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/RubyBinding.csproj
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/RubyBinding.csproj
@@ -83,7 +83,10 @@
+
+
+
@@ -109,6 +112,7 @@
+
@@ -120,6 +124,12 @@
+
+
+
+
+
+
@@ -154,8 +164,24 @@
Always
+
+ Always
+
+
+ Always
+
+
+ Always
+
+
+ Always
+
+
+ Always
+
+
@@ -184,6 +210,11 @@
ICSharpCode.SharpDevelop.Dom
False
+
+ {1F261725-6318-4434-A1B1-6C70CE4CD324}
+ UnitTesting
+ False
+
{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}
FormsDesigner
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/CreateTextWriterInfo.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/CreateTextWriterInfo.cs
new file mode 100644
index 0000000000..5bae55e9b8
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/CreateTextWriterInfo.cs
@@ -0,0 +1,65 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/IRubyFileService.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/IRubyFileService.cs
new file mode 100644
index 0000000000..56644946b6
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/IRubyFileService.cs
@@ -0,0 +1,20 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.IO;
+using System.Text;
+
+namespace ICSharpCode.RubyBinding
+{
+ public interface IRubyFileService
+ {
+ string GetTempFileName();
+ TextWriter CreateTextWriter(CreateTextWriterInfo createTextWriterInfo);
+ void DeleteFile(string fileName);
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyAddInOptions.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyAddInOptions.cs
index 240b62c5b3..8080672038 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyAddInOptions.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyAddInOptions.cs
@@ -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
{
this.properties = properties;
}
+
+ public string RubyLibraryPath {
+ get { return properties.Get(RubyLibraryPathProperty, String.Empty); }
+ set { properties.Set(RubyLibraryPathProperty, value.Trim()); }
+ }
+
+ public bool HasRubyLibraryPath {
+ get { return !String.IsNullOrEmpty(RubyLibraryPath); }
+ }
///
/// Gets or sets the ruby console filename.
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsoleApplication.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsoleApplication.cs
new file mode 100644
index 0000000000..cdb94308be
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyConsoleApplication.cs
@@ -0,0 +1,120 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text;
+
+namespace ICSharpCode.RubyBinding
+{
+ public class RubyConsoleApplication
+ {
+ string fileName;
+ bool debug;
+ List loadPaths = new List();
+ 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);
+ }
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyFileService.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyFileService.cs
new file mode 100644
index 0000000000..35a0a98221
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyFileService.cs
@@ -0,0 +1,31 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyOptionsPanel.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyOptionsPanel.cs
index 83a4ff1bd1..855bec4a6a 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyOptionsPanel.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyOptionsPanel.cs
@@ -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
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
public override bool StorePanelContents()
{
options.RubyFileName = rubyFileNameTextBox.Text;
+ options.RubyLibraryPath = rubyLibraryPathTextBox.Text;
return true;
}
}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestDebugger.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestDebugger.cs
new file mode 100644
index 0000000000..c00c4c789a
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestDebugger.cs
@@ -0,0 +1,71 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestFramework.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestFramework.cs
new file mode 100644
index 0000000000..e0995884ab
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestFramework.cs
@@ -0,0 +1,64 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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; }
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestResult.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestResult.cs
new file mode 100644
index 0000000000..d3ba41d74b
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestResult.cs
@@ -0,0 +1,69 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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;
+ }
+
+ ///
+ /// 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.
+ /// is not true.
+ ///
+ 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);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunner.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunner.cs
new file mode 100644
index 0000000000..178ef24d69
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunner.cs
@@ -0,0 +1,70 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunnerApplication.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunnerApplication.cs
new file mode 100644
index 0000000000..7842a23c5a
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunnerApplication.cs
@@ -0,0 +1,131 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunnerResponseFile.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunnerResponseFile.cs
new file mode 100644
index 0000000000..f03eab8501
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunnerResponseFile.cs
@@ -0,0 +1,83 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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 items)
+ {
+ foreach (ProjectItem item in items) {
+ FileProjectItem fileItem = item as FileProjectItem;
+ if (fileItem != null) {
+ WriteTestFileName(fileItem.FileName);
+ }
+ }
+ }
+
+ void WriteTestFileName(string testFileName)
+ {
+ writer.WriteLine(testFileName);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RunRubyCommand.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RunRubyCommand.cs
index f2c7b6ddf7..f14a27b006 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RunRubyCommand.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RunRubyCommand.cs
@@ -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);
+ }
}
}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdselectedtestsfile.rb b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdselectedtestsfile.rb
new file mode 100644
index 0000000000..fb24e8fa91
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdselectedtestsfile.rb
@@ -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
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtest.rb b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtest.rb
new file mode 100644
index 0000000000..2ed6ff6e33
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtest.rb
@@ -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
+
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtestresult.rb b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtestresult.rb
new file mode 100644
index 0000000000..feccb6948d
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtestresult.rb
@@ -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
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtestresultwriter.rb b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtestresultwriter.rb
new file mode 100644
index 0000000000..7fe72e75be
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtestresultwriter.rb
@@ -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
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtestrunner.rb b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtestrunner.rb
new file mode 100644
index 0000000000..47d76d18b1
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/TestRunner/sdtestrunner.rb
@@ -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
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Configuration/RubyAddInOptionsTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Configuration/RubyAddInOptionsTestFixture.cs
index 34be293efd..d3f85b0169 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Configuration/RubyAddInOptionsTestFixture.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Configuration/RubyAddInOptionsTestFixture.cs
@@ -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);
+ }
}
}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/FormsDesignerDisplayBindingTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/FormsDesignerDisplayBindingTestFixture.cs
index ded2faeb25..c6ccc33c46 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/FormsDesignerDisplayBindingTestFixture.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/FormsDesignerDisplayBindingTestFixture.cs
@@ -14,7 +14,7 @@ using ICSharpCode.SharpDevelop.Gui;
using NUnit.Framework;
using RubyBinding.Tests.Utils;
-namespace RubyBinding.Tests
+namespace RubyBinding.Tests.Designer
{
///
/// Tests the RubyFormsDesignerDisplayBinding.
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs
index 06d576c74d..2cb1d70536 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs
@@ -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
[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);
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/RubyDesignerGeneratorTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/RubyDesignerGeneratorTestFixture.cs
index d56e1d80c8..57fed3725c 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/RubyDesignerGeneratorTestFixture.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/RubyDesignerGeneratorTestFixture.cs
@@ -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
[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);
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/DebugRunRubyCommandTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/DebugRunRubyCommandTestFixture.cs
index b41d84aa86..40e75962c5 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/DebugRunRubyCommandTestFixture.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/DebugRunRubyCommandTestFixture.cs
@@ -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);
}
}
}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RubyOptionsPanelTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RubyOptionsPanelTestFixture.cs
index b40e8ad991..da718ce94e 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RubyOptionsPanelTestFixture.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RubyOptionsPanelTestFixture.cs
@@ -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
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
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
}
[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);
+ }
}
}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RunRubyCommandTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RunRubyCommandTestFixture.cs
index 56b9fcf05c..50dbd55dcc 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RunRubyCommandTestFixture.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/RunRubyCommandTestFixture.cs
@@ -59,22 +59,19 @@ namespace RubyBinding.Tests.Gui
}
[Test]
- public void ProcessInfoFileName()
+ public void ProcessInfoFileNameIsIronRubyConsole()
{
Assert.AreEqual(@"C:\IronRuby\ir.exe", debugger.ProcessStartInfo.FileName);
}
- ///
- /// The -1.9 parameter is used to enable Ruby 1.9 mode otherwise UTF8 files cannot be processed.
- ///
[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);
}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj
index 1cfa40ddd6..8d13444ed1 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj
@@ -317,8 +317,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -344,7 +357,6 @@
-
@@ -352,6 +364,7 @@
+
@@ -365,10 +378,13 @@
+
+
+
RubyBinding.addin
@@ -377,6 +393,7 @@
+
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}
@@ -402,6 +419,14 @@
{8035765F-D51F-4A0C-A746-2FD100E19419}
ICSharpCode.SharpDevelop.Widgets
+
+ {44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}
+ UnitTesting.Tests
+
+
+ {1F261725-6318-4434-A1B1-6C70CE4CD324}
+ UnitTesting
+
{0162E499-42D0-409B-AA25-EED21F75336B}
AvalonEdit.AddIn
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/CreateRubyTestRunnerTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/CreateRubyTestRunnerTestFixture.cs
new file mode 100644
index 0000000000..6692e81cf4
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/CreateRubyTestRunnerTestFixture.cs
@@ -0,0 +1,52 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/CreateTextWriterFromCreateTextWriterInfoTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/CreateTextWriterFromCreateTextWriterInfoTestFixture.cs
new file mode 100644
index 0000000000..10d11f7ed8
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/CreateTextWriterFromCreateTextWriterInfoTestFixture.cs
@@ -0,0 +1,41 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/CreateTextWriterInfoEqualsTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/CreateTextWriterInfoEqualsTestFixture.cs
new file mode 100644
index 0000000000..039456c2ee
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/CreateTextWriterInfoEqualsTestFixture.cs
@@ -0,0 +1,57 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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));
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyConsoleApplicationTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyConsoleApplicationTestFixture.cs
new file mode 100644
index 0000000000..c6351a23cb
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyConsoleApplicationTestFixture.cs
@@ -0,0 +1,95 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestDebuggerRunsSelectedTestMethodTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestDebuggerRunsSelectedTestMethodTestFixture.cs
new file mode 100644
index 0000000000..6122d6d77b
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestDebuggerRunsSelectedTestMethodTestFixture.cs
@@ -0,0 +1,149 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestFrameworkIsTestClassTests.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestFrameworkIsTestClassTests.cs
new file mode 100644
index 0000000000..8f522ae954
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestFrameworkIsTestClassTests.cs
@@ -0,0 +1,75 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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));
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestFrameworkIsTestMethodTests.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestFrameworkIsTestMethodTests.cs
new file mode 100644
index 0000000000..a36ab4d93d
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestFrameworkIsTestMethodTests.cs
@@ -0,0 +1,49 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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));
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestFrameworkIsTestProjectTests.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestFrameworkIsTestProjectTests.cs
new file mode 100644
index 0000000000..5aee8115ba
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestFrameworkIsTestProjectTests.cs
@@ -0,0 +1,66 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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));
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestResultFailureTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestResultFailureTestFixture.cs
new file mode 100644
index 0000000000..bf4c1e52f1
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestResultFailureTestFixture.cs
@@ -0,0 +1,94 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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" +
+ " 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);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerApplicationTests.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerApplicationTests.cs
new file mode 100644
index 0000000000..725e58c7de
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerApplicationTests.cs
@@ -0,0 +1,129 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerResponseFileTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerResponseFileTestFixture.cs
new file mode 100644
index 0000000000..cc4bf4e9a3
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerResponseFileTestFixture.cs
@@ -0,0 +1,115 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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(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());
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerRunsSelectedTestMethodTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerRunsSelectedTestMethodTestFixture.cs
new file mode 100644
index 0000000000..b8472c450f
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerRunsSelectedTestMethodTestFixture.cs
@@ -0,0 +1,200 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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(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);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/AddInPathHelper.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/AddInPathHelper.cs
new file mode 100644
index 0000000000..b3ae4a8434
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/AddInPathHelper.cs
@@ -0,0 +1,60 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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
+ "\r\n" +
+ " \r\n" +
+ " \r\n" +
+ " \r\n" +
+ "";
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockMethod.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockMethod.cs
deleted file mode 100644
index 92692cc82e..0000000000
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockMethod.cs
+++ /dev/null
@@ -1,297 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using ICSharpCode.SharpDevelop.Dom;
-
-namespace RubyBinding.Tests.Utils
-{
- ///
- /// Mock IMethod implementation.
- ///
- public class MockMethod : IMethod
- {
- public MockMethod()
- {
- }
-
- public DomRegion BodyRegion { get; set; }
-
- public IList TypeParameters {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsConstructor {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsOperator {
- get {
- throw new NotImplementedException();
- }
- }
-
- public IList HandlesClauses {
- get {
- throw new NotImplementedException();
- }
- }
-
- public IList 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 InterfaceImplementations {
- get {
- throw new NotImplementedException();
- }
- }
-
- public IClass DeclaringType {
- get {
- throw new NotImplementedException();
- }
- }
-
- public ModifierEnum Modifiers {
- get {
- throw new NotImplementedException();
- }
- }
-
- public IList 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; }
- }
- }
-}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockRubyFileService.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockRubyFileService.cs
new file mode 100644
index 0000000000..fd08a4c7ae
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockRubyFileService.cs
@@ -0,0 +1,58 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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; }
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/RubySelectedTestsHelper.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/RubySelectedTestsHelper.cs
new file mode 100644
index 0000000000..c6c24d6cb1
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/RubySelectedTestsHelper.cs
@@ -0,0 +1,33 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/Tests/AddInPathHelperTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/Tests/AddInPathHelperTestFixture.cs
new file mode 100644
index 0000000000..93047628bc
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/Tests/AddInPathHelperTestFixture.cs
@@ -0,0 +1,50 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/Tests/MockRubyFileServiceTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/Tests/MockRubyFileServiceTestFixture.cs
new file mode 100644
index 0000000000..83b994acaa
--- /dev/null
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/Tests/MockRubyFileServiceTestFixture.cs
@@ -0,0 +1,65 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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);
+ }
+ }
+}