Skip to content

Commit

Permalink
Category inheritance feature spec added.
Browse files Browse the repository at this point in the history
  • Loading branch information
drunkcod committed Aug 30, 2014
1 parent 6be70a1 commit 14ae897
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Source/Core/IConeSuite.cs
Expand Up @@ -8,10 +8,10 @@ public interface IConeEntity
IEnumerable<string> Categories { get; }
}

public interface IConeSuite : IConeEntity
{
void AddCategories(IEnumerable<string> categories);
public interface IConeSuite : IConeEntity
{
void AddCategories(IEnumerable<string> categories);
IRowSuite AddRowSuite(ConeMethodThunk thunk, string suiteName);
void DiscoverTests(ConeTestNamer names);
}
}
}
5 changes: 5 additions & 0 deletions Source/Runners/ConePadSuite.cs
Expand Up @@ -152,5 +152,10 @@ class ConePadRowSuite : IRowSuite
public void Run(Action<IEnumerable<IConeTest>, IConeFixture> collectResults) {
collectResults(tests, fixture);
}

public void RunAll(Action<IEnumerable<IConeTest>, IConeFixture> collectResults) {
Run(collectResults);
Subsuites.Flatten(x => x.Subsuites).ForEach(x => x.Run(collectResults));
}
}
}
1 change: 1 addition & 0 deletions Specs/Cone.Specs/Cone.Specs.csproj
Expand Up @@ -59,6 +59,7 @@
<Compile Include="Core\MethodExpectProviderLookupSpec.cs" />
<Compile Include="Core\MissingLinqSpec.cs" />
<Compile Include="Core\TypeFormatterSpec.cs" />
<Compile Include="Features\CategoryHandlingFeature.cs" />
<Compile Include="Features\RowTests.cs" />
<Compile Include="Helpers\EventSpySpec.cs" />
<Compile Include="Runners\MSTestSuiteBuilderSpec.cs" />
Expand Down
44 changes: 44 additions & 0 deletions Specs/Cone.Specs/Features/CategoryHandlingFeature.cs
@@ -0,0 +1,44 @@
using Cone.Core;
using Cone.Runners;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Cone.Features
{
[Feature("Category Handling")]
public class CategoryHandlingFeature
{
[Feature("Sugar Sweet")]
class ExampleSpec {
[Context("I'm Sugar", Category = "Sugar")]
public class ExampleSugarSpec
{
public void sugar() { }

[Context("I'm Sweet", Category = "Sweet")]
public class ExampleSugarSweetSpec
{
public void sugar_sweet() { }
}
}
}

public void categories_are_lexically_inherited() {
var suite = new ConePadSuiteBuilder(new DefaultObjectProvider())
.BuildSuite(typeof(ExampleSpec));

var result = new List<string>();
suite.RunAll((tests, fixture) => {
result.AddRange(tests.Select(test => test.TestName.Name + " - " + string.Join(",", test.Categories)));
});

Check.That(
() => result.Contains("sugar - Sugar"),
() => result.Contains("sugar sweet - Sugar,Sweet")
);
}

}
}

0 comments on commit 14ae897

Please sign in to comment.