Browse Source

Show better error message when test runner application cannot be found.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6424 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Matt Ward 16 years ago
parent
commit
cf7a257e20
  1. 6
      data/resources/StringResources.fr.resx
  2. 6
      data/resources/StringResources.nl.resx
  3. 3
      data/resources/StringResources.resx
  4. 1
      src/AddIns/Analysis/CodeCoverage/Project/CodeCoverage.csproj
  5. 16
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageTestRunner.cs
  6. 44
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageTestRunnerContext.cs
  7. 3
      src/AddIns/Analysis/CodeCoverage/Project/Src/IFileSystem.cs
  8. 4
      src/AddIns/Analysis/CodeCoverage/Test/Testing/CodeCoverageTestRunnerTests.cs
  9. 9
      src/AddIns/Analysis/CodeCoverage/Test/Testing/RunTestWithCodeCoverageCommandTests.cs
  10. 5
      src/AddIns/Analysis/CodeCoverage/Test/Utils/DerivedCodeCoverageTestRunner.cs
  11. 8
      src/AddIns/Analysis/CodeCoverage/Test/Utils/MockCodeCoverageTestRunnerFactory.cs
  12. 16
      src/AddIns/Analysis/UnitTesting/Src/IFileSystem.cs
  13. 2
      src/AddIns/Analysis/UnitTesting/Src/IRunTestCommandContext.cs
  14. 3
      src/AddIns/Analysis/UnitTesting/Src/IUnitTestFileService.cs
  15. 17
      src/AddIns/Analysis/UnitTesting/Src/IUnitTestMessageService.cs
  16. 4
      src/AddIns/Analysis/UnitTesting/Src/NUnitTestDebugger.cs
  17. 11
      src/AddIns/Analysis/UnitTesting/Src/NUnitTestRunner.cs
  18. 4
      src/AddIns/Analysis/UnitTesting/Src/RunTestCommandContext.cs
  19. 7
      src/AddIns/Analysis/UnitTesting/Src/TestDebuggerBase.cs
  20. 42
      src/AddIns/Analysis/UnitTesting/Src/TestProcessRunnerBase.cs
  21. 56
      src/AddIns/Analysis/UnitTesting/Src/TestProcessRunnerBaseContext.cs
  22. 6
      src/AddIns/Analysis/UnitTesting/Src/UnitTestFileService.cs
  23. 28
      src/AddIns/Analysis/UnitTesting/Src/UnitTestMessageService.cs
  24. 92
      src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsForMethodTestFixture.cs
  25. 8
      src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsWithDebuggerTestFixture.cs
  26. 4
      src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWhenDebuggerRunningTestFixture.cs
  27. 9
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockFileService.cs
  28. 72
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs
  29. 14
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs
  30. 34
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestRunnerContext.cs
  31. 2
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs
  32. 8
      src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockMessageServiceTestFixture.cs
  33. 2
      src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockNUnitTestFrameworkTestFixture.cs
  34. 4
      src/AddIns/Analysis/UnitTesting/UnitTesting.csproj
  35. 1
      src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
  36. 3
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IPythonFileService.cs
  37. 5
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonFileService.cs
  38. 5
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestDebugger.cs
  39. 21
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunner.cs
  40. 54
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunnerContext.cs
  41. 12
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestRunnerRunsSelectedTestMethodTestFixture.cs
  42. 5
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockPythonFileService.cs
  43. 1
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/RubyBinding.csproj
  44. 3
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/IRubyFileService.cs
  45. 5
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyFileService.cs
  46. 4
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestDebugger.cs
  47. 18
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunner.cs
  48. 46
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunnerContext.cs
  49. 4
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Testing/RubyTestRunnerRunsSelectedTestMethodTestFixture.cs
  50. 5
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockRubyFileService.cs

6
data/resources/StringResources.fr.resx

@ -4255,6 +4255,9 @@ Toutes les modifications seront perdues.</value> @@ -4255,6 +4255,9 @@ Toutes les modifications seront perdues.</value>
<data name="ICSharpCode.SharpDevelop.Commands.SaveFileAs.FileSavedCaption" xml:space="preserve">
<value>Fichier sauvé</value>
</data>
<data name="ICSharpCode.SharpDevelop.Commands.TabStrip.NavigateToFileInProjectBrowser" xml:space="preserve">
<value>Naviguer par fichier avec l'explorateur de projet</value>
</data>
<data name="ICSharpCode.SharpDevelop.Commands.VBConvertProjectToCSharp" xml:space="preserve">
<value>De VB.NET vers C#</value>
</data>
@ -5918,6 +5921,9 @@ Soit ils n'existent pas, soit le document Wix n'est pas pour WiX 3.0 et l'espace @@ -5918,6 +5921,9 @@ Soit ils n'existent pas, soit le document Wix n'est pas pour WiX 3.0 et l'espace
<data name="ProjectComponent.ContextMenu.Clean" xml:space="preserve">
<value>&amp;Nettoyer</value>
</data>
<data name="ProjectComponent.ContextMenu.CollapseAll" xml:space="preserve">
<value>Réduire tout</value>
</data>
<data name="ProjectComponent.ContextMenu.Delete.Question" xml:space="preserve">
<value>Supprimer '${FileName}' de façon permanente?</value>
</data>

6
data/resources/StringResources.nl.resx

@ -4258,6 +4258,9 @@ Noot: Dit beïnvloed eigen aangepaste opmaak niet.</value> @@ -4258,6 +4258,9 @@ Noot: Dit beïnvloed eigen aangepaste opmaak niet.</value>
<data name="ICSharpCode.SharpDevelop.Commands.SaveFileAs.FileSavedCaption" xml:space="preserve">
<value>Bestand opgeslagen</value>
</data>
<data name="ICSharpCode.SharpDevelop.Commands.TabStrip.NavigateToFileInProjectBrowser" xml:space="preserve">
<value>Naar bestand in project browser navigeren</value>
</data>
<data name="ICSharpCode.SharpDevelop.Commands.VBConvertProjectToCSharp" xml:space="preserve">
<value>Van VB.NET naar C#</value>
</data>
@ -5919,6 +5922,9 @@ Microsoft.Tools.WindowsInstallerXml.Extenties.NetFxCompiler, WixNetFxExtentie</v @@ -5919,6 +5922,9 @@ Microsoft.Tools.WindowsInstallerXml.Extenties.NetFxCompiler, WixNetFxExtentie</v
<data name="ProjectComponent.ContextMenu.Clean" xml:space="preserve">
<value>Opscho&amp;nen</value>
</data>
<data name="ProjectComponent.ContextMenu.CollapseAll" xml:space="preserve">
<value>Alles invouwen</value>
</data>
<data name="ProjectComponent.ContextMenu.Delete.Question" xml:space="preserve">
<value>Wilt u '${FileName}' definitief verwijderen?</value>
</data>

3
data/resources/StringResources.resx

@ -4859,6 +4859,9 @@ Goto 'Options-&gt;Visual Style' and change the current language ambience.</value @@ -4859,6 +4859,9 @@ Goto 'Options-&gt;Visual Style' and change the current language ambience.</value
<data name="ICSharpCode.UnitTesting.TestMenu" xml:space="preserve">
<value>&amp;Test</value>
</data>
<data name="ICSharpCode.UnitTesting.TestRunnerNotFoundMessageFormat" xml:space="preserve">
<value>Unable to run unit tests. The file '{0}' cannot be found.</value>
</data>
<data name="ICSharpCode.WixBinding.AddCompilerExtensionsDialog.Title" xml:space="preserve">
<value>Add Extensions</value>
</data>

