Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5081 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
50 changed files with 8160 additions and 292 deletions
@ -1,41 +0,0 @@
@@ -1,41 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Util; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Process runner interface.
|
||||
/// </summary>
|
||||
public interface IProcessRunner |
||||
{ |
||||
/// <summary>
|
||||
/// Triggered when a line of text is read from the standard output.
|
||||
/// </summary>
|
||||
event LineReceivedEventHandler OutputLineReceived; |
||||
|
||||
/// <summary>
|
||||
/// Triggered when the process has exited.
|
||||
/// </summary>
|
||||
event EventHandler ProcessExited; |
||||
|
||||
/// <summary>
|
||||
/// Starts the process.
|
||||
/// </summary>
|
||||
/// <param name="command">The process filename.</param>
|
||||
/// <param name="arguments">The command line arguments to
|
||||
/// pass to the command.</param>
|
||||
void Start(string command, string arguments); |
||||
|
||||
/// <summary>
|
||||
/// Kills the running process.
|
||||
/// </summary>
|
||||
void Kill(); |
||||
} |
||||
} |
||||
@ -1,16 +0,0 @@
@@ -1,16 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Util; |
||||
|
||||
namespace ICSharpCode.PythonBinding |
||||
{ |
||||
public class PythonProcessRunner : ProcessRunner, IProcessRunner |
||||
{ |
||||
} |
||||
} |
||||
@ -1,132 +0,0 @@
@@ -1,132 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Util; |
||||
|
||||
namespace PythonBinding.Tests.Utils |
||||
{ |
||||
/// <summary>
|
||||
/// Dummy IProcessRunner class.
|
||||
/// </summary>
|
||||
public class MockProcessRunner : IProcessRunner |
||||
{ |
||||
string commandLine = String.Empty; |
||||
string outputText; |
||||
bool killCalled; |
||||
|
||||
/// <summary>
|
||||
/// Triggered when a line of text is read from the standard output.
|
||||
/// </summary>
|
||||
public event LineReceivedEventHandler OutputLineReceived; |
||||
|
||||
/// <summary>
|
||||
/// Triggered when the process has exited.
|
||||
/// </summary>
|
||||
public event EventHandler ProcessExited; |
||||
|
||||
public MockProcessRunner() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Starts the process.
|
||||
/// </summary>
|
||||
/// <param name="command">The process filename.</param>
|
||||
/// <param name="arguments">The command line arguments to
|
||||
/// pass to the command.</param>
|
||||
public void Start(string command, string arguments) |
||||
{ |
||||
commandLine = String.Concat(command, " ", arguments); |
||||
if (outputText != null) { |
||||
OnOutputLineReceived(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Kills the running process.
|
||||
/// </summary>
|
||||
public void Kill() |
||||
{ |
||||
killCalled = true; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the full command line used with the process runner.
|
||||
/// </summary>
|
||||
public string CommandLine { |
||||
get { |
||||
return commandLine; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The string will be sent to any OutputLineReceived event
|
||||
/// handler when the Start method is called.
|
||||
/// </summary>
|
||||
public string OutputText { |
||||
set { |
||||
outputText = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Raises the ProcessExited event.
|
||||
/// </summary>
|
||||
public void RaiseExitEvent() |
||||
{ |
||||
OnProcessExited(new EventArgs()); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the Kill method was called.
|
||||
/// </summary>
|
||||
public bool KillCalled { |
||||
get { |
||||
return killCalled; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Raises the ProcessExited event.
|
||||
/// </summary>
|
||||
void OnProcessExited(EventArgs e) |
||||
{ |
||||
if (ProcessExited != null) { |
||||
ProcessExited(this, e); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Raises the OutputLineReceived event.
|
||||
/// </summary>
|
||||
void OnOutputLineReceived(LineReceivedEventArgs e) |
||||
{ |
||||
if (OutputLineReceived != null) { |
||||
OutputLineReceived(this, e); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Raises an event for each line in the output text.
|
||||
/// </summary>
|
||||
void OnOutputLineReceived() |
||||
{ |
||||
using (StringReader reader = new StringReader(outputText)) { |
||||
string line; |
||||
do { |
||||
line = reader.ReadLine(); |
||||
if (line != null) { |
||||
OnOutputLineReceived(new LineReceivedEventArgs(line)); |
||||
} |
||||
} while (line != null); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,104 @@
@@ -0,0 +1,104 @@
|
||||
// <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 ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace UnitTesting.Tests.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that the test methods of a second parent base class are detected:
|
||||
///
|
||||
/// class BaseBaseTestFixture { [Test] public void BaseBaseTest() ... }
|
||||
/// class BaseTestFixture : BaseBaseTestFixture ...
|
||||
/// class TestFixture : BaseTestFixture
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class TwoBaseClassesWithTestMethodsTestFixture |
||||
{ |
||||
TestClass testClass; |
||||
MockClass c; |
||||
|
||||
[SetUp] |
||||
public void SetUp() |
||||
{ |
||||
MockProjectContent projectContent = new MockProjectContent(); |
||||
projectContent.Language = LanguageProperties.None; |
||||
|
||||
// Create the top base test class.
|
||||
MockClass baseBaseClass = new MockClass("ICSharpCode.SharpDevelop.Tests.BaseBaseTestFixture"); |
||||
baseBaseClass.ProjectContent = projectContent; |
||||
MockMethod baseMethod = new MockMethod("BaseBaseTest"); |
||||
baseMethod.Attributes.Add(new MockAttribute("Test")); |
||||
baseMethod.DeclaringType = baseBaseClass; |
||||
baseBaseClass.Methods.Add(baseMethod); |
||||
|
||||
// Create the next level test class.
|
||||
MockClass baseClass = new MockClass("ICSharpCode.SharpDevelop.Tests.BaseTestFixture"); |
||||
baseClass.ProjectContent = projectContent; |
||||
baseMethod = new MockMethod("BaseTest"); |
||||
baseMethod.Attributes.Add(new MockAttribute("Test")); |
||||
baseMethod.DeclaringType = baseClass; |
||||
baseClass.Methods.Add(baseMethod); |
||||
|
||||
// Create the derived test class.
|
||||
c = new MockClass("ICSharpCode.SharpDevelop.Tests.MainTestFixture"); |
||||
c.Attributes.Add(new MockAttribute("TestFixture")); |
||||
c.ProjectContent = projectContent; |
||||
projectContent.Classes.Add(c); |
||||
|
||||
// Set the base class for each class in the hierarchy.
|
||||
c.BaseClass = baseClass; |
||||
baseClass.BaseClass = baseBaseClass; |
||||
|
||||
// Create TestClass.
|
||||
testClass = new TestClass(c); |
||||
} |
||||
|
||||
[Test] |
||||
public void BaseBaseTestMethodExists() |
||||
{ |
||||
Assert.IsTrue(testClass.TestMethods.Contains("BaseBaseTestFixture.BaseBaseTest")); |
||||
} |
||||
|
||||
[Test] |
||||
public void BaseMethodExists() |
||||
{ |
||||
Assert.IsTrue(testClass.TestMethods.Contains("BaseTestFixture.BaseTest")); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The TestMethod.Method property should return an IMethod
|
||||
/// that returns the derived class from the DeclaringType property
|
||||
/// and not the base class. This ensures that the correct
|
||||
/// test is run when selected in the unit test tree.
|
||||
/// </summary>
|
||||
[Test] |
||||
public void BaseBaseMethodDeclaringTypeIsDerivedClass() |
||||
{ |
||||
TestMethod method = testClass.TestMethods["BaseBaseTestFixture.BaseBaseTest"]; |
||||
Assert.AreEqual(c, method.Method.DeclaringType); |
||||
} |
||||
|
||||
[Test] |
||||
public void UpdateTestResult() |
||||
{ |
||||
TestClassCollection testClasses = new TestClassCollection(); |
||||
testClasses.Add(testClass); |
||||
|
||||
TestResult testResult = new TestResult("ICSharpCode.SharpDevelop.Tests.MainTestFixture.BaseBaseTest"); |
||||
testResult.IsFailure = true; |
||||
testClasses.UpdateTestResult(testResult); |
||||
|
||||
Assert.AreEqual(TestResultType.Failure, testClass.Result); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue