Skip to content

Commit

Permalink
Putting tests around TestFrameworkResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
codereflection committed May 19, 2011
1 parent 280f226 commit 122c884
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Giles.Core/Giles.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<Compile Include="Runners\IFrameworkRunner.cs" />
<Compile Include="Runners\IRunner.cs" />
<Compile Include="Runners\ITestListener.cs" />
<Compile Include="Runners\ITestRunnerResolver.cs" />
<Compile Include="Runners\FrameworkRunnerLocator.cs" />
<Compile Include="Runners\TestResult.cs" />
<Compile Include="Runners\TestRunner.cs" />
<Compile Include="Runners\TestRunnerResolver.cs" />
Expand Down
3 changes: 3 additions & 0 deletions src/Giles.Core/Runners/TestRunnerResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public TestRunnerResolver()

public IEnumerable<IFrameworkRunner> Resolve(Assembly assembly)
{
if (assembly == null)
return Enumerable.Empty<IFrameworkRunner>();

var referencedAssemblies = assembly.GetReferencedAssemblies();

var result =
Expand Down
67 changes: 67 additions & 0 deletions src/Giles.Specs/Core/Runners/TestRunnerResolverSpecs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Giles.Core.Runners;
using Machine.Specifications;

namespace Giles.Specs.Core.Runners
{
public class with_a_test_runner_resolver
{
protected static TestRunnerResolver subject;

Establish context = () =>
subject = new TestRunnerResolver();
}

public class when_resolving_for_a_test_runner_in_an_assembly_without_a_test_framework
: with_a_test_runner_resolver
{
static Assembly assembly;
static IEnumerable<IFrameworkRunner> result;

Establish context = () =>
assembly = typeof(TestRunnerResolver).Assembly;

Because of = () =>
result = subject.Resolve(assembly);

It should_return_an_empty_list_of_framework_runners = () =>
result.ShouldBeEmpty();
}

public class when_resolving_for_the_mspec_runner_in_an_assembly_that_references_mspec
: with_a_test_runner_resolver
{
static Assembly assemby;
static IEnumerable<IFrameworkRunner> result;

Establish context = () =>
assemby = typeof(with_a_test_runner_resolver).Assembly;

Because of = () =>
result = subject.Resolve(assemby);

It should_return_a_result = () =>
result.ShouldNotBeEmpty();

It should_return_the_mspec_framework_runner = () =>
result.First().ShouldBeOfType<Giles.Runner.Machine.Specifications.SpecificationRunner>();
}

public class when_resolving_for_a_test_runner_and_an_assembly_is_not_passed
: with_a_test_runner_resolver
{
static Assembly assembly;
static IEnumerable<IFrameworkRunner> result;

Establish context = () =>
assembly = null;

Because of = () =>
result = subject.Resolve(assembly);

It should_return_an_empty_list_of_framework_runners = () =>
result.ShouldBeEmpty();
}
}
5 changes: 5 additions & 0 deletions src/Giles.Specs/Giles.Specs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<Compile Include="Core\Runners\BuildRunnerSpecs.cs" />
<Compile Include="Core\Runners\CommandProcessExecutorSpecs.cs" />
<Compile Include="Core\Runners\FakeUserDisplay.cs" />
<Compile Include="Core\Runners\TestRunnerResolverSpecs.cs" />
<Compile Include="Core\Runners\TestRunnerSpecs.cs" />
<Compile Include="Core\Watchers\SourceWatcherSpecs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand All @@ -76,6 +77,10 @@
<Project>{9039E7FA-989E-46ED-B031-FB67571E8385}</Project>
<Name>Giles.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Runners\Giles.Runner.Machine.Specifications\Giles.Runner.Machine.Specifications.csproj">
<Project>{88C6CC22-B9F2-41B8-8E4F-9500902AF874}</Project>
<Name>Giles.Runner.Machine.Specifications</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down

0 comments on commit 122c884

Please sign in to comment.