1
src/AddIns/Analysis/CodeCoverage/Project/CodeCoverage.csproj

@ -68,6 +68,7 @@ @@ -68,6 +68,7 @@
<Compile Include="Src\CodeCoverageMethod.cs" />
<Compile Include="Src\CodeCoverageSequencePoint.cs" />
<Compile Include="Src\CodeCoverageTestRunner.cs" />
<Compile Include="Src\CodeCoverageTestRunnerContext.cs" />
<Compile Include="Src\CodeCoverageTestRunnerFactory.cs" />
<Compile Include="Src\CodeCoverageTreeView.cs" />
<Compile Include="Src\CodeCoverageModuleTreeNode.cs" />

16
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageTestRunner.cs

@ -22,21 +22,15 @@ namespace ICSharpCode.CodeCoverage @@ -22,21 +22,15 @@ namespace ICSharpCode.CodeCoverage
PartCoverSettingsFactory settingsFactory;
public CodeCoverageTestRunner()
: this(new UnitTestProcessRunner(),
new TestResultsMonitor(),
new UnitTestingOptions(),
new FileSystem())
: this(new CodeCoverageTestRunnerContext())
{
}
public CodeCoverageTestRunner(IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor,
UnitTestingOptions options,
IFileSystem fileSystem)
: base(processRunner, testResultsMonitor)
public CodeCoverageTestRunner(CodeCoverageTestRunnerContext context)
: base(context)
{
this.options = options;
this.fileSystem = fileSystem;
this.options = context.Options;
this.fileSystem = context.CodeCoverageFileSystem;
settingsFactory = new PartCoverSettingsFactory(fileSystem);
}

44
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageTestRunnerContext.cs

@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.CodeCoverage
{
public class CodeCoverageTestRunnerContext : TestProcessRunnerBaseContext
{
UnitTestingOptions options;
public CodeCoverageTestRunnerContext()
: this(new UnitTestProcessRunner(),
new TestResultsMonitor(),
new FileSystem(),
new UnitTestMessageService(),
new UnitTestingOptions())
{
}
public CodeCoverageTestRunnerContext(IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor,
ICSharpCode.CodeCoverage.IFileSystem fileSystem,
IUnitTestMessageService messageService,
UnitTestingOptions options)
: base(processRunner, testResultsMonitor, fileSystem, messageService)
{
this.options = options;
}
public UnitTestingOptions Options {
get { return options; }
}
public ICSharpCode.CodeCoverage.IFileSystem CodeCoverageFileSystem {
get { return base.FileSystem as ICSharpCode.CodeCoverage.IFileSystem; }
}
}
}

3
src/AddIns/Analysis/CodeCoverage/Project/Src/IFileSystem.cs

@ -10,9 +10,8 @@ using System.IO; @@ -10,9 +10,8 @@ using System.IO;
namespace ICSharpCode.CodeCoverage
{
public interface IFileSystem
public interface IFileSystem : ICSharpCode.UnitTesting.IFileSystem
{
bool FileExists(string path);
void DeleteFile(string path);
bool DirectoryExists(string path);

4
src/AddIns/Analysis/CodeCoverage/Test/Testing/CodeCoverageTestRunnerTests.cs

@ -28,6 +28,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing @@ -28,6 +28,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing
UnitTestingOptions options;
DerivedCodeCoverageTestRunner testRunner;
MockFileSystem fileSystem;
MockMessageService messageService;
[SetUp]
public void Init()
@ -36,7 +37,8 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing @@ -36,7 +37,8 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing
testResultsMonitor = new MockTestResultsMonitor();
options = new UnitTestingOptions(new Properties());
fileSystem = new MockFileSystem();
testRunner = new DerivedCodeCoverageTestRunner(processRunner, testResultsMonitor, options, fileSystem);
messageService = new MockMessageService();
testRunner = new DerivedCodeCoverageTestRunner(processRunner, testResultsMonitor, options, fileSystem, messageService);
}
[Test]

9
src/AddIns/Analysis/CodeCoverage/Test/Testing/RunTestWithCodeCoverageCommandTests.cs

@ -164,9 +164,10 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing @@ -164,9 +164,10 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing
command.CallCreateTestRunner(null);
MockCSharpProject project = new MockCSharpProject();
SelectedTests tests = new SelectedTests(project);
mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = true;
mockCodeCoverageTestRunnerFactory.FileSystem.CreateTextReaderReturnValue = new StringReader("<a/>");
mockCodeCoverageTestRunnerFactory.TestRunner.Start(tests);
mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = true;
mockCodeCoverageTestRunnerFactory.FileSystem.CreateTextReaderReturnValue = CreateCodeCoverageResultsTextReader();
mockCodeCoverageTestRunnerFactory.ProcessRunner.FireProcessExitedEvent();
@ -225,14 +226,16 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing @@ -225,14 +226,16 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing
ActionArguments<Task> CreateTestRunnerAndFirePartCoverProcessExitEventWhenNoCoverageFileProduced()
{
mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = false;
command.CallCreateTestRunner(null);
MockCSharpProject project = new MockCSharpProject();
SelectedTests tests = new SelectedTests(project);
mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = true;
mockCodeCoverageTestRunnerFactory.FileSystem.CreateTextReaderReturnValue = new StringReader("<a/>");
mockCodeCoverageTestRunnerFactory.TestRunner.Start(tests);
mockCodeCoverageTestRunnerFactory.FileSystem.FileExistsReturnValue = false;
mockCodeCoverageTestRunnerFactory.ProcessRunner.FireProcessExitedEvent();
object actionArgsAsObject = context.MockUnitTestWorkbench.SafeThreadAsyncMethodCallsWithArguments[0];

5
src/AddIns/Analysis/CodeCoverage/Test/Utils/DerivedCodeCoverageTestRunner.cs

@ -20,8 +20,9 @@ namespace ICSharpCode.CodeCoverage.Tests.Utils @@ -20,8 +20,9 @@ namespace ICSharpCode.CodeCoverage.Tests.Utils
public DerivedCodeCoverageTestRunner(IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor,
UnitTestingOptions options,
IFileSystem fileSystem)
: base(processRunner, testResultsMonitor, options, fileSystem)
IFileSystem fileSystem,
IUnitTestMessageService messageService)
: base(new CodeCoverageTestRunnerContext(processRunner, testResultsMonitor, fileSystem, messageService, options))
{
}

8
src/AddIns/Analysis/CodeCoverage/Test/Utils/MockCodeCoverageTestRunnerFactory.cs

@ -20,6 +20,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Utils @@ -20,6 +20,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Utils
public UnitTestingOptions Options;
public CodeCoverageTestRunner TestRunner;
public MockFileSystem FileSystem;
public MockMessageService MessageService;
public MockCodeCoverageTestRunnerFactory()
{
@ -27,7 +28,12 @@ namespace ICSharpCode.CodeCoverage.Tests.Utils @@ -27,7 +28,12 @@ namespace ICSharpCode.CodeCoverage.Tests.Utils
TestResultsMonitor = new MockTestResultsMonitor();
Options = new UnitTestingOptions(new Properties());
FileSystem = new MockFileSystem();
TestRunner = new CodeCoverageTestRunner(ProcessRunner, TestResultsMonitor, Options, FileSystem);
CodeCoverageTestRunnerContext context = new CodeCoverageTestRunnerContext(ProcessRunner,
TestResultsMonitor,
FileSystem,
MessageService,
Options);
TestRunner = new CodeCoverageTestRunner(context);
}
public CodeCoverageTestRunner CreateCodeCoverageTestRunner()

16
src/AddIns/Analysis/UnitTesting/Src/IFileSystem.cs

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
namespace ICSharpCode.UnitTesting
{
public interface IFileSystem
{
bool FileExists(string fileName);
}
}

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

@ -20,7 +20,7 @@ namespace ICSharpCode.UnitTesting @@ -20,7 +20,7 @@ namespace ICSharpCode.UnitTesting
IBuildOptions BuildOptions { get; }
MessageViewCategory UnitTestCategory { get; }
IUnitTestsPad OpenUnitTestsPad { get; }
IMessageService MessageService { get; }
IUnitTestMessageService MessageService { get; }
IUnitTestSaveAllFilesCommand SaveAllFilesCommand { get; }
IStatusBarService StatusBarService { get; }
}

3
src/AddIns/Analysis/UnitTesting/Src/IUnitTestFileService.cs

@ -9,10 +9,9 @@ using System; @@ -9,10 +9,9 @@ using System;
namespace ICSharpCode.UnitTesting
{
public interface IUnitTestFileService
public interface IUnitTestFileService : IFileSystem
{
void OpenFile(string fileName);
void JumpToFilePosition(string fileName, int line, int column);
}
}

17
src/AddIns/Analysis/UnitTesting/Src/IUnitTestMessageService.cs

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
namespace ICSharpCode.UnitTesting
{
public interface IUnitTestMessageService
{
bool AskQuestion(string question, string caption);
void ShowFormattedErrorMessage(string format, string item);
}
}

4
src/AddIns/Analysis/UnitTesting/Src/NUnitTestDebugger.cs

@ -18,14 +18,14 @@ namespace ICSharpCode.UnitTesting @@ -18,14 +18,14 @@ namespace ICSharpCode.UnitTesting
public NUnitTestDebugger()
: this(new UnitTestDebuggerService(),
ServiceManager.Instance.MessageService,
new UnitTestMessageService(),
new TestResultsMonitor(),
new UnitTestingOptions())
{
}
public NUnitTestDebugger(IUnitTestDebuggerService debuggerService,
IMessageService messageService,
IUnitTestMessageService messageService,
ITestResultsMonitor testResultsMonitor,
UnitTestingOptions options)
: base(debuggerService, messageService, testResultsMonitor)

11
src/AddIns/Analysis/UnitTesting/Src/NUnitTestRunner.cs

@ -16,20 +16,17 @@ namespace ICSharpCode.UnitTesting @@ -16,20 +16,17 @@ namespace ICSharpCode.UnitTesting
UnitTestingOptions options;
public NUnitTestRunner()
: this(new UnitTestProcessRunner(),
new TestResultsMonitor(),
: this(new TestProcessRunnerBaseContext(),
new UnitTestingOptions())
{
}
public NUnitTestRunner(IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor,
UnitTestingOptions options)
: base(processRunner, testResultsMonitor)
public NUnitTestRunner(TestProcessRunnerBaseContext context, UnitTestingOptions options)
: base(context)
{
this.options = options;
}
protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests)
{
NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests, options);

4
src/AddIns/Analysis/UnitTesting/Src/RunTestCommandContext.cs

