Browse Source

Fix Gallio sample.

Compile Gallio extension with AnyCPU so it works on x64 Windows.
pull/39/merge
Matt Ward 12 years ago
parent
commit
245c2bd9ca
  1. 8
      samples/Gallio/Gallio.Extension/Gallio.Extension.csproj
  2. 7
      samples/Gallio/Gallio.SharpDevelop.Tests/Gallio.SharpDevelop.Tests.csproj
  3. 42
      samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestFrameworkIsTestMemberTests.cs
  4. 3
      samples/Gallio/Gallio.SharpDevelop/Gallio.SharpDevelop.csproj
  5. 19
      samples/Gallio/Gallio.SharpDevelop/GallioTestFramework.cs

8
samples/Gallio/Gallio.Extension/Gallio.Extension.csproj

@ -12,14 +12,17 @@
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib> <NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<NoWin32Manifest>False</NoWin32Manifest>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' "> <PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop> <RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress> <BaseAddress>4194304</BaseAddress>
<FileAlignment>4096</FileAlignment> <FileAlignment>4096</FileAlignment>
<Prefer32Bit>False</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
@ -28,6 +31,7 @@
<Optimize>False</Optimize> <Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

7
samples/Gallio/Gallio.SharpDevelop.Tests/Gallio.SharpDevelop.Tests.csproj

@ -51,16 +51,13 @@
<Reference Include="ICSharpCode.SharpDevelop.Dom"> <Reference Include="ICSharpCode.SharpDevelop.Dom">
<HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.Dom.dll</HintPath> <HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.Dom.dll</HintPath>
</Reference> </Reference>
<Reference Include="ICSharpCode.SharpDevelop.Dom">
<HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.Dom.dll</HintPath>
</Reference>
<Reference Include="nunit.framework"> <Reference Include="nunit.framework">
<HintPath>..\..\..\bin\Tools\NUnit\nunit.framework.dll</HintPath> <HintPath>..\..\..\bin\Tools\NUnit\nunit.framework.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="UnitTesting"> <Reference Include="UnitTesting">
<HintPath>..\..\..\AddIns\AddIns\Misc\UnitTesting\UnitTesting.dll</HintPath> <HintPath>..\..\..\AddIns\Analysis\UnitTesting\UnitTesting.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnitTesting.Tests"> <Reference Include="UnitTesting.Tests">
<HintPath>..\..\..\bin\UnitTests\UnitTesting.Tests.dll</HintPath> <HintPath>..\..\..\bin\UnitTests\UnitTesting.Tests.dll</HintPath>
@ -80,7 +77,7 @@
<Compile Include="GallioEchoConsoleProcessStartInfoTestFixture.cs" /> <Compile Include="GallioEchoConsoleProcessStartInfoTestFixture.cs" />
<Compile Include="GallioTestFailureTestFixture.cs" /> <Compile Include="GallioTestFailureTestFixture.cs" />
<Compile Include="GallioTestFrameworkIsTestClassTests.cs" /> <Compile Include="GallioTestFrameworkIsTestClassTests.cs" />
<Compile Include="GallioTestFrameworkIsTestMethodTests.cs" /> <Compile Include="GallioTestFrameworkIsTestMemberTests.cs" />
<Compile Include="GallioTestFrameworkIsTestProjectTests.cs" /> <Compile Include="GallioTestFrameworkIsTestProjectTests.cs" />
<Compile Include="GallioTestToSharpDevelopTestResultConversionTests.cs" /> <Compile Include="GallioTestToSharpDevelopTestResultConversionTests.cs" />
<Compile Include="TestResultsWriterTestFixture.cs" /> <Compile Include="TestResultsWriterTestFixture.cs" />

42
samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestFrameworkIsTestMethodTests.cs → samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestFrameworkIsTestMemberTests.cs

@ -17,7 +17,7 @@ using UnitTesting.Tests.Utils;
namespace Gallio.SharpDevelop.Tests namespace Gallio.SharpDevelop.Tests
{ {
[TestFixture] [TestFixture]
public class GallioTestFrameworkIsTestMethodTests public class GallioTestFrameworkIsTestMemberTests
{ {
GallioTestFramework testFramework; GallioTestFramework testFramework;
@ -28,44 +28,44 @@ namespace Gallio.SharpDevelop.Tests
} }
[Test] [Test]
public void IsTestMethodReturnsFalseWhenMethodHasNoAttributes() public void IsTestMemberReturnsFalseWhenMethodHasNoAttributes()
{ {
MockMethod mockMethod = MockMethod.CreateMockMethodWithoutAnyAttributes(); MockMethod mockMethod = MockMethod.CreateMockMethodWithoutAnyAttributes();
Assert.IsFalse(testFramework.IsTestMethod(mockMethod)); Assert.IsFalse(testFramework.IsTestMember(mockMethod));
} }
[Test] [Test]
public void IsTestMethodReturnsTrueWhenMethodHasTestAttributeWithoutAttributePart() public void IsTestMemberReturnsTrueWhenMethodHasTestAttributeWithoutAttributePart()
{ {
MockAttribute testAttribute = new MockAttribute("Test"); MockAttribute testAttribute = new MockAttribute("Test");
MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute); MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
Assert.IsTrue(testFramework.IsTestMethod(mockMethod)); Assert.IsTrue(testFramework.IsTestMember(mockMethod));
} }
[Test] [Test]
public void IsTestMethodReturnsTrueWhenMethodHasTestAttributeAttribute() public void IsTestMemberReturnsTrueWhenMethodHasTestAttributeAttribute()
{ {
MockAttribute testAttribute = new MockAttribute("TestAttribute"); MockAttribute testAttribute = new MockAttribute("TestAttribute");
MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute); MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
Assert.IsTrue(testFramework.IsTestMethod(mockMethod)); Assert.IsTrue(testFramework.IsTestMember(mockMethod));
} }
[Test] [Test]
public void IsTestMethodReturnsTrueWhenMethodHasFullyQualifiedNUnitTestAttribute() public void IsTestMemberReturnsTrueWhenMethodHasFullyQualifiedNUnitTestAttribute()
{ {
MockAttribute testAttribute = new MockAttribute("MbUnit.Framework.TestAttribute"); MockAttribute testAttribute = new MockAttribute("MbUnit.Framework.TestAttribute");
MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute); MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
Assert.IsTrue(testFramework.IsTestMethod(mockMethod)); Assert.IsTrue(testFramework.IsTestMember(mockMethod));
} }
[Test] [Test]
public void IsTestMethodReturnsFalseWhenMethodIsNull() public void IsTestMemberReturnsFalseWhenMethodIsNull()
{ {
Assert.IsFalse(testFramework.IsTestMethod(null)); Assert.IsFalse(testFramework.IsTestMember(null));
} }
[Test] [Test]
public void IsTestMethodReturnsFalseWhenProjectContentLanguageHasNullNameComparer() public void IsTestMemberReturnsFalseWhenProjectContentLanguageHasNullNameComparer()
{ {
IProject project = new MockCSharpProject(); IProject project = new MockCSharpProject();
MockProjectContent mockProjectContent = new MockProjectContent(); MockProjectContent mockProjectContent = new MockProjectContent();
@ -75,7 +75,7 @@ namespace Gallio.SharpDevelop.Tests
MockMethod mockMethod = new MockMethod(mockClass); MockMethod mockMethod = new MockMethod(mockClass);
mockMethod.Attributes.Add(new MockAttribute("Test")); mockMethod.Attributes.Add(new MockAttribute("Test"));
Assert.IsFalse(testFramework.IsTestMethod(mockMethod)); Assert.IsFalse(testFramework.IsTestMember(mockMethod));
} }
/// <summary> /// <summary>
@ -83,26 +83,26 @@ namespace Gallio.SharpDevelop.Tests
/// flagged as a TestMethod. /// flagged as a TestMethod.
/// </summary> /// </summary>
[Test] [Test]
public void IsTestMethodReturnsTrueWhenProjectIsNull() public void IsTestMemberReturnsTrueWhenProjectIsNull()
{ {
MockAttribute testAttribute = new MockAttribute("Test"); MockAttribute testAttribute = new MockAttribute("Test");
MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute); MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
MockProjectContent mockProjectContent = (MockProjectContent)mockMethod.DeclaringType.ProjectContent; MockProjectContent mockProjectContent = (MockProjectContent)mockMethod.DeclaringType.ProjectContent;
mockProjectContent.Project = null; mockProjectContent.Project = null;
Assert.IsTrue(testFramework.IsTestMethod(mockMethod)); Assert.IsTrue(testFramework.IsTestMember(mockMethod));
} }
[Test] [Test]
public void IsTestMethodReturnsFalseWhenMethodHasNullDeclaringType() public void IsTestMemberReturnsFalseWhenMethodHasNullDeclaringType()
{ {
MockMethod mockMethod = new MockMethod(new MockClass()); MockMethod mockMethod = new MockMethod(new MockClass());
Assert.IsFalse(testFramework.IsTestMethod(mockMethod)); Assert.IsFalse(testFramework.IsTestMember(mockMethod));
} }
[Test] [Test]
public void IsTestMethodReturnsFalseWhenMethodHasNullLanguage() public void IsTestMemberReturnsFalseWhenMethodHasNullLanguage()
{ {
IProject project = new MockCSharpProject(); IProject project = new MockCSharpProject();
MockProjectContent mockProjectContent = new MockProjectContent(); MockProjectContent mockProjectContent = new MockProjectContent();
@ -110,18 +110,18 @@ namespace Gallio.SharpDevelop.Tests
MockClass mockClass = new MockClass(mockProjectContent); MockClass mockClass = new MockClass(mockProjectContent);
MockMethod mockMethod = new MockMethod(mockClass); MockMethod mockMethod = new MockMethod(mockClass);
Assert.IsFalse(testFramework.IsTestMethod(mockMethod)); Assert.IsFalse(testFramework.IsTestMember(mockMethod));
} }
[Test] [Test]
public void IsTestMethodReturnsFalseWhenMethodHasHasParameters() public void IsTestMemberReturnsFalseWhenMethodHasHasParameters()
{ {
MockAttribute testAttribute = new MockAttribute("Test"); MockAttribute testAttribute = new MockAttribute("Test");
MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute); MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
MockParameter mockParameter = new MockParameter(); MockParameter mockParameter = new MockParameter();
mockMethod.Parameters.Add(mockParameter); mockMethod.Parameters.Add(mockParameter);
Assert.IsFalse(testFramework.IsTestMethod(mockMethod)); Assert.IsFalse(testFramework.IsTestMember(mockMethod));
} }
} }
} }

