Browse Source

BaseTestMethod renamed to BaseTestMember and it's base class changed to AbstractMember.

pull/23/head
Tomasz Tretkowski 14 years ago
parent
commit
017bac76d6
  1. 2
      src/AddIns/Analysis/MachineSpecifications/MachineSpecifications/src/MSpecTestFramework.cs
  2. 66
      src/AddIns/Analysis/UnitTesting/Src/BaseTestMember.cs
  3. 42
      src/AddIns/Analysis/UnitTesting/Src/BaseTestMethod.cs
  4. 2
      src/AddIns/Analysis/UnitTesting/Src/TestClass.cs
  5. 4
      src/AddIns/Analysis/UnitTesting/Src/UnitTestCommands.cs
  6. 8
      src/AddIns/Analysis/UnitTesting/Test/Project/BaseTestMethodTestFixture.cs
  7. 4
      src/AddIns/Analysis/UnitTesting/Test/Project/TestClassIsTestMethodUsesTestFrameworksTestFixture.cs
  8. 2
      src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedBaseClassMethodTestFixture.cs
  9. 2
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockProjectContent.cs
  10. 2
      src/AddIns/Analysis/UnitTesting/UnitTesting.csproj

2
src/AddIns/Analysis/MachineSpecifications/MachineSpecifications/src/MSpecTestFramework.cs

@ -42,7 +42,7 @@ namespace ICSharpCode.MachineSpecifications @@ -42,7 +42,7 @@ namespace ICSharpCode.MachineSpecifications
{
var behaviorFields = ResolveBehaviorFieldsOf(field);
var behaviorTestMembers = GetTestMembers(testClass, behaviorFields);
var decoratedTestMembers = behaviorTestMembers.Select(f => new BaseTestMethod(testClass, f)).Cast<IMember>();
var decoratedTestMembers = behaviorTestMembers.Select(f => new BaseTestMember(testClass, f)).Cast<IMember>();
result.AddRange(decoratedTestMembers);
}
return result;

66
src/AddIns/Analysis/UnitTesting/Src/BaseTestMember.cs

@ -0,0 +1,66 @@ @@ -0,0 +1,66 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.UnitTesting
{
/// <summary>
/// Represents a test member 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 members is to return the derived class from the
/// DeclaringType's property. Otherwise the base class
/// member is tested and the derived class is not used.
/// </remarks>
public class BaseTestMember : AbstractMember
{
IMember member;
/// <summary>
/// Creates a new instance of the BaseTestMember.
/// </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 member.</param>
public BaseTestMember(IClass derivedClass, IMember member)
: base(derivedClass, member.Name)
{
this.member = member;
this.ReturnType = member.ReturnType;
this.Modifiers = member.Modifiers;
this.Region = member.Region;
this.BodyRegion = member.BodyRegion;
this.Documentation = member.Documentation;
}
/// <summary>
/// Gets the actual method used to create this object.
/// </summary>
public IMember Member {
get { return member; }
}
public override EntityType EntityType {
get {
return member.EntityType;
}
}
public override string DocumentationTag {
get {
return null;
}
}
public override string Documentation {get;set;}
public override IMember Clone()
{
return new BaseTestMember(DeclaringType, Member);
}
}
}

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

@ -1,42 +0,0 @@ @@ -1,42 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
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
{
IMember 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, IMember 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 IMember Method {
get { return method; }
}
}
}

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