@ -20,7 +20,7 @@ namespace ICSharpCode.UnitTesting @@ -20,7 +20,7 @@ namespace ICSharpCode.UnitTesting
UnitTestBuildProjectFactory buildProjectFactory = new UnitTestBuildProjectFactory();
UnitTestBuildOptions buildOptions = new UnitTestBuildOptions();
MessageViewCategory unitTestCategory = TestService.UnitTestMessageView;
IMessageService messageService = ServiceManager.Instance.MessageService;
UnitTestMessageService messageService = new UnitTestMessageService();
UnitTestSaveAllFilesCommand saveAllFilesCommand = new UnitTestSaveAllFilesCommand();
IStatusBarService statusBarService = WorkbenchSingleton.StatusBar;
@ -52,7 +52,7 @@ namespace ICSharpCode.UnitTesting @@ -52,7 +52,7 @@ namespace ICSharpCode.UnitTesting
get { return UnitTestsPad.Instance; }
}
public IMessageService MessageService {
public IUnitTestMessageService MessageService {
get { return messageService; }
}

7
src/AddIns/Analysis/UnitTesting/Src/TestDebuggerBase.cs

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
using System;
using System.Diagnostics;
using ICSharpCode.Core.Services;
using ICSharpCode.SharpDevelop.Debugging;
namespace ICSharpCode.UnitTesting
@ -15,19 +14,19 @@ namespace ICSharpCode.UnitTesting @@ -15,19 +14,19 @@ namespace ICSharpCode.UnitTesting
public abstract class TestDebuggerBase : TestRunnerBase
{
IUnitTestDebuggerService debuggerService;
IMessageService messageService;
IUnitTestMessageService messageService;
IDebugger debugger;
ITestResultsMonitor testResultsMonitor;
public TestDebuggerBase()
: this(new UnitTestDebuggerService(),
ServiceManager.Instance.MessageService,
new UnitTestMessageService(),
new TestResultsMonitor())
{
}
public TestDebuggerBase(IUnitTestDebuggerService debuggerService,
IMessageService messageService,
IUnitTestMessageService messageService,
ITestResultsMonitor testResultsMonitor)
{
this.debuggerService = debuggerService;

42
src/AddIns/Analysis/UnitTesting/Src/TestProcessRunnerBase.cs

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
using System;
using System.Diagnostics;
using ICSharpCode.Core.WinForms;
using ICSharpCode.SharpDevelop.Util;
namespace ICSharpCode.UnitTesting
@ -15,18 +16,34 @@ namespace ICSharpCode.UnitTesting @@ -15,18 +16,34 @@ namespace ICSharpCode.UnitTesting
{
IUnitTestProcessRunner processRunner;
ITestResultsMonitor testResultsMonitor;
IFileSystem fileSystem;
IUnitTestMessageService messageService;
public TestProcessRunnerBase()
: this(new UnitTestProcessRunner(),
new TestResultsMonitor())
new TestResultsMonitor(),
new UnitTestFileService(),
new UnitTestMessageService())
{
}
public TestProcessRunnerBase(TestProcessRunnerBaseContext context)
: this(context.TestProcessRunner,
context.TestResultsMonitor,
context.FileSystem,
context.MessageService)
{
}
public TestProcessRunnerBase(IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor)
ITestResultsMonitor testResultsMonitor,
IFileSystem fileSystem,
IUnitTestMessageService messageService)
{
this.processRunner = processRunner;
this.testResultsMonitor = testResultsMonitor;
this.fileSystem = fileSystem;
this.messageService = messageService;
processRunner.LogStandardOutputAndError = false;
processRunner.OutputLineReceived += OutputLineReceived;
@ -58,9 +75,24 @@ namespace ICSharpCode.UnitTesting @@ -58,9 +75,24 @@ namespace ICSharpCode.UnitTesting
{
LogCommandLine(processStartInfo);
testResultsMonitor.Start();
processRunner.WorkingDirectory = processStartInfo.WorkingDirectory;
processRunner.Start(processStartInfo.FileName, processStartInfo.Arguments);
if (ApplicationFileNameExists(processStartInfo.FileName)) {
testResultsMonitor.Start();
processRunner.WorkingDirectory = processStartInfo.WorkingDirectory;
processRunner.Start(processStartInfo.FileName, processStartInfo.Arguments);
} else {
ShowApplicationDoesNotExistMessage(processStartInfo.FileName);
}
}
bool ApplicationFileNameExists(string fileName)
{
return fileSystem.FileExists(fileName);
}
void ShowApplicationDoesNotExistMessage(string fileName)
{
string resourceString = "${res:ICSharpCode.UnitTesting.TestRunnerNotFoundMessageFormat}";
messageService.ShowFormattedErrorMessage(resourceString, fileName);
}
public override void Stop()

56
src/AddIns/Analysis/UnitTesting/Src/TestProcessRunnerBaseContext.cs

@ -0,0 +1,56 @@ @@ -0,0 +1,56 @@
// <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.WinForms;
using ICSharpCode.SharpDevelop.Util;
namespace ICSharpCode.UnitTesting
{
public class TestProcessRunnerBaseContext
{
IUnitTestProcessRunner processRunner;
ITestResultsMonitor testResultsMonitor;
IFileSystem fileSystem;
IUnitTestMessageService messageService;
public TestProcessRunnerBaseContext()
: this(new UnitTestProcessRunner(),
new TestResultsMonitor(),
new UnitTestFileService(),
new UnitTestMessageService())
{
}
public TestProcessRunnerBaseContext(IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor,
IFileSystem fileSystem,
IUnitTestMessageService messageService)
{
this.processRunner = processRunner;
this.testResultsMonitor = testResultsMonitor;
this.fileSystem = fileSystem;
this.messageService = messageService;
}
public IUnitTestProcessRunner TestProcessRunner {
get { return processRunner; }
}
public ITestResultsMonitor TestResultsMonitor {
get { return testResultsMonitor; }
}
public IFileSystem FileSystem {
get { return fileSystem; }
}
public IUnitTestMessageService MessageService {
get { return messageService; }
}
}
}

6
src/AddIns/Analysis/UnitTesting/Src/UnitTestFileService.cs

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using System.IO;
using ICSharpCode.SharpDevelop;
namespace ICSharpCode.UnitTesting
@ -21,5 +22,10 @@ namespace ICSharpCode.UnitTesting @@ -21,5 +22,10 @@ namespace ICSharpCode.UnitTesting
{
FileService.JumpToFilePosition(fileName, line, column);
}
public bool FileExists(string fileName)
{
return File.Exists(fileName);
}
}
}

28
src/AddIns/Analysis/UnitTesting/Src/UnitTestMessageService.cs

@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.Core;
using ICSharpCode.Core.Services;
namespace ICSharpCode.UnitTesting
{
public class UnitTestMessageService : IUnitTestMessageService
{
public bool AskQuestion(string question, string caption)
{
return ServiceManager.Instance.MessageService.AskQuestion(question, caption);
}
public void ShowFormattedErrorMessage(string format, string item)
{
format = StringParser.Parse(format);
string message = String.Format(format, item);
ServiceManager.Instance.MessageService.ShowError(message);
}
}
}

92
src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsForMethodTestFixture.cs

@ -21,26 +21,33 @@ namespace UnitTesting.Tests.Tree @@ -21,26 +21,33 @@ namespace UnitTesting.Tests.Tree
SelectedTests selectedTests;
NUnitTestRunner testRunner;
[SetUp]
public void Init()
void CreateNUnitTestRunner()
{
selectedTests = SelectedTestsHelper.CreateSelectedTestMethod();
context = new MockNUnitTestRunnerContext();
FileUtility.ApplicationRootPath = @"C:\SharpDevelop";
testRunner = context.CreateNUnitTestRunner();
}
void StartNUnitTestRunner()
{
testRunner.Start(selectedTests);
}
[Test]
public void StartMethodCallsTestResultsMonitorStartMethod()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
Assert.IsTrue(context.MockTestResultsMonitor.IsStartMethodCalled);
}
[Test]
public void StopMethodCallsTestResultsMonitorStopMethod()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
testRunner.Stop();
Assert.IsTrue(context.MockTestResultsMonitor.IsStopMethodCalled);
}
@ -48,6 +55,8 @@ namespace UnitTesting.Tests.Tree @@ -48,6 +55,8 @@ namespace UnitTesting.Tests.Tree
[Test]
public void DisposeMethodCallsTestResultsMonitorDisposeMethod()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
testRunner.Dispose();
Assert.IsTrue(context.MockTestResultsMonitor.IsDisposeMethodCalled);
}
@ -55,12 +64,16 @@ namespace UnitTesting.Tests.Tree @@ -55,12 +64,16 @@ namespace UnitTesting.Tests.Tree
[Test]
public void NUnitTestRunnerIsIDisposable()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
Assert.IsNotNull(testRunner as IDisposable);
}
[Test]
public void StopMethodCallsTestResultsReadMethodToEnsureAllTestsAreRead()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
testRunner.Stop();
Assert.IsTrue(context.MockTestResultsMonitor.IsReadMethodCalled);
}
@ -68,6 +81,8 @@ namespace UnitTesting.Tests.Tree @@ -68,6 +81,8 @@ namespace UnitTesting.Tests.Tree
[Test]
public void StopMethodCallsProcessRunnerKillMethod()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
testRunner.Stop();
Assert.IsTrue(context.MockProcessRunner.IsKillMethodCalled);
}
@ -75,6 +90,9 @@ namespace UnitTesting.Tests.Tree @@ -75,6 +90,9 @@ namespace UnitTesting.Tests.Tree
[Test]
public void FiringTestResultsMonitorTestFinishedEventFiresNUnitTestRunnerTestFinishedEvent()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
TestResult testResultToFire = new TestResult("abc");
TestResult resultFromEventHandler = FireTestResult(testResultToFire);
Assert.IsNotNull(resultFromEventHandler);
@ -94,6 +112,9 @@ namespace UnitTesting.Tests.Tree @@ -94,6 +112,9 @@ namespace UnitTesting.Tests.Tree
[Test]
public void FiringTestResultsMonitorTestFinishedCreatesNUnitTestResultWithCorrectNameFromNUnitTestRunnerTestFinishedEvent()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
TestResult testResultToFire = new TestResult("abc");
NUnitTestResult resultFromEventHandler = FireTestResult(testResultToFire) as NUnitTestResult;
Assert.AreEqual("abc", resultFromEventHandler.Name);
@ -102,6 +123,9 @@ namespace UnitTesting.Tests.Tree @@ -102,6 +123,9 @@ namespace UnitTesting.Tests.Tree
[Test]
public void FiringTestResultsMonitorTestFinishedEventAfterDisposingTestRunnerDoesNotGenerateTestFinishedEvent()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
bool fired = false;
testRunner.TestFinished += delegate(object source, TestFinishedEventArgs e) {
fired = true;
@ -117,12 +141,16 @@ namespace UnitTesting.Tests.Tree @@ -117,12 +141,16 @@ namespace UnitTesting.Tests.Tree
[Test]
public void NUnitTestRunnerImplementsITestRunner()
{
CreateNUnitTestRunner();
Assert.IsNotNull(testRunner as ITestRunner);
}
[Test]
public void FiringProcessExitEventCausesTestRunnerAllTestsFinishedEventToFire()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
bool fired = false;
testRunner.AllTestsFinished += delegate (object source, EventArgs e) {
fired = true;
@ -135,6 +163,9 @@ namespace UnitTesting.Tests.Tree @@ -135,6 +163,9 @@ namespace UnitTesting.Tests.Tree
[Test]
public void NUnitConsoleExeProcessIsStarted()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
string expectedCommand = @"C:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe";
Assert.AreEqual(expectedCommand, context.MockProcessRunner.CommandPassedToStartMethod);
}
@ -142,6 +173,9 @@ namespace UnitTesting.Tests.Tree @@ -142,6 +173,9 @@ namespace UnitTesting.Tests.Tree
[Test]
public void NUnitConsoleExeProcessIsStartedWithArgumentsToTestSingleMethod()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
string expectedArgs =
"\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" " +
"/results=\"c:\\temp\\tmp66.tmp\" " +
@ -152,6 +186,9 @@ namespace UnitTesting.Tests.Tree @@ -152,6 +186,9 @@ namespace UnitTesting.Tests.Tree
[Test]
public void NUnitConsoleWorkingDirectoryIsUsedByProcessRunner()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
string expectedDirectory = @"C:\SharpDevelop\bin\Tools\NUnit";
Assert.AreEqual(expectedDirectory, context.MockProcessRunner.WorkingDirectory);
}
@ -159,12 +196,18 @@ namespace UnitTesting.Tests.Tree @@ -159,12 +196,18 @@ namespace UnitTesting.Tests.Tree
[Test]
public void ProcessRunnerLogStandardOutputAndErrorIsFalse()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
Assert.IsFalse(context.MockProcessRunner.LogStandardOutputAndError);
}
[Test]
public void FiringProcessRunnerOutputLineReceivedEventFiresTestRunnerMessageReceivedEvent()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
string message = null;
testRunner.MessageReceived += delegate (object o, MessageReceivedEventArgs e) {
message = e.Message;
@ -179,6 +222,9 @@ namespace UnitTesting.Tests.Tree @@ -179,6 +222,9 @@ namespace UnitTesting.Tests.Tree
[Test]
public void FiringProcessRunnerErrorLineReceivedEventFiresTestRunnerMessageReceivedEvent()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
string message = null;
testRunner.MessageReceived += delegate (object o, MessageReceivedEventArgs e) {
message = e.Message;
@ -193,6 +239,9 @@ namespace UnitTesting.Tests.Tree @@ -193,6 +239,9 @@ namespace UnitTesting.Tests.Tree
[Test]
public void FiringProcessRunnerOutputLineReceivedEventAfterDisposingTestRunnerDoesNotMessageReceivedEvent()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
string message = null;
testRunner.MessageReceived += delegate (object o, MessageReceivedEventArgs e) {
message = e.Message;
@ -207,6 +256,9 @@ namespace UnitTesting.Tests.Tree @@ -207,6 +256,9 @@ namespace UnitTesting.Tests.Tree
[Test]
public void FiringProcessRunnerErrorLineReceivedEventAfterDisposingTestRunnerDoesNotMessageReceivedEvent()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
string message = null;
testRunner.MessageReceived += delegate (object o, MessageReceivedEventArgs e) {
message = e.Message;
@ -217,5 +269,41 @@ namespace UnitTesting.Tests.Tree @@ -217,5 +269,41 @@ namespace UnitTesting.Tests.Tree
Assert.IsNull(message);
}
[Test]
public void NUnitConsoleExeFileCheckedThatItExists()
{
CreateNUnitTestRunner();
StartNUnitTestRunner();
string fileName = context.MockFileService.FileNamePassedToFileExists;
string expectedFileName = @"C:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe";
Assert.AreEqual(expectedFileName, fileName);
}
[Test]
public void NUnitConsoleExeNotStartedIfFileDoesNotExist()
{
CreateNUnitTestRunner();
context.MockFileService.FileExistsReturnValue = false;
StartNUnitTestRunner();
Assert.IsNull(context.MockProcessRunner.CommandPassedToStartMethod);
}
[Test]
public void MessageShowedToUserIfNUnitConsoleExeDoesNotExist()
{
CreateNUnitTestRunner();
context.MockFileService.FileExistsReturnValue = false;
StartNUnitTestRunner();
string expectedFormat = "${res:ICSharpCode.UnitTesting.TestRunnerNotFoundMessageFormat}";
string expectedItem = @"C:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe";
Assert.AreEqual(expectedFormat, context.MockMessageService.FormatPassedToShowFormattedErrorMessage);
Assert.AreEqual(expectedItem, context.MockMessageService.ItemPassedToShowFormattedErrorMessage);
}
}
}

8
src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsWithDebuggerTestFixture.cs

@ -184,7 +184,7 @@ namespace UnitTesting.Tests.Tree @@ -184,7 +184,7 @@ namespace UnitTesting.Tests.Tree
StartTestDebugger();
string expectedQuestion = "${res:XML.MainMenu.RunMenu.Compile.StopDebuggingQuestion}";
Assert.AreEqual(expectedQuestion, messageService.Question);
Assert.AreEqual(expectedQuestion, messageService.QuestionPassedToAskQuestion);
}
void SetDebuggerIsLoadedToTrueAndDebuggingToTrue()
@ -200,7 +200,7 @@ namespace UnitTesting.Tests.Tree @@ -200,7 +200,7 @@ namespace UnitTesting.Tests.Tree
debuggerService.MockDebugger.IsDebugging = false;
StartTestDebugger();
Assert.IsNull(messageService.Question);
Assert.IsNull(messageService.QuestionPassedToAskQuestion);
}
[Test]
@ -210,7 +210,7 @@ namespace UnitTesting.Tests.Tree @@ -210,7 +210,7 @@ namespace UnitTesting.Tests.Tree
debuggerService.MockDebugger.IsDebugging = true;
StartTestDebugger();
Assert.IsNull(messageService.Question);
Assert.IsNull(messageService.QuestionPassedToAskQuestion);
}
[Test]
@ -220,7 +220,7 @@ namespace UnitTesting.Tests.Tree @@ -220,7 +220,7 @@ namespace UnitTesting.Tests.Tree
StartTestDebugger();
string expectedCaption = "${res:XML.MainMenu.RunMenu.Compile.StopDebuggingTitle}";
Assert.AreEqual(expectedCaption, messageService.Caption);
Assert.AreEqual(expectedCaption, messageService.CaptionPassedToAskQuestion);
}
[Test]

