Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6095 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61pull/1/head
52 changed files with 2686 additions and 401 deletions
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.RubyBinding |
||||
{ |
||||
public class CreateTextWriterInfo |
||||
{ |
||||
string fileName; |
||||
Encoding encoding; |
||||
bool append; |
||||
|
||||
public CreateTextWriterInfo(string fileName, Encoding encoding, bool append) |
||||
{ |
||||
this.fileName = fileName; |
||||
this.encoding = encoding; |
||||
this.append = append; |
||||
} |
||||
|
||||
public string FileName { |
||||
get { return fileName; } |
||||
} |
||||
|
||||
public Encoding Encoding { |
||||
get { return encoding; } |
||||
} |
||||
|
||||
public bool Append { |
||||
get { return append; } |
||||
} |
||||
|
||||
public override bool Equals(object obj) |
||||
{ |
||||
CreateTextWriterInfo rhs = obj as CreateTextWriterInfo; |
||||
if (rhs != null) { |
||||
return Equals(rhs); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
bool Equals(CreateTextWriterInfo rhs) |
||||
{ |
||||
return (fileName == rhs.fileName) && |
||||
(encoding == rhs.encoding) && |
||||
(append == rhs.append); |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
return base.GetHashCode(); |
||||
} |
||||
|
||||
public TextWriter CreateTextWriter() |
||||
{ |
||||
return new StreamWriter(fileName, append, encoding); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.RubyBinding |
||||
{ |
||||
public interface IRubyFileService |
||||
{ |
||||
string GetTempFileName(); |
||||
TextWriter CreateTextWriter(CreateTextWriterInfo createTextWriterInfo); |
||||
void DeleteFile(string fileName); |
||||
} |
||||
} |
@ -0,0 +1,120 @@
@@ -0,0 +1,120 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.RubyBinding |
||||
{ |
||||
public class RubyConsoleApplication |
||||
{ |
||||
string fileName; |
||||
bool debug; |
||||
List<string> loadPaths = new List<string>(); |
||||
string rubyScriptFileName = String.Empty; |
||||
string rubyScriptCommandLineArguments = String.Empty; |
||||
string workingDirectory = String.Empty; |
||||
string loadPath = String.Empty; |
||||
StringBuilder arguments; |
||||
|
||||
public RubyConsoleApplication(RubyAddInOptions options) |
||||
{ |
||||
this.fileName = options.RubyFileName; |
||||
} |
||||
|
||||
public string FileName { |
||||
get { return fileName; } |
||||
} |
||||
|
||||
public bool Debug { |
||||
get { return debug; } |
||||
set { debug = value; } |
||||
} |
||||
|
||||
public void AddLoadPath(string path) |
||||
{ |
||||
loadPaths.Add(path); |
||||
} |
||||
|
||||
public string RubyScriptFileName { |
||||
get { return rubyScriptFileName; } |
||||
set { rubyScriptFileName = value; } |
||||
} |
||||
|
||||
public string RubyScriptCommandLineArguments { |
||||
get { return rubyScriptCommandLineArguments; } |
||||
set { rubyScriptCommandLineArguments = value; } |
||||
} |
||||
|
||||
public string WorkingDirectory { |
||||
get { return workingDirectory; } |
||||
set { workingDirectory = value; } |
||||
} |
||||
|
||||
public ProcessStartInfo GetProcessStartInfo() |
||||
{ |
||||
ProcessStartInfo processStartInfo = new ProcessStartInfo(); |
||||
processStartInfo.FileName = fileName; |
||||
processStartInfo.Arguments = GetArguments(); |
||||
processStartInfo.WorkingDirectory = workingDirectory; |
||||
return processStartInfo; |
||||
} |
||||
|
||||
public string GetArguments() |
||||
{ |
||||
arguments = new StringBuilder(); |
||||
|
||||
AppendBooleanOptionIfTrue("-D", debug); |
||||
AppendLoadPaths(); |
||||
AppendQuotedStringIfNotEmpty(rubyScriptFileName); |
||||
AppendStringIfNotEmpty(rubyScriptCommandLineArguments); |
||||
|
||||
return arguments.ToString().TrimEnd(); |
||||
} |
||||
|
||||
void AppendBooleanOptionIfTrue(string option, bool flag) |
||||
{ |
||||
if (flag) { |
||||
AppendOption(option); |
||||
} |
||||
} |
||||
|
||||
void AppendOption(string option) |
||||
{ |
||||
arguments.Append(option + " "); |
||||
} |
||||
|
||||
void AppendLoadPaths() |
||||
{ |
||||
foreach (string path in loadPaths) { |
||||
AppendQuotedString("-I" + path); |
||||
} |
||||
} |
||||
|
||||
void AppendQuotedStringIfNotEmpty(string option) |
||||
{ |
||||
if (!String.IsNullOrEmpty(option)) { |
||||
AppendQuotedString(option); |
||||
} |
||||
} |
||||
|
||||
void AppendQuotedString(string option) |
||||
{ |
||||
string quotedOption = String.Format("\"{0}\"", option); |
||||
AppendOption(quotedOption); |
||||
} |
||||
|
||||
void AppendStringIfNotEmpty(string option) |
||||
{ |
||||
if (!String.IsNullOrEmpty(option)) { |
||||
AppendOption(option); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.RubyBinding |
||||
{ |
||||
public class RubyFileService : IRubyFileService |
||||
{ |
||||
public string GetTempFileName() |
||||
{ |
||||
return Path.GetTempFileName(); |
||||
} |
||||
|
||||
public TextWriter CreateTextWriter(CreateTextWriterInfo createTextWriterInfo) |
||||
{ |
||||
return createTextWriterInfo.CreateTextWriter(); |
||||
} |
||||
|
||||
public void DeleteFile(string fileName) |
||||
{ |
||||
File.Delete(fileName); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Diagnostics; |
||||
using ICSharpCode.Core.Services; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace ICSharpCode.RubyBinding |
||||
{ |
||||
public class RubyTestDebugger : TestDebuggerBase |
||||
{ |
||||
RubyAddInOptions options; |
||||
IRubyFileService fileService; |
||||
RubyTestRunnerApplication testRunnerApplication; |
||||
|
||||
public RubyTestDebugger() |
||||
: this(new UnitTestDebuggerService(), |
||||
ServiceManager.Instance.MessageService, |
||||
new TestResultsMonitor(), |
||||
new RubyAddInOptions(), |
||||
new RubyFileService()) |
||||
{ |
||||
} |
||||
|
||||
public RubyTestDebugger(IUnitTestDebuggerService debuggerService, |
||||
IMessageService messageService, |
||||
ITestResultsMonitor testResultsMonitor, |
||||
RubyAddInOptions options, |
||||
IRubyFileService fileService) |
||||
: base(debuggerService, messageService, testResultsMonitor) |
||||
{ |
||||
this.options = options; |
||||
this.fileService = fileService; |
||||
testResultsMonitor.InitialFilePosition = 0; |
||||
} |
||||
|
||||
public override void Start(SelectedTests selectedTests) |
||||
{ |
||||
CreateTestRunnerApplication(); |
||||
testRunnerApplication.CreateResponseFile(selectedTests); |
||||
base.Start(selectedTests); |
||||
} |
||||
|
||||
void CreateTestRunnerApplication() |
||||
{ |
||||
testRunnerApplication = new RubyTestRunnerApplication(base.TestResultsMonitor.FileName, options, fileService); |
||||
} |
||||
|
||||
protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests) |
||||
{ |
||||
testRunnerApplication.Debug = true; |
||||
return testRunnerApplication.CreateProcessStartInfo(selectedTests); |
||||
} |
||||
|
||||
public override void Dispose() |
||||
{ |
||||
testRunnerApplication.Dispose(); |
||||
base.Dispose(); |
||||
} |
||||
|
||||
protected override TestResult CreateTestResultForTestFramework(TestResult testResult) |
||||
{ |
||||
return new RubyTestResult(testResult); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace ICSharpCode.RubyBinding |
||||
{ |
||||
public class RubyTestFramework : ITestFramework |
||||
{ |
||||
public bool IsTestMethod(IMember member) |
||||
{ |
||||
if (member != null) { |
||||
return member.Name.StartsWith("test"); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public bool IsTestClass(IClass c) |
||||
{ |
||||
while (c != null) { |
||||
if (HasTestCaseBaseType(c)) { |
||||
return true; |
||||
} |
||||
c = c.BaseClass; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
bool HasTestCaseBaseType(IClass c) |
||||
{ |
||||
if (c.BaseTypes.Count > 0) { |
||||
string baseTypeName = c.BaseTypes[0].FullyQualifiedName; |
||||
return (baseTypeName == "Test.Unit.TestCase"); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public bool IsTestProject(IProject project) |
||||
{ |
||||
return project is RubyProject; |
||||
} |
||||
|
||||
public ITestRunner CreateTestRunner() |
||||
{ |
||||
return new RubyTestRunner(); |
||||
} |
||||
|
||||
public ITestRunner CreateTestDebugger() |
||||
{ |
||||
return new RubyTestDebugger(); |
||||
} |
||||
|
||||
public bool IsBuildNeededBeforeTestRun { |
||||
get { return false; } |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using System.Text.RegularExpressions; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace ICSharpCode.RubyBinding |
||||
{ |
||||
public class RubyTestResult : TestResult |
||||
{ |
||||
public RubyTestResult(TestResult testResult) |
||||
: base(testResult.Name) |
||||
{ |
||||
ResultType = testResult.ResultType; |
||||
Message = testResult.Message; |
||||
StackTrace = testResult.StackTrace; |
||||
} |
||||
|
||||
protected override void OnStackTraceChanged() |
||||
{ |
||||
if (String.IsNullOrEmpty(StackTrace)) { |
||||
ResetStackTraceFilePosition(); |
||||
} else { |
||||
GetFilePositionFromStackTrace(); |
||||
} |
||||
} |
||||
|
||||
void ResetStackTraceFilePosition() |
||||
{ |
||||
StackTraceFilePosition = FilePosition.Empty; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Stack trace: Failure:
|
||||
/// test_fail(SecondTests)
|
||||
/// [d:\temp\test\rubytests\SecondTests.rb:6:in `test_fail'
|
||||
/// d:\temp\test\rubytests/sdtestrunner.rb:73:in `start_mediator'
|
||||
/// d:\temp\test\rubytests/sdtestrunner.rb:47:in `start']:
|
||||
/// Assertion was false.
|
||||
/// <false> is not true.
|
||||
/// </summary>
|
||||
void GetFilePositionFromStackTrace() |
||||
{ |
||||
Match match = Regex.Match(StackTrace, "\\s\\[(.*?):(\\d+):", RegexOptions.Multiline); |
||||
if (match.Success) { |
||||
try { |
||||
SetStackTraceFilePosition(match.Groups); |
||||
} catch (OverflowException) { |
||||
// Ignore.
|
||||
} |
||||
} |
||||
} |
||||
|
||||
void SetStackTraceFilePosition(GroupCollection groups) |
||||
{ |
||||
string fileName = groups[1].Value; |
||||
int line = Convert.ToInt32(groups[2].Value); |
||||
int column = 1; |
||||
|
||||
StackTraceFilePosition = new FilePosition(fileName, line, column); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,70 @@
@@ -0,0 +1,70 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
using System.Text; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace ICSharpCode.RubyBinding |
||||
{ |
||||
public class RubyTestRunner : TestProcessRunnerBase |
||||
{ |
||||
RubyAddInOptions options; |
||||
IRubyFileService fileService; |
||||
RubyTestRunnerApplication testRunnerApplication; |
||||
|
||||
public RubyTestRunner() |
||||
: this(new UnitTestProcessRunner(), |
||||
new TestResultsMonitor(), |
||||
new RubyAddInOptions(), |
||||
new RubyFileService()) |
||||
{ |
||||
} |
||||
|
||||
public RubyTestRunner(IUnitTestProcessRunner processRunner, |
||||
ITestResultsMonitor testResultsMonitor, |
||||
RubyAddInOptions options, |
||||
IRubyFileService fileService) |
||||
: base(processRunner, testResultsMonitor) |
||||
{ |
||||
this.options = options; |
||||
this.fileService = fileService; |
||||
testResultsMonitor.InitialFilePosition = 0; |
||||
} |
||||
|
||||
public override void Start(SelectedTests selectedTests) |
||||
{ |
||||
CreateTestRunnerApplication(); |
||||
testRunnerApplication.CreateResponseFile(selectedTests); |
||||
base.Start(selectedTests); |
||||
} |
||||
|
||||
void CreateTestRunnerApplication() |
||||
{ |
||||
testRunnerApplication = new RubyTestRunnerApplication(base.TestResultsMonitor.FileName, options, fileService); |
||||
} |
||||
|
||||
protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests) |
||||
{ |
||||
return testRunnerApplication.CreateProcessStartInfo(selectedTests); |
||||
} |
||||
|
||||
public override void Dispose() |
||||
{ |
||||
testRunnerApplication.Dispose(); |
||||
base.Dispose(); |
||||
} |
||||
|
||||
protected override TestResult CreateTestResultForTestFramework(TestResult testResult) |
||||
{ |
||||
return new RubyTestResult(testResult); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,131 @@
@@ -0,0 +1,131 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
using System.Text; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace ICSharpCode.RubyBinding |
||||
{ |
||||
public class RubyTestRunnerApplication |
||||
{ |
||||
string testResultsFileName = String.Empty; |
||||
RubyAddInOptions options; |
||||
RubyTestRunnerResponseFile responseFile; |
||||
IRubyFileService fileService; |
||||
CreateTextWriterInfo textWriterInfo; |
||||
RubyConsoleApplication consoleApplication; |
||||
StringBuilder arguments; |
||||
|
||||
public RubyTestRunnerApplication(string testResultsFileName, |
||||
RubyAddInOptions options, |
||||
IRubyFileService fileService) |
||||
{ |
||||
this.testResultsFileName = testResultsFileName; |
||||
this.options = options; |
||||
this.fileService = fileService; |
||||
consoleApplication = new RubyConsoleApplication(options); |
||||
} |
||||
|
||||
public bool Debug { |
||||
get { return consoleApplication.Debug; } |
||||
set { consoleApplication.Debug = value; } |
||||
} |
||||
|
||||
public void CreateResponseFile(SelectedTests selectedTests) |
||||
{ |
||||
CreateResponseFile(); |
||||
using (responseFile) { |
||||
WriteTests(selectedTests); |
||||
} |
||||
} |
||||
|
||||
void CreateResponseFile() |
||||
{ |
||||
TextWriter writer = CreateTextWriter(); |
||||
responseFile = new RubyTestRunnerResponseFile(writer); |
||||
} |
||||
|
||||
TextWriter CreateTextWriter() |
||||
{ |
||||
string fileName = fileService.GetTempFileName(); |
||||
textWriterInfo = new CreateTextWriterInfo(fileName, Encoding.ASCII, false); |
||||
return fileService.CreateTextWriter(textWriterInfo); |
||||
} |
||||
|
||||
void WriteTests(SelectedTests selectedTests) |
||||
{ |
||||
responseFile.WriteTests(selectedTests); |
||||
} |
||||
|
||||
public ProcessStartInfo CreateProcessStartInfo(SelectedTests selectedTests) |
||||
{ |
||||
consoleApplication.RubyScriptFileName = GetSharpDevelopTestRubyScriptFileName(); |
||||
AddLoadPaths(); |
||||
consoleApplication.RubyScriptCommandLineArguments = GetCommandLineArguments(selectedTests); |
||||
consoleApplication.WorkingDirectory = selectedTests.Project.Directory; |
||||
return consoleApplication.GetProcessStartInfo(); |
||||
} |
||||
|
||||
void AddLoadPaths() |
||||
{ |
||||
if (options.HasRubyLibraryPath) { |
||||
consoleApplication.AddLoadPath(options.RubyLibraryPath); |
||||
} |
||||
string testRunnerLoadPath = Path.GetDirectoryName(consoleApplication.RubyScriptFileName); |
||||
consoleApplication.AddLoadPath(testRunnerLoadPath); |
||||
} |
||||
|
||||
string GetSharpDevelopTestRubyScriptFileName() |
||||
{ |
||||
string fileName = StringParser.Parse(@"${addinpath:ICSharpCode.RubyBinding}\TestRunner\sdtest.rb"); |
||||
return Path.GetFullPath(fileName); |
||||
} |
||||
|
||||
string GetCommandLineArguments(SelectedTests selectedTests) |
||||
{ |
||||
arguments = new StringBuilder(); |
||||
AppendSelectedTest(selectedTests); |
||||
AppendTestResultsFileNameAndResponseFileNameArgs(); |
||||
|
||||
return arguments.ToString(); |
||||
} |
||||
|
||||
void AppendSelectedTest(SelectedTests selectedTests) |
||||
{ |
||||
if (selectedTests.Method != null) { |
||||
AppendSelectedTestMethod(selectedTests.Method); |
||||
} else if (selectedTests.Class != null) { |
||||
AppendSelectedTestClass(selectedTests.Class); |
||||
} |
||||
} |
||||
|
||||
void AppendSelectedTestMethod(IMember method) |
||||
{ |
||||
arguments.AppendFormat("--name={0} ", method.Name); |
||||
} |
||||
|
||||
void AppendSelectedTestClass(IClass c) |
||||
{ |
||||
arguments.AppendFormat("--testcase={0} ", c.FullyQualifiedName); |
||||
} |
||||
|
||||
void AppendTestResultsFileNameAndResponseFileNameArgs() |
||||
{ |
||||
arguments.AppendFormat("-- \"{0}\" \"{1}\"", testResultsFileName, textWriterInfo.FileName); |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
fileService.DeleteFile(textWriterInfo.FileName); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.ObjectModel; |
||||
using System.IO; |
||||
using System.Text; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace ICSharpCode.RubyBinding |
||||
{ |
||||
public class RubyTestRunnerResponseFile : IDisposable |
||||
{ |
||||
TextWriter writer; |
||||
|
||||
public RubyTestRunnerResponseFile(string fileName) |
||||
: this(new StreamWriter(fileName, false, Encoding.ASCII)) |
||||
{ |
||||
} |
||||
|
||||
public RubyTestRunnerResponseFile(TextWriter writer) |
||||
{ |
||||
this.writer = writer; |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
writer.Dispose(); |
||||
} |
||||
|
||||
public void WriteTests(SelectedTests selectedTests) |
||||
{ |
||||
if (selectedTests.Method != null) { |
||||
WriteTestFileNameForMethod(selectedTests.Method); |
||||
} else if (selectedTests.Class != null) { |
||||
WriteTestFileNameForClass(selectedTests.Class); |
||||
} else if (selectedTests.Project != null) { |
||||
WriteTestsForProject(selectedTests.Project); |
||||
} |
||||
} |
||||
|
||||
void WriteTestFileNameForMethod(IMember method) |
||||
{ |
||||
WriteTestFileNameForCompilationUnit(method.CompilationUnit); |
||||
} |
||||
|
||||
void WriteTestFileNameForClass(IClass c) |
||||
{ |
||||
WriteTestFileNameForCompilationUnit(c.CompilationUnit); |
||||
} |
||||
|
||||
void WriteTestFileNameForCompilationUnit(ICompilationUnit unit) |
||||
{ |
||||
WriteTestFileName(unit.FileName); |
||||
} |
||||
|
||||
void WriteTestsForProject(IProject project) |
||||
{ |
||||
WriteTestsForProjectFileItems(project.Items); |
||||
} |
||||
|
||||
void WriteTestsForProjectFileItems(ReadOnlyCollection<ProjectItem> items) |
||||
{ |
||||
foreach (ProjectItem item in items) { |
||||
FileProjectItem fileItem = item as FileProjectItem; |
||||
if (fileItem != null) { |
||||
WriteTestFileName(fileItem.FileName); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void WriteTestFileName(string testFileName) |
||||
{ |
||||
writer.WriteLine(testFileName); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
|
||||
module Test |
||||
module Unit |
||||
module UI |
||||
module SharpDevelopConsole |
||||
|
||||
class SharpDevelopSelectedTestsFile |
||||
|
||||
def initialize(filename) |
||||
@tests = [] |
||||
read_tests(filename) |
||||
end |
||||
|
||||
def read_tests(filename) |
||||
File.open(filename).each {|line| |
||||
line = line.strip |
||||
if line.length > 0 then |
||||
@tests.push(line) |
||||
end |
||||
} |
||||
end |
||||
|
||||
def tests |
||||
return @tests |
||||
end |
||||
|
||||
end |
||||
|
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
|
||||
require 'test/unit' |
||||
require 'test/unit/autorunner' |
||||
require 'sdselectedtestsfile' |
||||
|
||||
Test::Unit.run = false |
||||
|
||||
Test::Unit::AutoRunner::RUNNERS[:console] = |
||||
proc do |r| |
||||
require 'sdtestrunner' |
||||
Test::Unit::UI::SharpDevelopConsole::TestRunner |
||||
end |
||||
|
||||
standalone = true |
||||
runner = Test::Unit::AutoRunner.new(standalone) |
||||
runner.process_args(ARGV) |
||||
|
||||
# Add files to run tests on. |
||||
selected_tests_filename = ARGV.last |
||||
print "selected_tests_filename: " + selected_tests_filename |
||||
selected_tests_file = Test::Unit::UI::SharpDevelopConsole::SharpDevelopSelectedTestsFile.new(selected_tests_filename) |
||||
selected_tests_file.tests.each {|filename| |
||||
runner.to_run.push(filename) |
||||
} |
||||
|
||||
runner.run |
||||
|
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
|
||||
module Test |
||||
module Unit |
||||
module UI |
||||
module SharpDevelopConsole |
||||
|
||||
class SharpDevelopTestResult |
||||
|
||||
def initialize(name) |
||||
@name = parse_name(name) |
||||
@result = 'Success' |
||||
@message = '' |
||||
@stacktrace = '' |
||||
end |
||||
|
||||
def parse_name(name) |
||||
@name = name |
||||
open_bracket_index = name.index('(') |
||||
if open_bracket_index > 0 then |
||||
close_bracket_index = name.index(')', open_bracket_index) |
||||
if close_bracket_index > 0 then |
||||
length = close_bracket_index - open_bracket_index - 1 |
||||
method_name = name[0, open_bracket_index] |
||||
class_name = name[open_bracket_index + 1, length] |
||||
@name = class_name + '.' + method_name |
||||
end |
||||
end |
||||
end |
||||
|
||||
def name |
||||
return @name |
||||
end |
||||
|
||||
def result |
||||
return @result |
||||
end |
||||
|
||||
def message |
||||
return @message |
||||
end |
||||
|
||||
def stacktrace |
||||
return @stacktrace |
||||
end |
||||
|
||||
def update_fault(fault) |
||||
@result = 'Failure' |
||||
@message = format_text(fault.message) |
||||
@stacktrace = format_text(fault.long_display) |
||||
end |
||||
|
||||
def format_text(text) |
||||
formatted_text = '' |
||||
text.each_line do |line| |
||||
formatted_text += " " + line |
||||
end |
||||
return formatted_text[1..-1] |
||||
end |
||||
end |
||||
|
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
|
||||
require 'sdtestresult' |
||||
|
||||
module Test |
||||
module Unit |
||||
module UI |
||||
module SharpDevelopConsole |
||||
|
||||
class SharpDevelopTestResultWriter |
||||
|
||||
def initialize(filename) |
||||
@file = File.open(filename, 'w') |
||||
end |
||||
|
||||
def write_test_result(test_result) |
||||
writeline("Name: " + test_result.name) |
||||
writeline("Result: " + test_result.result) |
||||
writeline("Message: " + test_result.message) |
||||
writeline("StackTrace: " + test_result.stacktrace) |
||||
end |
||||
|
||||
def writeline(message) |
||||
@file.write(message + "\r\n") |
||||
@file.flush |
||||
end |
||||
end |
||||
|
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,145 @@
@@ -0,0 +1,145 @@
|
||||
#-- |
||||
# |
||||
# Author:: Nathaniel Talbott. |
||||
# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved. |
||||
# License:: Ruby license. |
||||
# |
||||
# Extended to support SharpDevelop |
||||
|
||||
require 'test/unit/ui/testrunnermediator' |
||||
require 'test/unit/ui/testrunnerutilities' |
||||
require 'sdtestresultwriter' |
||||
require 'sdtestresult' |
||||
|
||||
module Test |
||||
module Unit |
||||
module UI |
||||
module SharpDevelopConsole |
||||
|
||||
# Runs a Test::Unit::TestSuite on the console. |
||||
class TestRunner |
||||
extend TestRunnerUtilities |
||||
|
||||
# Creates a new TestRunner for running the passed |
||||
# suite. If quiet_mode is true, the output while |
||||
# running is limited to progress dots, errors and |
||||
# failures, and the final result. io specifies |
||||
# where runner output should go to; defaults to |
||||
# STDOUT. |
||||
def initialize(suite, output_level=NORMAL, io=STDOUT) |
||||
if (suite.respond_to?(:suite)) |
||||
@suite = suite.suite |
||||
else |
||||
@suite = suite |
||||
end |
||||
@output_level = output_level |
||||
@io = io |
||||
@already_outputted = false |
||||
@faults = [] |
||||
|
||||
resultsfile = ARGV[0] |
||||
@test_result_writer = SharpDevelopTestResultWriter.new(resultsfile) |
||||
end |
||||
|
||||
# Begins the test run. |
||||
def start |
||||
setup_mediator |
||||
attach_to_mediator |
||||
return start_mediator |
||||
end |
||||
|
||||
private |
||||
def setup_mediator |
||||
@mediator = create_mediator(@suite) |
||||
suite_name = @suite.to_s |
||||
if ( @suite.kind_of?(Module) ) |
||||
suite_name = @suite.name |
||||
end |
||||
output("Loaded suite #{suite_name}") |
||||
end |
||||
|
||||
def create_mediator(suite) |
||||
return TestRunnerMediator.new(suite) |
||||
end |
||||
|
||||
def attach_to_mediator |
||||
@mediator.add_listener(TestResult::FAULT, &method(:add_fault)) |
||||
@mediator.add_listener(TestRunnerMediator::STARTED, &method(:started)) |
||||
@mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished)) |
||||
@mediator.add_listener(TestCase::STARTED, &method(:test_started)) |
||||
@mediator.add_listener(TestCase::FINISHED, &method(:test_finished)) |
||||
end |
||||
|
||||
def start_mediator |
||||
return @mediator.run_suite |
||||
end |
||||
|
||||
def add_fault(fault) |
||||
@test_result.update_fault(fault) |
||||
@faults << fault |
||||
output_single(fault.single_character_display, PROGRESS_ONLY) |
||||
@already_outputted = true |
||||
end |
||||
|
||||
def started(result) |
||||
@result = result |
||||
output("Started") |
||||
end |
||||
|
||||
def finished(elapsed_time) |
||||
nl |
||||
output("Finished in #{elapsed_time} seconds.") |
||||
@faults.each_with_index do |fault, index| |
||||
nl |
||||
output("%3d) %s" % [index + 1, fault.long_display]) |
||||
end |
||||
nl |
||||
output(@result) |
||||
end |
||||
|
||||
def test_started(name) |
||||
create_test_result(name) |
||||
output_single(name + ": ", VERBOSE) |
||||
end |
||||
|
||||
def create_test_result(name) |
||||
@test_result = SharpDevelopTestResult.new(name) |
||||
end |
||||
|
||||
def test_finished(name) |
||||
write_test_result() |
||||
output_single(".", PROGRESS_ONLY) unless (@already_outputted) |
||||
nl(VERBOSE) |
||||
@already_outputted = false |
||||
end |
||||
|
||||
def nl(level=NORMAL) |
||||
output("", level) |
||||
end |
||||
|
||||
def output(something, level=NORMAL) |
||||
@io.puts(something) if (output?(level)) |
||||
@io.flush |
||||
end |
||||
|
||||
def output_single(something, level=NORMAL) |
||||
@io.write(something) if (output?(level)) |
||||
@io.flush |
||||
end |
||||
|
||||
def output?(level) |
||||
level <= @output_level |
||||
end |
||||
|
||||
def write_test_result() |
||||
@test_result_writer.write_test_result(@test_result) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
|
||||
if __FILE__ == $0 |
||||
Test::Unit::UI::SharpDevelopConsole::TestRunner.start_command_line_test |
||||
end |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.RubyBinding; |
||||
using NUnit.Framework; |
||||
|
||||
namespace RubyBinding.Tests.Testing |
||||
{ |
||||
[TestFixture] |
||||
public class CreateRubyTestRunnerTestFixture |
||||
{ |
||||
RubyTestFramework testFramework; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
if (!PropertyService.Initialized) { |
||||
PropertyService.InitializeService(String.Empty, String.Empty, String.Empty); |
||||
} |
||||
} |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
testFramework = new RubyTestFramework(); |
||||
} |
||||
|
||||
[Test] |
||||
public void RubyTestFrameworkCreateTestRunnerReturnsRubyTestRunner() |
||||
{ |
||||
Assert.IsInstanceOf(typeof(RubyTestRunner), testFramework.CreateTestRunner()); |
||||
} |
||||
|
||||
[Test] |
||||
public void RubyTestFrameworkCreateTestDebuggerReturnsRubyTestDebugger() |
||||
{ |
||||
Assert.IsInstanceOf(typeof(RubyTestDebugger), testFramework.CreateTestDebugger()); |
||||
} |
||||
|
||||
[Test] |
||||
public void RubyTestFrameworkIsBuildNeededBeforeTestRunReturnsFalse() |
||||
{ |
||||
Assert.IsFalse(testFramework.IsBuildNeededBeforeTestRun); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Text; |
||||
using ICSharpCode.RubyBinding; |
||||
using NUnit.Framework; |
||||
|
||||
namespace RubyBinding.Tests.Testing |
||||
{ |
||||
[TestFixture] |
||||
public class CreateTextWriterFromCreateTextWriterInfoTestFixture |
||||
{ |
||||
TextWriter textWriter; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
string fileName = Path.GetTempFileName(); |
||||
CreateTextWriterInfo info = new CreateTextWriterInfo(fileName, Encoding.UTF8, false); |
||||
textWriter = info.CreateTextWriter(); |
||||
} |
||||
|
||||
[TestFixtureTearDown] |
||||
public void TearDownFixture() |
||||
{ |
||||
textWriter.Dispose(); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreatedTextWriterEncodingIsUtf8() |
||||
{ |
||||
Assert.AreEqual(Encoding.UTF8, textWriter.Encoding); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Text; |
||||
using ICSharpCode.RubyBinding; |
||||
using NUnit.Framework; |
||||
|
||||
namespace RubyBinding.Tests.Testing |
||||
{ |
||||
[TestFixture] |
||||
public class CreateTextWriterInfoEqualsTestFixture |
||||
{ |
||||
[Test] |
||||
public void CreateTextWriterInfosAreEqualWhenFileNameAndEncodingAndAppendAreEqual() |
||||
{ |
||||
CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true); |
||||
CreateTextWriterInfo rhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true); |
||||
Assert.AreEqual(lhs, rhs); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateTextWriterInfosAreNotEqualWhenFileNamesAreDifferent() |
||||
{ |
||||
CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true); |
||||
CreateTextWriterInfo rhs = new CreateTextWriterInfo("different-filename.txt", Encoding.UTF8, true); |
||||
Assert.AreNotEqual(lhs, rhs); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateTextWriterInfosAreNotEqualWhenEncodingsAreDifferent() |
||||
{ |
||||
CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true); |
||||
CreateTextWriterInfo rhs = new CreateTextWriterInfo("test.txt", Encoding.ASCII, true); |
||||
Assert.AreNotEqual(lhs, rhs); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateTextWriterInfosAreNotEqualWhenAppendIsDifferent() |
||||
{ |
||||
CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true); |
||||
CreateTextWriterInfo rhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, false); |
||||
Assert.AreNotEqual(lhs, rhs); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateTextWriterInfoEqualsReturnsFalseWhenNullPassedAsParameter() |
||||
{ |
||||
CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true); |
||||
Assert.IsFalse(lhs.Equals(null)); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,95 @@
@@ -0,0 +1,95 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Diagnostics; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.RubyBinding; |
||||
using NUnit.Framework; |
||||
using RubyBinding.Tests.Utils; |
||||
|
||||
namespace RubyBinding.Tests.Testing |
||||
{ |
||||
[TestFixture] |
||||
public class RubyConsoleApplicationTestFixture |
||||
{ |
||||
RubyConsoleApplication app; |
||||
RubyAddInOptions options; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
options = new RubyAddInOptions(new Properties()); |
||||
options.RubyFileName = @"C:\IronRuby\ir.exe"; |
||||
app = new RubyConsoleApplication(options); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileNameIsRubyFileNameFromAddInOptions() |
||||
{ |
||||
string expectedFileName = @"C:\IronRuby\ir.exe"; |
||||
Assert.AreEqual(expectedFileName, app.FileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetArgumentsReturnsDebugOptionWhenDebugIsTrue() |
||||
{ |
||||
app.Debug = true; |
||||
string expectedCommandLine = "-D"; |
||||
|
||||
Assert.AreEqual(expectedCommandLine, app.GetArguments()); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetArgumentsReturnsQuotedRubyScriptFileName() |
||||
{ |
||||
app.RubyScriptFileName = @"d:\projects\my ruby\test.rb"; |
||||
string expectedCommandLine = "\"d:\\projects\\my ruby\\test.rb\""; |
||||
|
||||
Assert.AreEqual(expectedCommandLine, app.GetArguments()); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetArgumentsReturnsQuotedRubyScriptFileNameAndItsCommandLineArguments() |
||||
{ |
||||
app.Debug = true; |
||||
app.RubyScriptFileName = @"d:\projects\my ruby\test.rb"; |
||||
app.RubyScriptCommandLineArguments = "-- responseFile.txt"; |
||||
string expectedCommandLine = |
||||
"-D \"d:\\projects\\my ruby\\test.rb\" -- responseFile.txt"; |
||||
|
||||
Assert.AreEqual(expectedCommandLine, app.GetArguments()); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetProcessStartInfoHasFileNameThatEqualsIronRubyConsoleApplicationExeFileName() |
||||
{ |
||||
ProcessStartInfo startInfo = app.GetProcessStartInfo(); |
||||
string expectedFileName = @"C:\IronRuby\ir.exe"; |
||||
|
||||
Assert.AreEqual(expectedFileName, startInfo.FileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetProcessStartInfoHasDebugFlagSetInArguments() |
||||
{ |
||||
app.Debug = true; |
||||
ProcessStartInfo startInfo = app.GetProcessStartInfo(); |
||||
string expectedCommandLine = "-D"; |
||||
|
||||
Assert.AreEqual(expectedCommandLine, startInfo.Arguments); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetProcessStartInfoHasWorkingDirectoryIfSet() |
||||
{ |
||||
app.WorkingDirectory = @"d:\temp"; |
||||
ProcessStartInfo startInfo = app.GetProcessStartInfo(); |
||||
Assert.AreEqual(@"d:\temp", startInfo.WorkingDirectory); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,149 @@
@@ -0,0 +1,149 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
using System.Text; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.RubyBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
using RubyBinding.Tests.Utils; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace RubyBinding.Tests.Testing |
||||
{ |
||||
[TestFixture] |
||||
public class RubyTestDebuggerRunsSelectedTestMethodTestFixture |
||||
{ |
||||
MockDebuggerService debuggerService; |
||||
UnitTesting.Tests.Utils.MockDebugger debugger; |
||||
MockMessageService messageService; |
||||
MockCSharpProject project; |
||||
RubyTestDebugger testDebugger; |
||||
MockTestResultsMonitor testResultsMonitor; |
||||
SelectedTests selectedTests; |
||||
MockMethod methodToTest; |
||||
RubyAddInOptions options; |
||||
MockRubyFileService fileService; |
||||
StringBuilder responseFileText; |
||||
StringWriter responseFileStringWriter; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
CreateTestDebugger(); |
||||
CreateTestMethod(); |
||||
} |
||||
|
||||
void CreateTestDebugger() |
||||
{ |
||||
debuggerService = new MockDebuggerService(); |
||||
debugger = debuggerService.MockDebugger; |
||||
messageService = new MockMessageService(); |
||||
testResultsMonitor = new MockTestResultsMonitor(); |
||||
testResultsMonitor.InitialFilePosition = 3; |
||||
options = new RubyAddInOptions(new Properties()); |
||||
options.RubyFileName = @"c:\ironruby\ir.exe"; |
||||
fileService = new MockRubyFileService(); |
||||
testDebugger = new RubyTestDebugger(debuggerService, messageService, testResultsMonitor, options, fileService); |
||||
} |
||||
|
||||
void CreateTestMethod() |
||||
{ |
||||
project = new MockCSharpProject(); |
||||
MockClass c = new MockClass("MyNamespace.MyTestClass"); |
||||
methodToTest = new MockMethod(c, "MyTestMethod"); |
||||
} |
||||
|
||||
void RunTestsOnSelectedTestMethod() |
||||
{ |
||||
fileService.SetTempFileName(@"d:\temp\tmp66.tmp"); |
||||
CreateTemporaryResponseFileWriter(); |
||||
|
||||
selectedTests = new SelectedTests(project, null, null, methodToTest); |
||||
testDebugger.Start(selectedTests); |
||||
} |
||||
|
||||
void CreateTemporaryResponseFileWriter() |
||||
{ |
||||
responseFileText = new StringBuilder(); |
||||
responseFileStringWriter = new StringWriter(responseFileText); |
||||
fileService.SetTextWriter(responseFileStringWriter); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestDebuggerProcessFileNameIsIronRubyConsoleExeTakenFromAddInOptions() |
||||
{ |
||||
RunTestsOnSelectedTestMethod(); |
||||
|
||||
string expectedFileName = @"c:\ironruby\ir.exe"; |
||||
Assert.AreEqual(expectedFileName, debugger.ProcessStartInfo.FileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void DisposingTestRunnerDeletesTemporaryResponseFile() |
||||
{ |
||||
fileService.FileNameDeleted = null; |
||||
RunTestsOnSelectedTestMethod(); |
||||
testDebugger.Dispose(); |
||||
|
||||
string expectedFileName = @"d:\temp\tmp66.tmp"; |
||||
Assert.AreEqual(expectedFileName, fileService.FileNameDeleted); |
||||
} |
||||
|
||||
[Test] |
||||
public void DisposingTestRunnerDisposesTestResultsMonitor() |
||||
{ |
||||
RunTestsOnSelectedTestMethod(); |
||||
testDebugger.Dispose(); |
||||
Assert.IsTrue(testResultsMonitor.IsDisposeMethodCalled); |
||||
} |
||||
|
||||
[Test] |
||||
public void CommandLineArgumentHasSharpDevelopTestRubyScriptFileNameAndTestResultsFileNameResponseFileName() |
||||
{ |
||||
AddIn addin = AddInPathHelper.CreateDummyRubyAddInInsideAddInTree(); |
||||
addin.FileName = @"c:\sharpdevelop\addins\rubybinding\rubybinding.addin"; |
||||
|
||||
testResultsMonitor.FileName = @"d:\testresults.txt"; |
||||
RunTestsOnSelectedTestMethod(); |
||||
|
||||
string expectedCommandLine = |
||||
"-D " + |
||||
"\"-Ic:\\sharpdevelop\\addins\\rubybinding\\TestRunner\" " + |
||||
"\"c:\\sharpdevelop\\addins\\rubybinding\\TestRunner\\sdtest.rb\" " + |
||||
"--name=MyTestMethod " + |
||||
"-- " + |
||||
"\"d:\\testresults.txt\" " + |
||||
"\"d:\\temp\\tmp66.tmp\""; |
||||
|
||||
Assert.AreEqual(expectedCommandLine, debugger.ProcessStartInfo.Arguments); |
||||
} |
||||
|
||||
[Test] |
||||
public void RubyTestResultReturnedFromTestFinishedEvent() |
||||
{ |
||||
TestResult testResult = null; |
||||
testDebugger.TestFinished += delegate(object source, TestFinishedEventArgs e) { |
||||
testResult = e.Result; |
||||
}; |
||||
TestResult testResultToFire = new TestResult("test"); |
||||
testResultsMonitor.FireTestFinishedEvent(testResultToFire); |
||||
|
||||
Assert.IsInstanceOf(typeof(RubyTestResult), testResult); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestResultsMonitorInitialFilePositionIsZero() |
||||
{ |
||||
Assert.AreEqual(0, testResultsMonitor.InitialFilePosition); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.RubyBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using RubyBinding.Tests.Utils; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace RubyBinding.Tests.Testing |
||||
{ |
||||
[TestFixture] |
||||
public class RubyTestFrameworkIsTestClassTests |
||||
{ |
||||
RubyTestFramework testFramework; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
testFramework = new RubyTestFramework(); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateClassWithTestUnitTestCaseBaseTypeReturnsClassWithFirstBaseTypeEqualToTestCase() |
||||
{ |
||||
IClass c = MockClass.CreateClassWithBaseType("Test.Unit.TestCase"); |
||||
string name = c.BaseTypes[0].FullyQualifiedName; |
||||
string expectedName = "Test.Unit.TestCase"; |
||||
Assert.AreEqual(expectedName, name); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestClassReturnsTrueWhenClassFirstBaseTypeIsUnitTestTestCase() |
||||
{ |
||||
MockClass c = MockClass.CreateClassWithBaseType("Test.Unit.TestCase"); |
||||
Assert.IsTrue(testFramework.IsTestClass(c)); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestClassReturnsFalseWhenClassHasNoBaseTypes() |
||||
{ |
||||
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); |
||||
Assert.IsFalse(testFramework.IsTestClass(c)); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestClassReturnsFalseForNull() |
||||
{ |
||||
Assert.IsFalse(testFramework.IsTestClass(null)); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestClassReturnsFalseWhenFirstBaseTypeIsSystemWindowsFormsForm() |
||||
{ |
||||
MockClass c = MockClass.CreateClassWithBaseType("System.Windows.Forms.Form"); |
||||
Assert.IsFalse(testFramework.IsTestClass(c)); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestClassReturnsTrueWhenDerivedClassHasBaseClassDerivedFromTestCase() |
||||
{ |
||||
MockClass baseClass = MockClass.CreateClassWithBaseType("Test.Unit.TestCase"); |
||||
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); |
||||
DefaultReturnType returnType = new DefaultReturnType(baseClass); |
||||
c.BaseTypes.Add(returnType); |
||||
|
||||
Assert.IsTrue(testFramework.IsTestClass(c)); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.RubyBinding; |
||||
using NUnit.Framework; |
||||
using RubyBinding.Tests.Utils; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace RubyBinding.Tests.Testing |
||||
{ |
||||
[TestFixture] |
||||
public class RubyTestFrameworkIsTestMethodTests |
||||
{ |
||||
RubyTestFramework testFramework; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
testFramework = new RubyTestFramework(); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestMethodReturnsTrueForMethodThatStartsWithTest() |
||||
{ |
||||
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); |
||||
MockMethod method = new MockMethod(c, "testRunThis"); |
||||
Assert.IsTrue(testFramework.IsTestMethod(method)); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestMethodReturnsFalseForNull() |
||||
{ |
||||
Assert.IsFalse(testFramework.IsTestMethod(null)); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestMethodReturnsFalseForMethodThatDoesNotStartWithTest() |
||||
{ |
||||
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); |
||||
MockMethod method = new MockMethod(c, "RunThis"); |
||||
Assert.IsFalse(testFramework.IsTestMethod(method)); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,66 @@
@@ -0,0 +1,66 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.RubyBinding; |
||||
using ICSharpCode.SharpDevelop.Internal.Templates; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using NUnit.Framework; |
||||
using RubyBinding.Tests.Utils; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace RubyBinding.Tests.Testing |
||||
{ |
||||
[TestFixture] |
||||
public class RubyTestFrameworkIsTestProjectTests |
||||
{ |
||||
RubyTestFramework testFramework; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
MSBuildEngineHelper.InitMSBuildEngine(); |
||||
} |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
testFramework = new RubyTestFramework(); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestProjectWhenPassedNullProjectReturnsFalse() |
||||
{ |
||||
Assert.IsFalse(testFramework.IsTestProject(null)); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestProjectWhenPassedRubyPythonProjectReturnsTrue() |
||||
{ |
||||
ProjectCreateInformation createInfo = new ProjectCreateInformation(); |
||||
createInfo.Solution = new Solution(); |
||||
createInfo.OutputProjectFileName = @"C:\projects\test.rbproj"; |
||||
RubyProject project = new RubyProject(createInfo); |
||||
|
||||
Assert.IsTrue(testFramework.IsTestProject(project)); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestProjectWhenPassedNonPythonProjectReturnsFalse() |
||||
{ |
||||
MockProject project = new MockProject(); |
||||
Assert.IsFalse(testFramework.IsTestProject(project)); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestProjectWhenPassedNullRubyProjectReturnsFalse() |
||||
{ |
||||
RubyProject project = null; |
||||
Assert.IsFalse(testFramework.IsTestProject(project)); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,94 @@
@@ -0,0 +1,94 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.RubyBinding; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
|
||||
namespace RubyBinding.Tests.Testing |
||||
{ |
||||
[TestFixture] |
||||
public class RubyTestResultFailureTestFixture |
||||
{ |
||||
RubyTestResult RubyTestResult; |
||||
string stackTraceText; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
TestResult testResult = new TestResult("MyTest"); |
||||
testResult.ResultType = TestResultType.Failure; |
||||
testResult.Message = "test failed"; |
||||
|
||||
stackTraceText = |
||||
"Failure:\r\n" + |
||||
"test_fail(SecondTests)\r\n" + |
||||
" [d:\\projects\\rubytests\\SecondTests.rb:6:in `test_fail'\r\n" + |
||||
" d:\\test\\rubytests/sdtestrunner.rb:73:in `start_mediator'\r\n" + |
||||
" d:\\test\\rubytests/sdtestrunner.rb:47:in `start']:\r\n" + |
||||
"Assertion was false.\r\n" + |
||||
"<false> is not true.\r\n" + |
||||
""; |
||||
|
||||
testResult.StackTrace = stackTraceText; |
||||
RubyTestResult = new RubyTestResult(testResult); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestResultNameIsMyTest() |
||||
{ |
||||
Assert.AreEqual("MyTest", RubyTestResult.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestResultTypeIsFailure() |
||||
{ |
||||
Assert.AreEqual(TestResultType.Failure, RubyTestResult.ResultType); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestResultMessageIsTestFailed() |
||||
{ |
||||
Assert.AreEqual("test failed", RubyTestResult.Message); |
||||
} |
||||
|
||||
[Test] |
||||
public void RubyTestResultHasStackTraceFromOriginalTestResult() |
||||
{ |
||||
Assert.AreEqual(stackTraceText, RubyTestResult.StackTrace); |
||||
} |
||||
|
||||
[Test] |
||||
public void StackTraceFilePositionHasExpectedFileName() |
||||
{ |
||||
string expectedFileName = @"d:\projects\rubytests\SecondTests.rb"; |
||||
Assert.AreEqual(expectedFileName, RubyTestResult.StackTraceFilePosition.FileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void StackTraceFilePositionLineIs6() |
||||
{ |
||||
Assert.AreEqual(6, RubyTestResult.StackTraceFilePosition.Line); |
||||
} |
||||
|
||||
[Test] |
||||
public void StackTraceFilePositionColumnIsOne() |
||||
{ |
||||
Assert.AreEqual(1, RubyTestResult.StackTraceFilePosition.Column); |
||||
} |
||||
|
||||
[Test] |
||||
public void ChangingStackTraceToEmptyStringSetsStackTraceFilePositionToEmpty() |
||||
{ |
||||
RubyTestResult.StackTraceFilePosition = new FilePosition("test.rb", 10, 2); |
||||
RubyTestResult.StackTrace = String.Empty; |
||||
Assert.IsTrue(RubyTestResult.StackTraceFilePosition.IsEmpty); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,129 @@
@@ -0,0 +1,129 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Diagnostics; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.RubyBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
using RubyBinding.Tests.Testing; |
||||
using RubyBinding.Tests.Utils; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace RubyBinding.Tests.Testing |
||||
{ |
||||
[TestFixture] |
||||
public class RubyTestRunnerApplicationTests |
||||
{ |
||||
RubyTestRunnerApplication testRunner; |
||||
RubyAddInOptions options; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
string tempFileName = "temp.tmp"; |
||||
MockRubyFileService fileService = new MockRubyFileService(); |
||||
fileService.SetTempFileName(tempFileName); |
||||
fileService.SetTextWriter(new StringWriter()); |
||||
|
||||
Properties properties = new Properties(); |
||||
options = new RubyAddInOptions(properties); |
||||
|
||||
AddIn addin = AddInPathHelper.CreateDummyRubyAddInInsideAddInTree(); |
||||
addin.FileName = @"c:\rubybinding\rubybinding.addin"; |
||||
|
||||
string testResultsFileName = "results.txt"; |
||||
testRunner = new RubyTestRunnerApplication(testResultsFileName, options, fileService); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateProcessInfoReturnsCommandLineWithTestClassOption() |
||||
{ |
||||
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); |
||||
c.FullyQualifiedName = "MyTests"; |
||||
SelectedTests selectedTests = RubySelectedTestsHelper.CreateSelectedTests(c); |
||||
ProcessStartInfo processStartInfo = GetProcessStartInfoFromTestRunnerApp(selectedTests); |
||||
|
||||
string expectedCommandLine = |
||||
"\"-Ic:\\rubybinding\\TestRunner\" " + |
||||
"\"c:\\rubybinding\\TestRunner\\sdtest.rb\" " + |
||||
"--testcase=MyTests " + |
||||
"-- " + |
||||
"\"results.txt\" " + |
||||
"\"temp.tmp\""; |
||||
|
||||
Assert.AreEqual(expectedCommandLine, processStartInfo.Arguments); |
||||
} |
||||
|
||||
ProcessStartInfo GetProcessStartInfoFromTestRunnerApp(SelectedTests selectedTests) |
||||
{ |
||||
testRunner.CreateResponseFile(selectedTests); |
||||
return testRunner.CreateProcessStartInfo(selectedTests); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateProcessInfoReturnsCommandLineWithTestMethodOption() |
||||
{ |
||||
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); |
||||
MockMethod method = new MockMethod(c, "MyMethod"); |
||||
SelectedTests selectedTests = RubySelectedTestsHelper.CreateSelectedTests(method); |
||||
ProcessStartInfo processStartInfo = GetProcessStartInfoFromTestRunnerApp(selectedTests); |
||||
|
||||
string expectedCommandLine = |
||||
"\"-Ic:\\rubybinding\\TestRunner\" " + |
||||
"\"c:\\rubybinding\\TestRunner\\sdtest.rb\" " + |
||||
"--name=MyMethod " + |
||||
"-- " + |
||||
"\"results.txt\" " + |
||||
"\"temp.tmp\""; |
||||
|
||||
Assert.AreEqual(expectedCommandLine, processStartInfo.Arguments); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateProcessInfoReturnsFixedTestRunnerFilePath() |
||||
{ |
||||
AddIn addin = AddInPathHelper.CreateDummyRubyAddInInsideAddInTree(); |
||||
addin.FileName = @"c:\rubybinding\bin\..\AddIns\rubybinding.addin"; |
||||
|
||||
MockCSharpProject project = new MockCSharpProject(); |
||||
SelectedTests selectedTests = RubySelectedTestsHelper.CreateSelectedTests(project); |
||||
ProcessStartInfo processStartInfo = GetProcessStartInfoFromTestRunnerApp(selectedTests); |
||||
|
||||
string expectedCommandLine = |
||||
"\"-Ic:\\rubybinding\\AddIns\\TestRunner\" " + |
||||
"\"c:\\rubybinding\\AddIns\\TestRunner\\sdtest.rb\" " + |
||||
"-- " + |
||||
"\"results.txt\" " + |
||||
"\"temp.tmp\""; |
||||
|
||||
Assert.AreEqual(expectedCommandLine, processStartInfo.Arguments); |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateProcessInfoReturnsCommandLineWithLoadPathSpecifiedInRubyAddInOptions() |
||||
{ |
||||
MockCSharpProject project = new MockCSharpProject(); |
||||
options.RubyLibraryPath = @"c:\ruby\lib"; |
||||
SelectedTests selectedTests = RubySelectedTestsHelper.CreateSelectedTests(project); |
||||
ProcessStartInfo processStartInfo = GetProcessStartInfoFromTestRunnerApp(selectedTests); |
||||
|
||||
string expectedCommandLine = |
||||
"\"-Ic:\\ruby\\lib\" " + |
||||
"\"-Ic:\\rubybinding\\TestRunner\" " + |
||||
"\"c:\\rubybinding\\TestRunner\\sdtest.rb\" " + |
||||
"-- " + |
||||
"\"results.txt\" " + |
||||
"\"temp.tmp\""; |
||||
|
||||
Assert.AreEqual(expectedCommandLine, processStartInfo.Arguments); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,115 @@
@@ -0,0 +1,115 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Text; |
||||
using ICSharpCode.Core.Services; |
||||
using ICSharpCode.RubyBinding; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
using RubyBinding.Tests.Utils; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace RubyBinding.Tests.Testing |
||||
{ |
||||
[TestFixture] |
||||
public class RubyTestRunnerResponseFileTestFixture |
||||
{ |
||||
RubyTestRunnerResponseFile responseFile; |
||||
StringBuilder responseFileText; |
||||
StringWriter writer; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
responseFileText = new StringBuilder(); |
||||
writer = new StringWriter(responseFileText); |
||||
responseFile = new RubyTestRunnerResponseFile(writer); |
||||
} |
||||
|
||||
[Test] |
||||
public void DisposeMethodDisposesTextWriterPassedInConstructor() |
||||
{ |
||||
responseFile.Dispose(); |
||||
Assert.Throws<ObjectDisposedException>(delegate { writer.WriteLine("test"); }); |
||||
} |
||||
|
||||
[Test] |
||||
public void WriteTestsAddsTestClassFileNameToResponseFile() |
||||
{ |
||||
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); |
||||
c.CompilationUnit.FileName = @"d:\mytest.rb"; |
||||
SelectedTests selectedTests = RubySelectedTestsHelper.CreateSelectedTests(c); |
||||
responseFile.WriteTests(selectedTests); |
||||
|
||||
string expectedText = "d:\\mytest.rb\r\n"; |
||||
Assert.AreEqual(expectedText, responseFileText.ToString()); |
||||
} |
||||
|
||||
[Test] |
||||
public void WriteTestsAddsTestMethodFileNameToResponseFile() |
||||
{ |
||||
MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); |
||||
MockMethod method = new MockMethod(c, "MyTest"); |
||||
method.CompilationUnit.FileName = @"d:\mytest.rb"; |
||||
SelectedTests selectedTests = RubySelectedTestsHelper.CreateSelectedTests(method); |
||||
responseFile.WriteTests(selectedTests); |
||||
|
||||
string expectedText = "d:\\mytest.rb\r\n"; |
||||
Assert.AreEqual(expectedText, responseFileText.ToString()); |
||||
} |
||||
|
||||
[Test] |
||||
public void WriteTestsAddsFileNamesForFileInProject() |
||||
{ |
||||
MockCSharpProject project = new MockCSharpProject(new Solution(), "mytests"); |
||||
|
||||
FileProjectItem item = new FileProjectItem(project, ItemType.Compile); |
||||
item.FileName = @"c:\projects\mytests\myTests.rb"; |
||||
ProjectService.AddProjectItem(project, item); |
||||
|
||||
SelectedTests selectedTests = RubySelectedTestsHelper.CreateSelectedTests(project); |
||||
responseFile.WriteTests(selectedTests); |
||||
|
||||
string expectedText = "c:\\projects\\mytests\\myTests.rb\r\n"; |
||||
Assert.AreEqual(expectedText, responseFileText.ToString()); |
||||
} |
||||
|
||||
[Test] |
||||
public void WriteTestsDoesNotThrowNullReferenceExceptionWhenNonFileProjectItemInProject() |
||||
{ |
||||
MockCSharpProject project = new MockCSharpProject(new Solution(), "mytests"); |
||||
WebReferenceUrl webRef = new WebReferenceUrl(project); |
||||
webRef.Include = "test"; |
||||
ProjectService.AddProjectItem(project, webRef); |
||||
|
||||
FileProjectItem item = new FileProjectItem(project, ItemType.Compile); |
||||
item.FileName = @"c:\projects\mytests\myTests.rb"; |
||||
ProjectService.AddProjectItem(project, item); |
||||
|
||||
SelectedTests tests = new SelectedTests(project); |
||||
responseFile.WriteTests(tests); |
||||
|
||||
string expectedText = "c:\\projects\\mytests\\myTests.rb\r\n"; |
||||
Assert.AreEqual(expectedText, responseFileText.ToString()); |
||||
} |
||||
|
||||
[Test] |
||||
public void WriteTestsDoesNotThrowNullReferenceExceptionWhenProjectIsNull() |
||||
{ |
||||
SelectedTests tests = new SelectedTests(null); |
||||
responseFile.WriteTests(tests); |
||||
|
||||
Assert.AreEqual(String.Empty, responseFileText.ToString()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,200 @@
@@ -0,0 +1,200 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
using System.Text; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.RubyBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
using RubyBinding.Tests.Utils; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace RubyBinding.Tests.Testing |
||||
{ |
||||
[TestFixture] |
||||
public class RubyTestRunnerRunsSelectedTestMethodTestFixture |
||||
{ |
||||
MockCSharpProject project; |
||||
RubyTestRunner testRunner; |
||||
MockProcessRunner processRunner; |
||||
MockTestResultsMonitor testResultsMonitor; |
||||
SelectedTests selectedTests; |
||||
MockMethod methodToTest; |
||||
RubyAddInOptions options; |
||||
MockRubyFileService fileService; |
||||
StringBuilder responseFileText; |
||||
StringWriter responseFileStringWriter; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
CreateTestRunner(); |
||||
CreateTestMethod(); |
||||
} |
||||
|
||||
void CreateTestRunner() |
||||
{ |
||||
processRunner = new MockProcessRunner(); |
||||
testResultsMonitor = new MockTestResultsMonitor(); |
||||
testResultsMonitor.InitialFilePosition = 3; |
||||
options = new RubyAddInOptions(new Properties()); |
||||
options.RubyFileName = @"c:\ironruby\ir.exe"; |
||||
fileService = new MockRubyFileService(); |
||||
|
||||
testRunner = new RubyTestRunner(processRunner, testResultsMonitor, options, fileService); |
||||
} |
||||
|
||||
void CreateTestMethod() |
||||
{ |
||||
project = new MockCSharpProject(); |
||||
MockClass c = new MockClass("MyNamespace.MyTestClass"); |
||||
methodToTest = new MockMethod(c, "MyTestMethod"); |
||||
} |
||||
|
||||
void RunTestsOnSelectedTestMethod() |
||||
{ |
||||
fileService.SetTempFileName(@"d:\temp\tmp66.tmp"); |
||||
CreateTemporaryResponseFileWriter(); |
||||
|
||||
selectedTests = new SelectedTests(project, null, null, methodToTest); |
||||
testRunner.Start(selectedTests); |
||||
} |
||||
|
||||
void CreateTemporaryResponseFileWriter() |
||||
{ |
||||
responseFileText = new StringBuilder(); |
||||
responseFileStringWriter = new StringWriter(responseFileText); |
||||
fileService.SetTextWriter(responseFileStringWriter); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestRunnerProcessFileNameIsIronRubyConsoleExeTakenFromAddInOptions() |
||||
{ |
||||
RunTestsOnSelectedTestMethod(); |
||||
|
||||
string expectedFileName = @"c:\ironruby\ir.exe"; |
||||
Assert.AreEqual(expectedFileName, processRunner.CommandPassedToStartMethod); |
||||
} |
||||
|
||||
[Test] |
||||
public void CommandLineArgumentHasSharpDevelopTestRubyScriptFileNameAndTestResultsFileNameAndResponseFileName() |
||||
{ |
||||
AddIn addin = AddInPathHelper.CreateDummyRubyAddInInsideAddInTree(); |
||||
addin.FileName = @"c:\sharpdevelop\addins\rubybinding\rubybinding.addin"; |
||||
|
||||
testResultsMonitor.FileName = @"d:\testresults.txt"; |
||||
RunTestsOnSelectedTestMethod(); |
||||
|
||||
string expectedCommandLine = |
||||
"\"-Ic:\\sharpdevelop\\addins\\rubybinding\\TestRunner\" " + |
||||
"\"c:\\sharpdevelop\\addins\\rubybinding\\TestRunner\\sdtest.rb\" " + |
||||
"--name=MyTestMethod " + |
||||
"-- " + |
||||
"\"d:\\testresults.txt\" " + |
||||
"\"d:\\temp\\tmp66.tmp\""; |
||||
|
||||
Assert.AreEqual(expectedCommandLine, processRunner.CommandArgumentsPassedToStartMethod); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResponseFileCreatedUsingTempFileName() |
||||
{ |
||||
RunTestsOnSelectedTestMethod(); |
||||
|
||||
Assert.AreEqual(@"d:\temp\tmp66.tmp", fileService.CreateTextWriterInfoPassedToCreateTextWriter.FileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResponseFileCreatedWithAsciiEncoding() |
||||
{ |
||||
RunTestsOnSelectedTestMethod(); |
||||
|
||||
Assert.AreEqual(Encoding.ASCII, fileService.CreateTextWriterInfoPassedToCreateTextWriter.Encoding); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResponseFileCreatedWithAppendSetToFalse() |
||||
{ |
||||
RunTestsOnSelectedTestMethod(); |
||||
|
||||
Assert.IsFalse(fileService.CreateTextWriterInfoPassedToCreateTextWriter.Append); |
||||
} |
||||
|
||||
[Test] |
||||
public void DisposingTestRunnerDeletesTemporaryResponseFile() |
||||
{ |
||||
fileService.FileNameDeleted = null; |
||||
RunTestsOnSelectedTestMethod(); |
||||
testRunner.Dispose(); |
||||
|
||||
string expectedFileName = @"d:\temp\tmp66.tmp"; |
||||
Assert.AreEqual(expectedFileName, fileService.FileNameDeleted); |
||||
} |
||||
|
||||
[Test] |
||||
public void DisposingTestRunnerDisposesTestResultsMonitor() |
||||
{ |
||||
RunTestsOnSelectedTestMethod(); |
||||
testRunner.Dispose(); |
||||
Assert.IsTrue(testResultsMonitor.IsDisposeMethodCalled); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResponseFileTextContainsTestMethodFileName() |
||||
{ |
||||
methodToTest.CompilationUnit.FileName = @"d:\projects\ruby\test.rb"; |
||||
RunTestsOnSelectedTestMethod(); |
||||
|
||||
string expectedText = |
||||
"d:\\projects\\ruby\\test.rb\r\n"; |
||||
|
||||
Assert.AreEqual(expectedText, responseFileText.ToString()); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResponseFileTextWriterDisposedAfterTestsRun() |
||||
{ |
||||
RunTestsOnSelectedTestMethod(); |
||||
Assert.Throws<ObjectDisposedException>(delegate { responseFileStringWriter.Write("test"); }); |
||||
} |
||||
|
||||
[Test] |
||||
public void ProcessRunnerWorkingDirectoryIsDirectoryContainingProject() |
||||
{ |
||||
RunTestsOnSelectedTestMethod(); |
||||
|
||||
string expectedDirectory = @"c:\projects\MyTests"; |
||||
string actualDirectory = processRunner.WorkingDirectory; |
||||
|
||||
Assert.AreEqual(expectedDirectory, actualDirectory); |
||||
} |
||||
|
||||
[Test] |
||||
public void RubyTestResultReturnedFromTestFinishedEvent() |
||||
{ |
||||
TestResult testResult = null; |
||||
testRunner.TestFinished += delegate(object source, TestFinishedEventArgs e) { |
||||
testResult = e.Result; |
||||
}; |
||||
TestResult testResultToFire = new TestResult("test"); |
||||
testResultsMonitor.FireTestFinishedEvent(testResultToFire); |
||||
|
||||
Assert.IsInstanceOf(typeof(RubyTestResult), testResult); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestResultsMonitorInitialFilePositionIsZero() |
||||
{ |
||||
Assert.AreEqual(0, testResultsMonitor.InitialFilePosition); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace RubyBinding.Tests.Utils |
||||
{ |
||||
public static class AddInPathHelper |
||||
{ |
||||
public static AddIn CreateDummyRubyAddInInsideAddInTree() |
||||
{ |
||||
RemoveOldAddIn(); |
||||
AddIn addin = CreateAddIn(); |
||||
AddInTree.InsertAddIn(addin); |
||||
return addin; |
||||
} |
||||
|
||||
static void RemoveOldAddIn() |
||||
{ |
||||
AddIn oldAddin = FindOldAddIn(); |
||||
if (oldAddin != null) { |
||||
AddInTree.RemoveAddIn(oldAddin); |
||||
} |
||||
} |
||||
|
||||
static AddIn FindOldAddIn() |
||||
{ |
||||
foreach (AddIn addin in AddInTree.AddIns) { |
||||
if (addin.Manifest.PrimaryIdentity == "ICSharpCode.RubyBinding") { |
||||
return addin; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
static AddIn CreateAddIn() |
||||
{ |
||||
string xml = GetAddInXml(); |
||||
AddIn addin = AddIn.Load(new StringReader(xml)); |
||||
addin.FileName = @"C:\SharpDevelop\AddIns\RubyBinding\RubyBinding.addin"; |
||||
return addin; |
||||
} |
||||
|
||||
static string GetAddInXml() |
||||
{ |
||||
return |
||||
"<AddIn name='RubyBinding' author= '' copyright='' description=''>\r\n" + |
||||
" <Manifest>\r\n" + |
||||
" <Identity name='ICSharpCode.RubyBinding'/>\r\n" + |
||||
" </Manifest>\r\n" + |
||||
"</AddIn>"; |
||||
} |
||||
} |
||||
} |
@ -1,297 +0,0 @@
@@ -1,297 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace RubyBinding.Tests.Utils |
||||
{ |
||||
/// <summary>
|
||||
/// Mock IMethod implementation.
|
||||
/// </summary>
|
||||
public class MockMethod : IMethod |
||||
{ |
||||
public MockMethod() |
||||
{ |
||||
} |
||||
|
||||
public DomRegion BodyRegion { get; set; } |
||||
|
||||
public IList<ITypeParameter> TypeParameters { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsConstructor { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsOperator { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public IList<string> HandlesClauses { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public IList<IParameter> Parameters { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsExtensionMethod { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public string FullyQualifiedName { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public IReturnType DeclaringTypeReference { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
set { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public IMember GenericMember { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public DomRegion Region { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public string Name { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public string Namespace { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public string DotNetName { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public IReturnType ReturnType { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
set { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public IList<ExplicitInterfaceImplementation> InterfaceImplementations { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public IClass DeclaringType { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public ModifierEnum Modifiers { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public IList<IAttribute> Attributes { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public string Documentation { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsAbstract { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsSealed { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsStatic { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsConst { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsVirtual { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsPublic { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsProtected { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsPrivate { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsInternal { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsReadonly { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsProtectedAndInternal { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsProtectedOrInternal { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsOverride { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsOverridable { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsNew { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsSynthetic { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public object UserData { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
set { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsFrozen { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public IMember CreateSpecializedMember() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public bool IsAccessible(IClass callingClass, bool isClassInInheritanceTree) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void Freeze() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public int CompareTo(object obj) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public object Clone() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public ICompilationUnit CompilationUnit { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public IProjectContent ProjectContent { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public EntityType EntityType { |
||||
get { return EntityType.Method; } |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Text; |
||||
using ICSharpCode.RubyBinding; |
||||
|
||||
namespace RubyBinding.Tests.Utils |
||||
{ |
||||
public class MockRubyFileService : IRubyFileService |
||||
{ |
||||
CreateTextWriterInfo createTextWriterInfoPassedToCreateTextWriter; |
||||
string tempFileName; |
||||
TextWriter textWriter; |
||||
string fileNameDeleted; |
||||
|
||||
public void SetTempFileName(string fileName) |
||||
{ |
||||
this.tempFileName = fileName; |
||||
} |
||||
|
||||
public string GetTempFileName() |
||||
{ |
||||
return tempFileName; |
||||
} |
||||
|
||||
public void SetTextWriter(TextWriter writer) |
||||
{ |
||||
this.textWriter = writer; |
||||
} |
||||
|
||||
public TextWriter CreateTextWriter(CreateTextWriterInfo textWriterInfo) |
||||
{ |
||||
createTextWriterInfoPassedToCreateTextWriter = textWriterInfo; |
||||
return textWriter; |
||||
} |
||||
|
||||
public CreateTextWriterInfo CreateTextWriterInfoPassedToCreateTextWriter { |
||||
get { return createTextWriterInfoPassedToCreateTextWriter; } |
||||
set { createTextWriterInfoPassedToCreateTextWriter = value; } |
||||
} |
||||
|
||||
public void DeleteFile(string fileName) |
||||
{ |
||||
fileNameDeleted = fileName; |
||||
} |
||||
|
||||
public string FileNameDeleted { |
||||
get { return fileNameDeleted; } |
||||
set { fileNameDeleted = value; } |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.RubyBinding; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.UnitTesting; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace RubyBinding.Tests.Utils |
||||
{ |
||||
public static class RubySelectedTestsHelper |
||||
{ |
||||
public static SelectedTests CreateSelectedTests(IProject project) |
||||
{ |
||||
return new SelectedTests(project, null, null, null); |
||||
} |
||||
|
||||
public static SelectedTests CreateSelectedTests(MockMethod method) |
||||
{ |
||||
return new SelectedTests(method.MockDeclaringType.Project, null, method.MockDeclaringType, method); |
||||
} |
||||
|
||||
public static SelectedTests CreateSelectedTests(MockClass c) |
||||
{ |
||||
return new SelectedTests(c.Project, null, c, null); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
using NUnit.Framework; |
||||
using RubyBinding.Tests.Utils; |
||||
|
||||
namespace RubyBinding.Tests.Utils.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class AddInPathHelperTestFixture |
||||
{ |
||||
AddIn rubyAddIn; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
rubyAddIn = AddInPathHelper.CreateDummyRubyAddInInsideAddInTree(); |
||||
} |
||||
|
||||
[Test] |
||||
public void AddInFileNameIsCDriveSharpDevelopAddInsRubyBindingRubyBindingAddIn() |
||||
{ |
||||
string expectedFileName = @"C:\SharpDevelop\AddIns\RubyBinding\RubyBinding.addin"; |
||||
Assert.AreEqual(expectedFileName, rubyAddIn.FileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void StringParserAddInPathIsCDriveSharpDevelopAddInsRubyBindingForRubyBindingAddIn() |
||||
{ |
||||
string directory = StringParser.Parse("${addinpath:ICSharpCode.RubyBinding}"); |
||||
string expectedDirectory = @"C:\SharpDevelop\AddIns\RubyBinding"; |
||||
Assert.AreEqual(expectedDirectory, directory); |
||||
} |
||||
|
||||
[Test] |
||||
public void ChangingAddInFileNameReturnsExpectedFileNameFromStringParserAddInPath() |
||||
{ |
||||
rubyAddIn.FileName = @"c:\def\pythonbinding.addin"; |
||||
string expectedDirectory = @"c:\def"; |
||||
string actualDirectory = StringParser.Parse("${addinpath:ICSharpCode.RubyBinding}"); |
||||
Assert.AreEqual(expectedDirectory, actualDirectory); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Text; |
||||
using ICSharpCode.RubyBinding; |
||||
using NUnit.Framework; |
||||
|
||||
namespace RubyBinding.Tests.Utils.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class MockRubyFileServiceTestFixture |
||||
{ |
||||
MockRubyFileService fileService; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
fileService = new MockRubyFileService(); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetTempFileNameReturnsReturnsTemporaryFileName() |
||||
{ |
||||
string expectedFileName = @"c:\temp\tmp1.tmp"; |
||||
fileService.SetTempFileName(expectedFileName); |
||||
string tempFileName = fileService.GetTempFileName(); |
||||
Assert.AreEqual(expectedFileName, tempFileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void TextWriterReturnedFromCreateTextWriter() |
||||
{ |
||||
using (StringWriter stringWriter = new StringWriter(new StringBuilder())) { |
||||
fileService.SetTextWriter(stringWriter); |
||||
CreateTextWriterInfo info = new CreateTextWriterInfo(@"test.tmp", Encoding.UTF8, true); |
||||
Assert.AreEqual(stringWriter, fileService.CreateTextWriter(info)); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void CreateTextWriterInfoIsSavedWhenCreateTextWriterMethodIsCalled() |
||||
{ |
||||
fileService.CreateTextWriterInfoPassedToCreateTextWriter = null; |
||||
CreateTextWriterInfo info = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true); |
||||
fileService.CreateTextWriter(info); |
||||
Assert.AreEqual(info, fileService.CreateTextWriterInfoPassedToCreateTextWriter); |
||||
} |
||||
|
||||
[Test] |
||||
public void DeleteFileSavesFileNameDeleted() |
||||
{ |
||||
fileService.FileNameDeleted = null; |
||||
string expectedFileName = @"c:\temp\tmp66.tmp"; |
||||
fileService.DeleteFile(expectedFileName); |
||||
|
||||
Assert.AreEqual(expectedFileName, fileService.FileNameDeleted); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue