/
GilesConfigFactory.cs
52 lines (46 loc) · 1.85 KB
/
GilesConfigFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System.IO;
using System.Linq;
using Giles.Core.IO;
using Machine.Specifications.Utility;
namespace Giles.Core.Configuration
{
public class GilesConfigFactory
{
readonly GilesConfig config;
readonly IFileSystem fileSystem;
readonly string solutionPath;
readonly string testAssemblyPath;
readonly string projectRoot;
readonly string[] supportedRunners;
public GilesConfigFactory(GilesConfig config, IFileSystem fileSystem, string solutionPath, string testAssemblyPath, string projectRoot)
{
this.config = config;
this.fileSystem = fileSystem;
this.solutionPath = solutionPath;
this.testAssemblyPath = testAssemblyPath;
this.projectRoot = projectRoot;
supportedRunners = new[] {"mspec.exe", "nunit-console.exe"};
}
public GilesConfig Build()
{
LocateTestRunners();
config.TestAssemblyPath = testAssemblyPath;
config.SolutionPath = solutionPath;
return config;
}
void LocateTestRunners()
{
supportedRunners.Each(x =>
{
var files = fileSystem.GetFiles(projectRoot, x,
SearchOption.AllDirectories);
config.TestRunners.Add(x,
new RunnerAssembly
{
Path = files.FirstOrDefault(),
Enabled = !string.IsNullOrWhiteSpace(files.FirstOrDefault())
});
});
}
}
}