4
src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWhenDebuggerRunningTestFixture.cs

@ -28,7 +28,7 @@ namespace UnitTesting.Tests.Tree @@ -28,7 +28,7 @@ namespace UnitTesting.Tests.Tree
RunTests();
string expectedQuestion = "${res:XML.MainMenu.RunMenu.Compile.StopDebuggingQuestion}";
string actualQuestion = context.MockMessageService.Question;
string actualQuestion = context.MockMessageService.QuestionPassedToAskQuestion;
Assert.AreEqual(expectedQuestion, actualQuestion);
}
@ -52,7 +52,7 @@ namespace UnitTesting.Tests.Tree @@ -52,7 +52,7 @@ namespace UnitTesting.Tests.Tree
RunTests();
string expectedCaption = "${res:XML.MainMenu.RunMenu.Compile.StopDebuggingTitle}";
string actualCaption = context.MockMessageService.Caption;
string actualCaption = context.MockMessageService.CaptionPassedToAskQuestion;
Assert.AreEqual(expectedCaption, actualCaption);
}

9
src/AddIns/Analysis/UnitTesting/Test/Utils/MockFileService.cs

@ -13,6 +13,9 @@ namespace UnitTesting.Tests.Utils @@ -13,6 +13,9 @@ namespace UnitTesting.Tests.Utils
{
public class MockFileService : IUnitTestFileService
{
public string FileNamePassedToFileExists;
public bool FileExistsReturnValue = true;
string fileOpened;
FilePosition? filePositionJumpedTo;
@ -33,5 +36,11 @@ namespace UnitTesting.Tests.Utils @@ -33,5 +36,11 @@ namespace UnitTesting.Tests.Utils
{
filePositionJumpedTo = new FilePosition(fileName, line, column);
}
public bool FileExists(string fileName)
{
FileNamePassedToFileExists = fileName;
return FileExistsReturnValue;
}
}
}

