Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2580 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
8 changed files with 171 additions and 6 deletions
@ -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.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.UnitTesting |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a test method that exists in a base class.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// In order to have the Unit Test tree run the correct
|
||||
/// test when we have a class that has a base class with
|
||||
/// test methods is to return the derived class from the
|
||||
/// DeclaringType's property. Otherwise the base class
|
||||
/// method is tested and the derived class is not used.
|
||||
/// </remarks>
|
||||
public class BaseTestMethod : DefaultMethod |
||||
{ |
||||
IMethod method; |
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the BaseTestMethod.
|
||||
/// </summary>
|
||||
/// <param name="derivedClass">The derived class and not
|
||||
/// the class where the method is actually defined.</param>
|
||||
/// <param name="method">The base class's test method.</param>
|
||||
public BaseTestMethod(IClass derivedClass, IMethod method) |
||||
: base(method.Name, method.ReturnType, method.Modifiers, method.Region, method.BodyRegion, derivedClass) |
||||
{ |
||||
this.method = method; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the actual method used to create this object.
|
||||
/// </summary>
|
||||
public IMethod Method { |
||||
get { return method; } |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,91 @@
@@ -0,0 +1,91 @@
|
||||
// <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.UnitTesting; |
||||
using NUnit.Framework; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace UnitTesting.Tests.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that the BaseTestMethod populates the various
|
||||
/// properties of the DefaultMethod class in its constructor.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class BaseTestMethodTestFixture |
||||
{ |
||||
MockClass mockClass; |
||||
MockMethod mockMethod; |
||||
BaseTestMethod baseTestMethod; |
||||
DomRegion mockMethodRegion; |
||||
DomRegion mockMethodBodyRegion; |
||||
DefaultReturnType returnType; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
mockClass = new MockClass("Tests.MyTestFixture"); |
||||
mockMethod = new MockMethod("MyMethod"); |
||||
|
||||
mockMethodRegion = new DomRegion(0, 0, 0, 10); |
||||
mockMethod.Region = mockMethodRegion; |
||||
mockMethodBodyRegion = new DomRegion(1, 0, 2, 5); |
||||
mockMethod.BodyRegion = mockMethodBodyRegion; |
||||
mockMethod.Modifiers = ModifierEnum.Public; |
||||
|
||||
MockClass returnTypeClass = new MockClass("Tests.ReturnType"); |
||||
returnType = new DefaultReturnType(returnTypeClass); |
||||
mockMethod.ReturnType = returnType; |
||||
|
||||
baseTestMethod = new BaseTestMethod(mockClass, mockMethod); |
||||
} |
||||
|
||||
[Test] |
||||
public void MethodName() |
||||
{ |
||||
Assert.AreEqual("MyMethod", baseTestMethod.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void DeclaringType() |
||||
{ |
||||
Assert.AreEqual(mockClass, baseTestMethod.DeclaringType); |
||||
} |
||||
|
||||
[Test] |
||||
public void ActualMethod() |
||||
{ |
||||
Assert.AreEqual(mockMethod, baseTestMethod.Method); |
||||
} |
||||
|
||||
[Test] |
||||
public void MethodRegion() |
||||
{ |
||||
Assert.AreEqual(mockMethodRegion, baseTestMethod.Region); |
||||
} |
||||
|
||||
[Test] |
||||
public void MethodBodyRegion() |
||||
{ |
||||
Assert.AreEqual(mockMethodBodyRegion, baseTestMethod.BodyRegion); |
||||
} |
||||
|
||||
[Test] |
||||
public void Modifiers() |
||||
{ |
||||
Assert.AreEqual(ModifierEnum.Public, baseTestMethod.Modifiers); |
||||
} |
||||
|
||||
[Test] |
||||
public void ReturnType() |
||||
{ |
||||
Assert.IsTrue(Object.ReferenceEquals(returnType, baseTestMethod.ReturnType)); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue