main
1using System.Collections.Generic;
2using System.Linq;
3using System.Reflection;
4
5namespace Spec.Dox.Domain.Repositories
6{
7 public interface ITestContextRepository
8 {
9 IEnumerable<ITestContext> All(string path_to_assembly);
10 }
11
12 public class TestContextRepository : ITestContextRepository
13 {
14 ITypeContainsSpecifications criteria;
15
16 public TestContextRepository() : this(new TypeContainsSpecifications()) {}
17
18 public TestContextRepository(ITypeContainsSpecifications criteria)
19 {
20 this.criteria = criteria;
21 }
22
23 public IEnumerable<ITestContext> All(string path_to_assembly)
24 {
25 return Assembly
26 .LoadFrom(path_to_assembly)
27 .GetTypes()
28 .Where(type => criteria.IsSatisfiedBy(type))
29 .Select(type => new TestContext(type))
30 .Cast<ITestContext>()
31 ;
32 }
33 }
34}