72
src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs

@ -6,75 +6,29 @@ @@ -6,75 +6,29 @@
// </file>
using System;
using ICSharpCode.Core.Services;
using ICSharpCode.UnitTesting;
namespace UnitTesting.Tests.Utils
{
public class MockMessageService : IMessageService
public class MockMessageService : IUnitTestMessageService
{
string question;
string caption;
bool returnValue;
public bool AskQuestionReturnValue {
get { return returnValue; }
set { returnValue = value; }
}
public string QuestionPassedToAskQuestion;
public string CaptionPassedToAskQuestion;
public bool AskQuestionReturnValue;
public string FormatPassedToShowFormattedErrorMessage;
public string ItemPassedToShowFormattedErrorMessage;
public bool AskQuestion(string question, string caption)
{
this.question = question;
this.caption = caption;
return returnValue;
}
public string Question {
get { return question; }
}
public string Caption {
get { return caption; }
}
void IMessageService.ShowError(string message)
{
throw new NotImplementedException();
}
void IMessageService.ShowException(Exception ex, string message)
{
throw new NotImplementedException();
}
void IMessageService.ShowWarning(string message)
{
throw new NotImplementedException();
}
int IMessageService.ShowCustomDialog(string caption, string dialogText, int acceptButtonIndex, int cancelButtonIndex, params string[] buttontexts)
{
throw new NotImplementedException();
}
string IMessageService.ShowInputBox(string caption, string dialogText, string defaultValue)
{
throw new NotImplementedException();
QuestionPassedToAskQuestion = question;
CaptionPassedToAskQuestion = caption;
return AskQuestionReturnValue;
}
void IMessageService.ShowMessage(string message, string caption)
public void ShowFormattedErrorMessage(string format, string item)
{
throw new NotImplementedException();
}
void IMessageService.InformSaveError(string fileName, string message, string dialogName, Exception exceptionGot)
{
throw new NotImplementedException();
}
ChooseSaveErrorResult IMessageService.ChooseSaveError(string fileName, string message, string dialogName, Exception exceptionGot, bool chooseLocationEnabled)
{
throw new NotImplementedException();
}
FormatPassedToShowFormattedErrorMessage = format;
ItemPassedToShowFormattedErrorMessage = item;
}
}
}

14
src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs

@ -8,7 +8,6 @@ @@ -8,7 +8,6 @@
using System;
using System.Collections.Generic;
using ICSharpCode.Core;
using ICSharpCode.Core.Services;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
@ -23,7 +22,8 @@ namespace UnitTesting.Tests.Utils @@ -23,7 +22,8 @@ namespace UnitTesting.Tests.Utils
ITestResultsMonitor testResultsMonitor;
UnitTestingOptions options;
IUnitTestDebuggerService debuggerService;
IMessageService messageService;
IUnitTestMessageService messageService;
IUnitTestFileService fileService = new MockFileService();
public MockNUnitTestFramework(IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor,
@ -35,7 +35,7 @@ namespace UnitTesting.Tests.Utils @@ -35,7 +35,7 @@ namespace UnitTesting.Tests.Utils
public MockNUnitTestFramework(IUnitTestDebuggerService debuggerService,
ITestResultsMonitor testResultsMonitor,
UnitTestingOptions options,
IMessageService messageService)
IUnitTestMessageService messageService)
: this(debuggerService, null, testResultsMonitor, options, messageService)
{
}
@ -44,7 +44,7 @@ namespace UnitTesting.Tests.Utils @@ -44,7 +44,7 @@ namespace UnitTesting.Tests.Utils
IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor,
UnitTestingOptions options,
IMessageService messageService)
IUnitTestMessageService messageService)
{
this.debuggerService = debuggerService;
this.processRunner = processRunner;
@ -70,7 +70,11 @@ namespace UnitTesting.Tests.Utils @@ -70,7 +70,11 @@ namespace UnitTesting.Tests.Utils
public ITestRunner CreateTestRunner()
{
NUnitTestRunner testRunner = new NUnitTestRunner(processRunner, testResultsMonitor, options);
TestProcessRunnerBaseContext context = new TestProcessRunnerBaseContext(processRunner,
testResultsMonitor,
fileService,
messageService);
NUnitTestRunner testRunner = new NUnitTestRunner(context, options);
testRunnersCreated.Add(testRunner);
return testRunner;
}

34
src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestRunnerContext.cs

@ -11,28 +11,38 @@ using ICSharpCode.UnitTesting; @@ -11,28 +11,38 @@ using ICSharpCode.UnitTesting;
namespace UnitTesting.Tests.Utils
{
public class MockNUnitTestRunnerContext
public class MockNUnitTestRunnerContext : TestProcessRunnerBaseContext
{
MockProcessRunner processRunner = new MockProcessRunner();
UnitTestingOptions options = new UnitTestingOptions(new Properties());
MockTestResultsMonitor testResultsMonitor = new MockTestResultsMonitor();
public MockNUnitTestRunnerContext()
{
testResultsMonitor.FileName = @"c:\temp\tmp66.tmp";
}
public UnitTestingOptions options = new UnitTestingOptions(new Properties());
public MockProcessRunner MockProcessRunner {
get { return processRunner; }
get { return base.TestProcessRunner as MockProcessRunner; }
}
public MockTestResultsMonitor MockTestResultsMonitor {
get { return testResultsMonitor; }
get { return base.TestResultsMonitor as MockTestResultsMonitor; }
}
public MockFileService MockFileService {
get { return base.FileSystem as MockFileService; }
}
public MockMessageService MockMessageService {
get { return base.MessageService as MockMessageService; }
}
public MockNUnitTestRunnerContext()
: base(new MockProcessRunner(),
new MockTestResultsMonitor(),
new MockFileService(),
new MockMessageService())
{
MockTestResultsMonitor.FileName = @"c:\temp\tmp66.tmp";
}
public NUnitTestRunner CreateNUnitTestRunner()
{
return new NUnitTestRunner(processRunner, testResultsMonitor, options);
return new NUnitTestRunner(this, options);
}
}
}

2
src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs

@ -89,7 +89,7 @@ namespace UnitTesting.Tests.Utils @@ -89,7 +89,7 @@ namespace UnitTesting.Tests.Utils
set { unitTestsPad = value; }
}
public IMessageService MessageService {
public IUnitTestMessageService MessageService {
get { return messageService; }
}

8
src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockMessageServiceTestFixture.cs

@ -26,13 +26,13 @@ namespace UnitTesting.Tests.Utils.Tests @@ -26,13 +26,13 @@ namespace UnitTesting.Tests.Utils.Tests
[Test]
public void CaptionIsNullByDefault()
{
Assert.IsNull(messageService.Caption);
Assert.IsNull(messageService.CaptionPassedToAskQuestion);
}
[Test]
public void QuestionIsNullByDefault()
{
Assert.IsNull(messageService.Question);
Assert.IsNull(messageService.QuestionPassedToAskQuestion);
}
[Test]
@ -41,7 +41,7 @@ namespace UnitTesting.Tests.Utils.Tests @@ -41,7 +41,7 @@ namespace UnitTesting.Tests.Utils.Tests
string expectedQuestion = "question";
messageService.AskQuestion(expectedQuestion, null);
Assert.AreEqual(expectedQuestion, messageService.Question);
Assert.AreEqual(expectedQuestion, messageService.QuestionPassedToAskQuestion);
}
[Test]
@ -50,7 +50,7 @@ namespace UnitTesting.Tests.Utils.Tests @@ -50,7 +50,7 @@ namespace UnitTesting.Tests.Utils.Tests
string expectedCaption = "caption";
messageService.AskQuestion(null, expectedCaption);
Assert.AreEqual(expectedCaption, messageService.Caption);
Assert.AreEqual(expectedCaption, messageService.CaptionPassedToAskQuestion);
}
[Test]