3
samples/Gallio/Gallio.SharpDevelop/Gallio.SharpDevelop.csproj

@ -58,8 +58,7 @@
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="UnitTesting"> <Reference Include="UnitTesting">
<HintPath>..\..\..\AddIns\AddIns\Misc\UnitTesting\UnitTesting.dll</HintPath> <HintPath>..\..\..\AddIns\Analysis\UnitTesting\UnitTesting.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

19
samples/Gallio/Gallio.SharpDevelop/GallioTestFramework.cs

@ -6,6 +6,9 @@
// </file> // </file>
using System; using System;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting; using ICSharpCode.UnitTesting;
@ -78,12 +81,26 @@ namespace Gallio.SharpDevelop
return null; return null;
} }
public bool IsTestMember(IMember member)
{
var method = member as IMethod;
if (method != null) {
return IsTestMethod(method);
}
return false;
}
public IEnumerable<TestMember> GetTestMembersFor(IClass c)
{
return c.Methods.Where(IsTestMethod).Select(member => new TestMember(member));
}
/// <summary> /// <summary>
/// Determines whether the method is a test method. A method /// Determines whether the method is a test method. A method
/// is considered to be a test method if it contains the NUnit Test attribute. /// is considered to be a test method if it contains the NUnit Test attribute.
/// If the method has parameters it cannot be a test method. /// If the method has parameters it cannot be a test method.
/// </summary> /// </summary>
public bool IsTestMethod(IMember member) bool IsTestMethod(IMember member)
{ {
if (member == null) { if (member == null) {
return false; return false;

Loading…
Cancel
Save