@ -289,7 +289,7 @@ namespace ICSharpCode.UnitTesting @@ -289,7 +289,7 @@ namespace ICSharpCode.UnitTesting
IClass declaringType = c;
while (c.BaseClass != null) {
foreach (var method in testFrameworks.GetTestMembersFor(c.BaseClass)) {
BaseTestMethod baseTestMethod = new BaseTestMethod(declaringType, method);
BaseTestMember baseTestMethod = new BaseTestMember(declaringType, method);
TestMember testMethod = new TestMember(c.BaseClass.Name, baseTestMethod);
if (method.IsVirtual) {
if (!testMembers.Contains(method.Name)) {

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

@ -71,9 +71,9 @@ namespace ICSharpCode.UnitTesting @@ -71,9 +71,9 @@ namespace ICSharpCode.UnitTesting
{
IMember member = treeView.SelectedMember;
if (member != null) {
BaseTestMethod baseTestMethod = member as BaseTestMethod;
BaseTestMember baseTestMethod = member as BaseTestMember;
if (baseTestMethod != null) {
return baseTestMethod.Method;
return baseTestMethod.Member;
}
}
return member;

8
src/AddIns/Analysis/UnitTesting/Test/Project/BaseTestMethodTestFixture.cs

@ -18,7 +18,7 @@ namespace UnitTesting.Tests.Project @@ -18,7 +18,7 @@ namespace UnitTesting.Tests.Project
{
MockClass mockClass;
MockMethod mockMethod;
BaseTestMethod baseTestMethod;
BaseTestMember baseTestMethod;
DomRegion mockMethodRegion;
DomRegion mockMethodBodyRegion;
DefaultReturnType returnType;
@ -39,7 +39,7 @@ namespace UnitTesting.Tests.Project @@ -39,7 +39,7 @@ namespace UnitTesting.Tests.Project
returnType = new DefaultReturnType(returnTypeClass);
mockMethod.ReturnType = returnType;
baseTestMethod = new BaseTestMethod(mockClass, mockMethod);
baseTestMethod = new BaseTestMember(mockClass, mockMethod);
}
[Test]
@ -57,7 +57,7 @@ namespace UnitTesting.Tests.Project @@ -57,7 +57,7 @@ namespace UnitTesting.Tests.Project
[Test]
public void ActualMethod()
{
Assert.AreEqual(mockMethod, baseTestMethod.Method);
Assert.AreEqual(mockMethod, baseTestMethod.Member);
}
[Test]
@ -81,7 +81,7 @@ namespace UnitTesting.Tests.Project @@ -81,7 +81,7 @@ namespace UnitTesting.Tests.Project
[Test]
public void ReturnType()
{
Assert.IsTrue(Object.ReferenceEquals(returnType, baseTestMethod.ReturnType));
Assert.AreSame(returnType, baseTestMethod.ReturnType);
}
}
}

4
src/AddIns/Analysis/UnitTesting/Test/Project/TestClassIsTestMethodUsesTestFrameworksTestFixture.cs

@ -50,8 +50,8 @@ namespace UnitTesting.Tests.Project @@ -50,8 +50,8 @@ namespace UnitTesting.Tests.Project
[Test]
public void TestClassHasBaseClassTestMethod()
{
BaseTestMethod baseTestMethod = testClass.TestMembers[1].Member as BaseTestMethod;
Assert.AreEqual(baseClassTestMethod, baseTestMethod.Method);
BaseTestMember baseTestMethod = testClass.TestMembers[1].Member as BaseTestMember;
Assert.AreEqual(baseClassTestMethod, baseTestMethod.Member);
}
}
}

2
src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedBaseClassMethodTestFixture.cs

@ -30,7 +30,7 @@ namespace UnitTesting.Tests.Tree @@ -30,7 +30,7 @@ namespace UnitTesting.Tests.Tree
int methodBeginColumn = 6; // 1 based.
baseClassMethod.Region = new DomRegion(methodBeginLine, methodBeginColumn);
BaseTestMethod baseTestMethod = new BaseTestMethod(derivedClass, baseClassMethod);
BaseTestMember baseTestMethod = new BaseTestMember(derivedClass, baseClassMethod);
treeView = new MockTestTreeView();
treeView.SelectedMember = baseTestMethod;

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

@ -70,7 +70,7 @@ namespace UnitTesting.Tests.Utils @@ -70,7 +70,7 @@ namespace UnitTesting.Tests.Utils
public string GetXmlDocumentation(string memberTag)
{
throw new NotImplementedException();
return string.Empty;
}
public void AddClassToNamespaceList(IClass addClass)

2
src/AddIns/Analysis/UnitTesting/UnitTesting.csproj

@ -81,7 +81,7 @@ @@ -81,7 +81,7 @@
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
<Compile Include="Src\AllTestsTreeNode.cs" />
<Compile Include="Src\BaseTestMethod.cs" />
<Compile Include="Src\BaseTestMember.cs" />
<Compile Include="Src\EmptyUnitTestsPad.cs" />
<Compile Include="Src\IAddInTree.cs" />
<Compile Include="Src\IBuildOptions.cs" />

Loading…
Cancel
Save