2
src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockNUnitTestFrameworkTestFixture.cs

@ -127,7 +127,7 @@ namespace UnitTesting.Tests.Utils.Tests @@ -127,7 +127,7 @@ namespace UnitTesting.Tests.Utils.Tests
SelectedTests tests = new SelectedTests(project);
testDebugger.Start(tests);
Assert.IsNotNull(context.MockMessageService.Question);
Assert.IsNotNull(context.MockMessageService.QuestionPassedToAskQuestion);
}
[Test]

4
src/AddIns/Analysis/UnitTesting/UnitTesting.csproj

@ -57,12 +57,16 @@ @@ -57,12 +57,16 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Src\IFileSystem.cs" />
<Compile Include="Src\IUnitTestMessageService.cs" />
<Compile Include="Src\MultipleProjectBuildable.cs" />
<Compile Include="Src\TestProcessRunnerBaseContext.cs" />
<Compile Include="Src\UnitTestAddInTree.cs" />
<Compile Include="Src\UnitTestBuildOptions.cs" />
<Compile Include="Src\UnitTestBuildProjectFactory.cs" />
<Compile Include="Src\UnitTestDebuggerService.cs" />
<Compile Include="Src\UnitTestFileService.cs" />
<Compile Include="Src\UnitTestMessageService.cs" />
<Compile Include="Src\UnitTestProcessRunner.cs" />
<Compile Include="Src\UnitTestSaveAllFilesCommand.cs" />
<Compile Include="Src\UnitTestTaskService.cs" />

1
src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj

@ -125,6 +125,7 @@ @@ -125,6 +125,7 @@
<Compile Include="Src\PythonTestResult.cs" />
<Compile Include="Src\PythonTestRunner.cs" />
<Compile Include="Src\PythonTestRunnerApplication.cs" />
<Compile Include="Src\PythonTestRunnerContext.cs" />
<Compile Include="Src\PythonTestRunnerResponseFile.cs" />
<Compile Include="Src\PythonTextEditorViewContent.cs" />
<Compile Include="Src\SysModuleCompletionItems.cs" />

3
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IPythonFileService.cs

@ -8,10 +8,11 @@ @@ -8,10 +8,11 @@
using System;
using System.IO;
using System.Text;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.PythonBinding
{
public interface IPythonFileService
public interface IPythonFileService : IFileSystem
{
string GetTempFileName();
TextWriter CreateTextWriter(CreateTextWriterInfo createTextWriterInfo);

5
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonFileService.cs

@ -27,5 +27,10 @@ namespace ICSharpCode.PythonBinding @@ -27,5 +27,10 @@ namespace ICSharpCode.PythonBinding
{
File.Delete(fileName);
}
public bool FileExists(string fileName)
{
return File.Exists(fileName);
}
}
}

5
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestDebugger.cs

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
using System;
using System.Diagnostics;
using ICSharpCode.Core.Services;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.PythonBinding
@ -21,7 +20,7 @@ namespace ICSharpCode.PythonBinding @@ -21,7 +20,7 @@ namespace ICSharpCode.PythonBinding
public PythonTestDebugger()
: this(new UnitTestDebuggerService(),
ServiceManager.Instance.MessageService,
new UnitTestMessageService(),
new TestResultsMonitor(),
new PythonAddInOptions(),
new PythonStandardLibraryPath(),
@ -30,7 +29,7 @@ namespace ICSharpCode.PythonBinding @@ -30,7 +29,7 @@ namespace ICSharpCode.PythonBinding
}
public PythonTestDebugger(IUnitTestDebuggerService debuggerService,
IMessageService messageService,
IUnitTestMessageService messageService,
ITestResultsMonitor testResultsMonitor,
PythonAddInOptions options,
PythonStandardLibraryPath pythonStandardLibraryPath,

21
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunner.cs

@ -10,6 +10,7 @@ using System.Diagnostics; @@ -10,6 +10,7 @@ using System.Diagnostics;
using System.IO;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.Core.Services;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.PythonBinding
@ -22,24 +23,16 @@ namespace ICSharpCode.PythonBinding @@ -22,24 +23,16 @@ namespace ICSharpCode.PythonBinding
PythonTestRunnerApplication testRunnerApplication;
public PythonTestRunner()
: this(new UnitTestProcessRunner(),
new TestResultsMonitor(),
new PythonAddInOptions(),
new PythonStandardLibraryPath(),
new PythonFileService())
: this(new PythonTestRunnerContext())
{
}
public PythonTestRunner(IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor,
PythonAddInOptions options,
PythonStandardLibraryPath pythonStandardLibraryPath,
IPythonFileService fileService)
: base(processRunner, testResultsMonitor)
public PythonTestRunner(PythonTestRunnerContext context)
: base(context)
{
this.options = options;
this.pythonStandardLibraryPath = pythonStandardLibraryPath;
this.fileService = fileService;
this.options = context.Options;
this.pythonStandardLibraryPath = context.PythonStandardLibraryPath;
this.fileService = context.PythonFileService;
}
public override void Start(SelectedTests selectedTests)

54
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunnerContext.cs

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
// <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.UnitTesting;
namespace ICSharpCode.PythonBinding
{
public class PythonTestRunnerContext : TestProcessRunnerBaseContext
{
PythonAddInOptions options;
PythonStandardLibraryPath pythonStandardLibraryPath;
IPythonFileService fileService;
public PythonTestRunnerContext(IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor,
IUnitTestMessageService messageService,
PythonAddInOptions options,
PythonStandardLibraryPath pythonStandardLibraryPath,
IPythonFileService fileService)
: base(processRunner, testResultsMonitor, fileService, messageService)
{
this.options = options;
this.pythonStandardLibraryPath = pythonStandardLibraryPath;
this.fileService = fileService;
}
public PythonTestRunnerContext()
: this(new UnitTestProcessRunner(),
new TestResultsMonitor(),
new UnitTestMessageService(),
new PythonAddInOptions(),
new PythonStandardLibraryPath(),
new PythonFileService())
{
}
public PythonAddInOptions Options {
get { return options; }
}
public PythonStandardLibraryPath PythonStandardLibraryPath {
get { return pythonStandardLibraryPath; }
}
public IPythonFileService PythonFileService {
get { return base.FileSystem as IPythonFileService; }
}
}
}

12
src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestRunnerRunsSelectedTestMethodTestFixture.cs

@ -34,6 +34,7 @@ namespace PythonBinding.Tests.Testing @@ -34,6 +34,7 @@ namespace PythonBinding.Tests.Testing
StringBuilder responseFileText;
StringWriter responseFileStringWriter;
PythonStandardLibraryPath standardLibraryPath;
MockMessageService messageService;
[SetUp]
public void Init()
@ -49,9 +50,16 @@ namespace PythonBinding.Tests.Testing @@ -49,9 +50,16 @@ namespace PythonBinding.Tests.Testing
options = new PythonAddInOptions(new Properties());
options.PythonFileName = @"c:\ironpython\ipy.exe";
fileService = new MockPythonFileService();
messageService = new MockMessageService();
standardLibraryPath = new PythonStandardLibraryPath(@"c:\python\lib");
testRunner = new PythonTestRunner(processRunner, testResultsMonitor, options, standardLibraryPath, fileService);
PythonTestRunnerContext context = new PythonTestRunnerContext(processRunner,
testResultsMonitor,
messageService,
options,
standardLibraryPath,
fileService);
testRunner = new PythonTestRunner(context);
}
void CreateTestMethod()

