diff --git a/src/Giles.Core/Configuration/GilesConfig.cs b/src/Giles.Core/Configuration/GilesConfig.cs index 5dfa064..4f1d25e 100644 --- a/src/Giles.Core/Configuration/GilesConfig.cs +++ b/src/Giles.Core/Configuration/GilesConfig.cs @@ -6,8 +6,13 @@ namespace Giles.Core.Configuration public class GilesConfig : INotifyPropertyChanged { public IDictionary TestRunners = new Dictionary(); + public string TestAssemblyPath { get; set; } + public string SolutionPath { get; set; } + + public string ProjectRoot { get; set; } + long buildDelay = 500; public event PropertyChangedEventHandler PropertyChanged; diff --git a/src/Giles.Core/Configuration/GilesConfigFactory.cs b/src/Giles.Core/Configuration/GilesConfigFactory.cs index b53a381..ab5ebe6 100644 --- a/src/Giles.Core/Configuration/GilesConfigFactory.cs +++ b/src/Giles.Core/Configuration/GilesConfigFactory.cs @@ -11,16 +11,17 @@ public class GilesConfigFactory readonly IFileSystem fileSystem; readonly string solutionPath; readonly string testAssemblyPath; - readonly string solutionFolder; + readonly string projectRoot; readonly string[] supportedRunners; - public GilesConfigFactory(GilesConfig config, IFileSystem fileSystem, string solutionPath, string testAssemblyPath) + public GilesConfigFactory(GilesConfig config, IFileSystem fileSystem, string solutionPath, string testAssemblyPath, string projectRoot) { this.config = config; this.fileSystem = fileSystem; this.solutionPath = solutionPath; this.testAssemblyPath = testAssemblyPath; - solutionFolder = fileSystem.GetDirectoryName(solutionPath); + this.projectRoot = projectRoot; + supportedRunners = new[] {"mspec.exe", "nunit-console.exe"}; } @@ -35,17 +36,17 @@ public GilesConfig Build() void LocateTestRunners() { supportedRunners.Each(x => - { - var files = fileSystem.GetFiles(solutionFolder, x, - SearchOption.AllDirectories); + { + var files = fileSystem.GetFiles(projectRoot, x, + SearchOption.AllDirectories); - config.TestRunners.Add(x, - new RunnerAssembly - { - Path = files.FirstOrDefault(), - Enabled = !string.IsNullOrWhiteSpace(files.FirstOrDefault()) - }); - }); + config.TestRunners.Add(x, + new RunnerAssembly + { + Path = files.FirstOrDefault(), + Enabled = !string.IsNullOrWhiteSpace(files.FirstOrDefault()) + }); + }); } } } \ No newline at end of file diff --git a/src/Giles.Specs/Core/Configuration/GilesConfigFactorySpecs.cs b/src/Giles.Specs/Core/Configuration/GilesConfigFactorySpecs.cs index c6ee0e8..1f67c2e 100644 --- a/src/Giles.Specs/Core/Configuration/GilesConfigFactorySpecs.cs +++ b/src/Giles.Specs/Core/Configuration/GilesConfigFactorySpecs.cs @@ -17,20 +17,22 @@ public class a_giles_config protected static string solutionFolder; protected static string testRunnerExe; protected static string testAssemblyPath; + protected static string projectRoot; Establish context = () => { - solutionFolder = @"c:\solutionFolder"; - solutionPath = @"c:\solutionFolder\mySolution.sln"; - testAssemblyPath = @"c:\solutionFolder\tests\bin\debug\tests.dll"; + solutionFolder = @"c:\solutionRoot\solution"; + solutionPath = @"c:\solutionRoot\solution\mySolution.sln"; + testAssemblyPath = @"c:\solutionRoot\solution\tests\bin\debug\tests.dll"; fileSystem = Substitute.For(); testRunnerExe = @"c:\testAssembly.exe"; fileSystem.GetFiles(Arg.Any(), Arg.Any(), SearchOption.AllDirectories) .Returns(new[] { testRunnerExe }); fileSystem.GetDirectoryName(solutionPath).Returns(solutionFolder); + projectRoot = @"c:\solutionRoot"; config = new GilesConfig(); - factory = new GilesConfigFactory(config, fileSystem, solutionPath, testAssemblyPath); + factory = new GilesConfigFactory(config, fileSystem, solutionPath, testAssemblyPath, projectRoot); }; } @@ -40,14 +42,11 @@ public class when_building : a_giles_config Because of = () => factory.Build(); - It gets_the_solution_folder = () => - fileSystem.Received().GetDirectoryName(solutionPath); - It locates_the_mspec_test_runner = () => - fileSystem.Received().GetFiles(solutionFolder, "mspec.exe", SearchOption.AllDirectories); + fileSystem.Received().GetFiles(projectRoot, "mspec.exe", SearchOption.AllDirectories); It locates_the_nunit_test_runner = () => - fileSystem.Received().GetFiles(solutionFolder, "nunit-console.exe", SearchOption.AllDirectories); + fileSystem.Received().GetFiles(projectRoot, "nunit-console.exe", SearchOption.AllDirectories); It built_the_correct_config_test_runners = () => config.TestRunners.All(x => x.Value.Path == testRunnerExe).ShouldBeTrue(); diff --git a/src/Giles/Program.cs b/src/Giles/Program.cs index 9483c61..fb417a2 100644 --- a/src/Giles/Program.cs +++ b/src/Giles/Program.cs @@ -18,10 +18,11 @@ static void Main(string[] args) var solutionPath = args[0]; var testAssemblyPath = args[1]; + var projectRoot = args[2]; //solutionPath = @"D:\Dev\Prototypes\TestableTestStuff\TestableTestStuff.sln"; //testAssemblyPath = @"D:\Dev\Prototypes\TestableTestStuff\ClassThatDoesShit.Tests\bin\Debug\Teh.Tests.dll"; - var kernel = new StandardKernel(new SlayerModule(solutionPath, testAssemblyPath)); + var kernel = new StandardKernel(new SlayerModule(solutionPath, testAssemblyPath, projectRoot)); var configFactory = kernel.Get(); config = configFactory.Build(); @@ -89,6 +90,7 @@ static void DisplayConfig() Console.WriteLine("\nCurrent Configuration"); Console.WriteLine(" Build Delay: " + config.BuildDelay); Console.WriteLine(" Solution: " + config.SolutionPath); + Console.WriteLine(" Project Root: " + config.ProjectRoot); Console.WriteLine(" Test Assembly: " + config.TestAssemblyPath); Console.WriteLine(); } diff --git a/src/Giles/SlayerModule.cs b/src/Giles/SlayerModule.cs index 86b21ad..aa8c507 100644 --- a/src/Giles/SlayerModule.cs +++ b/src/Giles/SlayerModule.cs @@ -10,11 +10,13 @@ public class SlayerModule : NinjectModule { readonly string solutionPath; readonly string testAssemblyPath; + readonly string projectRoot; - public SlayerModule(string solutionPath, string testAssemblyPath) + public SlayerModule(string solutionPath, string testAssemblyPath, string projectRoot) { this.solutionPath = solutionPath; this.testAssemblyPath = testAssemblyPath; + this.projectRoot = projectRoot; } public override void Load() @@ -27,7 +29,8 @@ public override void Load() Bind().ToSelf().InSingletonScope(); Bind().ToSelf() .WithConstructorArgument("solutionPath", solutionPath) - .WithConstructorArgument("testAssemblyPath", testAssemblyPath); + .WithConstructorArgument("testAssemblyPath", testAssemblyPath) + .WithConstructorArgument("projectRoot", projectRoot); } } } \ No newline at end of file