5
src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockPythonFileService.cs

@ -54,5 +54,10 @@ namespace PythonBinding.Tests.Utils @@ -54,5 +54,10 @@ namespace PythonBinding.Tests.Utils
get { return fileNameDeleted; }
set { fileNameDeleted = value; }
}
public bool FileExists(string fileName)
{
return true;
}
}
}

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

@ -135,6 +135,7 @@ @@ -135,6 +135,7 @@
<Compile Include="Src\RubyTestResult.cs" />
<Compile Include="Src\RubyTestRunner.cs" />
<Compile Include="Src\RubyTestRunnerApplication.cs" />
<Compile Include="Src\RubyTestRunnerContext.cs" />
<Compile Include="Src\RubyTestRunnerResponseFile.cs" />
<Compile Include="Src\RubyTextEditorViewContent.cs" />
<Compile Include="Src\RunDebugRubyCommand.cs" />

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

@ -8,10 +8,11 @@ @@ -8,10 +8,11 @@
using System;
using System.IO;
using System.Text;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.RubyBinding
{
public interface IRubyFileService
public interface IRubyFileService : IFileSystem
{
string GetTempFileName();
TextWriter CreateTextWriter(CreateTextWriterInfo createTextWriterInfo);

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

@ -27,5 +27,10 @@ namespace ICSharpCode.RubyBinding @@ -27,5 +27,10 @@ namespace ICSharpCode.RubyBinding
{
File.Delete(fileName);
}
public bool FileExists(string fileName)
{
return File.Exists(fileName);
}
}
}

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

@ -20,7 +20,7 @@ namespace ICSharpCode.RubyBinding @@ -20,7 +20,7 @@ namespace ICSharpCode.RubyBinding
public RubyTestDebugger()
: this(new UnitTestDebuggerService(),
ServiceManager.Instance.MessageService,
new UnitTestMessageService(),
new TestResultsMonitor(),
new RubyAddInOptions(),
new RubyFileService())
@ -28,7 +28,7 @@ namespace ICSharpCode.RubyBinding @@ -28,7 +28,7 @@ namespace ICSharpCode.RubyBinding
}
public RubyTestDebugger(IUnitTestDebuggerService debuggerService,
IMessageService messageService,
IUnitTestMessageService messageService,
ITestResultsMonitor testResultsMonitor,
RubyAddInOptions options,
IRubyFileService fileService)

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

@ -21,22 +21,16 @@ namespace ICSharpCode.RubyBinding @@ -21,22 +21,16 @@ namespace ICSharpCode.RubyBinding
RubyTestRunnerApplication testRunnerApplication;
public RubyTestRunner()
: this(new UnitTestProcessRunner(),
new TestResultsMonitor(),
new RubyAddInOptions(),
new RubyFileService())
: this(new RubyTestRunnerContext())
{
}
public RubyTestRunner(IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor,
RubyAddInOptions options,
IRubyFileService fileService)
: base(processRunner, testResultsMonitor)
public RubyTestRunner(RubyTestRunnerContext context)
: base(context)
{
this.options = options;
this.fileService = fileService;
testResultsMonitor.InitialFilePosition = 0;
this.options = context.Options;
this.fileService = context.RubyFileService;
context.TestResultsMonitor.InitialFilePosition = 0;
}
public override void Start(SelectedTests selectedTests)

46
src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyTestRunnerContext.cs

@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
// <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.UnitTesting;
namespace ICSharpCode.RubyBinding
{
public class RubyTestRunnerContext : TestProcessRunnerBaseContext
{
RubyAddInOptions options;
IRubyFileService fileService;
public RubyTestRunnerContext()
: this(new UnitTestProcessRunner(),
new TestResultsMonitor(),
new RubyAddInOptions(),
new RubyFileService(),
new UnitTestMessageService())
{
}
public RubyTestRunnerContext(IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor,
RubyAddInOptions options,
IRubyFileService fileService,
IUnitTestMessageService messageService)
: base(processRunner, testResultsMonitor, fileService, messageService)
{
this.options = options;
this.fileService = fileService;
}
public RubyAddInOptions Options {
get { return options; }
}
public IRubyFileService RubyFileService {
get { return fileService; }
}
}
}

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

@ -49,8 +49,10 @@ namespace RubyBinding.Tests.Testing @@ -49,8 +49,10 @@ namespace RubyBinding.Tests.Testing
options = new RubyAddInOptions(new Properties());
options.RubyFileName = @"c:\ironruby\ir.exe";
fileService = new MockRubyFileService();
MockMessageService messageService = new MockMessageService();
testRunner = new RubyTestRunner(processRunner, testResultsMonitor, options, fileService);
RubyTestRunnerContext context = new RubyTestRunnerContext(processRunner, testResultsMonitor, options, fileService, messageService);
testRunner = new RubyTestRunner(context);
}
void CreateTestMethod()

5
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockRubyFileService.cs

@ -54,5 +54,10 @@ namespace RubyBinding.Tests.Utils @@ -54,5 +54,10 @@ namespace RubyBinding.Tests.Utils
get { return fileNameDeleted; }
set { fileNameDeleted = value; }
}
public bool FileExists(string fileName)
{
return true;
}
}
}

Loading…
Cancel
Save