Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #6 from mpareja/infer_parameters

Infer test assembly from solution and project files
  • Loading branch information...
commit 4de1f18a488d834d8341469c979e5cee5f63ac9b 2 parents cf92b06 + 099e130
@codereflection authored
View
151 src/Giles.Core/Configuration/MsBuildProject.cs
@@ -0,0 +1,151 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Xml;
+
+namespace Giles.Core.Configuration
+{
+ public class MsBuildProject
+ {
+ private readonly XmlDocument document;
+
+ public MsBuildProject(XmlDocument document)
+ {
+ this.document = document;
+ }
+
+ public static MsBuildProject Load(Stream projectFile)
+ {
+ var document = new XmlDocument();
+ document.Load(projectFile);
+
+ return new MsBuildProject(document);
+ }
+
+ public IEnumerable<string> GetLocalAssemblyRefs()
+ {
+ return (from XmlNode itemGroup in ProjectNode.ChildNodes
+ where itemGroup.Name == "ItemGroup"
+ from XmlNode refNode in itemGroup.ChildNodes
+ where refNode.Name == "Reference"
+ from XmlNode hintNode in refNode.ChildNodes
+ where hintNode.Name == "HintPath"
+ select hintNode.InnerText).ToArray();
+ }
+
+ public string GetAssemblyName()
+ {
+ var platformConfig = GetDefaultPlatformConfig();
+ return GetPropertyValue(platformConfig, "AssemblyName");
+ }
+
+ /// <summary>
+ /// Gets the output assembly file path relative to the
+ /// project files directory. Uses the project default
+ /// plaftorm configuration.
+ /// </summary>
+ /// <returns></returns>
+ public string GetAssemblyFilePath(string projectFilePath)
+ {
+ var platformConfig = GetDefaultPlatformConfig();
+ var dir = GetPropertyValue(platformConfig, "OutputPath");
+ var outtype = GetPropertyValue(platformConfig, "OutputType");
+
+ // FIXME: DLL or EXE
+ var assemblyName = GetPropertyValue(platformConfig, "AssemblyName");
+ switch(outtype.ToUpper())
+ {
+ case "LIBRARY":
+ assemblyName += ".dll";
+ break;
+ case "EXE":
+ assemblyName += ".exe";
+ break;
+ }
+
+ var projectPath = Path.GetDirectoryName(projectFilePath);
+ if (projectPath == null)
+ throw new ArgumentException("Invalid project file path", "projectFilePath");
+
+ return Path.Combine (projectPath, Path.Combine(dir, assemblyName));
+ }
+
+ public string GetPropertyValue(string platformConfig, string property)
+ {
+ var condition = "'" + platformConfig + "'";
+ var specific = (
+ from XmlNode propertyGroup in ProjectNode.ChildNodes
+ where propertyGroup.Name == "PropertyGroup" &&
+ propertyGroup.Attributes != null &&
+ propertyGroup.Attributes["Condition"] != null &&
+ propertyGroup.Attributes["Condition"].InnerText.Contains(condition)
+
+ from XmlNode outputNode in propertyGroup.ChildNodes
+ where outputNode.Name == property
+ select outputNode.InnerText).ToArray();
+
+ var defaultConfig = (
+ from XmlNode propertyGroup in ProjectNode.ChildNodes
+ where propertyGroup.Name == "PropertyGroup" && (
+ propertyGroup.Attributes == null ||
+ propertyGroup.Attributes["Condition"] == null)
+
+ from XmlNode outputNode in propertyGroup.ChildNodes
+ where outputNode.Name == property
+ select outputNode.InnerText).ToArray();
+
+ switch (specific.Length)
+ {
+ case 1:
+ return specific[0];
+ case 0:
+ switch (defaultConfig.Length)
+ {
+ case 1:
+ return defaultConfig[0];
+ case 0:
+ throw new InvalidOperationException(
+ string.Format("No value found for property '{0}' using "
+ + "platform configuration '{1}'", property, platformConfig));
+ }
+ break;
+ }
+ throw new InvalidOperationException(
+ string.Format("The property '{0}' had multiple values "
+ + "applicable for the same platform configuration '{1}'",
+ property, platformConfig));
+ }
+
+ public string GetDefaultPlatformConfig()
+ {
+ var config = GetDefaultPropertyValue("Configuration");
+ var platform = GetDefaultPropertyValue("Platform");
+ return config + "|" + platform;
+ }
+
+ private string GetDefaultPropertyValue(string property)
+ {
+ return (from XmlNode propertyGroup in ProjectNode.ChildNodes
+ where propertyGroup.Name == "PropertyGroup" &&
+ (propertyGroup.Attributes == null ||
+ propertyGroup.Attributes["Condition"] == null)
+ from XmlNode configNode in propertyGroup.ChildNodes
+ where configNode.Name == property &&
+ configNode.Attributes != null &&
+ configNode.Attributes["Condition"] != null &&
+ configNode.Attributes["Condition"].InnerText.Contains("'$(" + property + ")' == ''")
+ select configNode.InnerText).Single();
+ }
+
+ private XmlNode ProjectNode
+ {
+ get
+ {
+ return (from XmlNode node in document.ChildNodes
+ where node.Name.Equals("Project", StringComparison.OrdinalIgnoreCase)
+ select node).First();
+ }
+ }
+ }
+}
View
97 src/Giles.Core/Configuration/TestAssemblyFinder.cs
@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text.RegularExpressions;
+using Giles.Core.IO;
+
+namespace Giles.Core.Configuration
+{
+ public class TestAssemblyFinder
+ {
+ private readonly IFileSystem fileSystem;
+
+ //Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Giles.Specs", "Giles.Specs\Giles.Specs.csproj", "{8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}"
+ private static readonly Regex SolutionFileRegex = new Regex(
+ @"Project\(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC\}""\)" +
+ @"[^""]*""[^""]*""" +
+ @"[^""]*""([^""]*)""", RegexOptions.Compiled);
+
+ public TestAssemblyFinder(IFileSystem fileSystem)
+ {
+ this.fileSystem = fileSystem;
+ }
+
+ public IEnumerable<string> FindTestAssembliesIn(string solutionFilePath)
+ {
+ var projectFiles = GetProjectFilePaths(solutionFilePath);
+ var testAssemblies = new List<Tuple<int, string>>();
+ foreach (var file in projectFiles)
+ {
+ using (var stream = fileSystem.OpenFile(file, FileMode.Open,
+ FileAccess.Read, FileShare.ReadWrite))
+ {
+ var project = MsBuildProject.Load(stream);
+ var isTestProjectScore = GetIsTestProjectScore(project);
+ if (isTestProjectScore > 0)
+ {
+ var assemblyFilePath = project.GetAssemblyFilePath(file);
+ testAssemblies.Add(new Tuple<int, string>(
+ isTestProjectScore, assemblyFilePath));
+ }
+ }
+ }
+
+ // return assemblies with highest score first
+ return (from tuple in testAssemblies
+ orderby tuple.Item1 descending,
+ tuple.Item2 ascending // keep things deterministic for testing
+ select tuple.Item2).ToArray();
+ }
+
+ private IEnumerable<String> GetProjectFilePaths(string solutionFilePath)
+ {
+ var solutionContents = fileSystem.ReadAllText(solutionFilePath);
+ var solutionFileDir = Path.GetDirectoryName(solutionFilePath);
+ var match = SolutionFileRegex.Match(solutionContents);
+ while (match.Success)
+ {
+ var relativePath = match.Groups[1].Value;
+ match = match.NextMatch();
+ var path = Path.Combine(solutionFileDir, relativePath);
+ yield return path;
+ }
+ }
+
+ private int GetIsTestProjectScore(MsBuildProject project)
+ {
+ // TODO: may want to group this information with other info about supported test frameworks
+ int score = 0;
+ if (IsTestFrameworkReferenced(project, "Machine.Specifications.dll"))
+ score += 10;
+ if (IsTestFrameworkReferenced(project, "nunit.framework.dll"))
+ score += 10;
+
+ // no supported test framework, abort
+ if (score == 0)
+ return 0;
+
+ var assemblyName = project.GetAssemblyName();
+ if (assemblyName.Contains("UnitTest"))
+ score += 5;
+ else if (assemblyName.Contains("Test"))
+ score += 3;
+
+ if (assemblyName.Contains("Spec"))
+ score += 2; // more likely to have non-test project with Spec in it?
+
+ return score;
+ }
+
+ private bool IsTestFrameworkReferenced(MsBuildProject project, string frameworkAssemblyFilename)
+ {
+ return project.GetLocalAssemblyRefs().Any(info =>
+ info.EndsWith(frameworkAssemblyFilename, StringComparison.OrdinalIgnoreCase));
+ }
+ }
+}
View
3  src/Giles.Core/Giles.Core.csproj
@@ -56,8 +56,10 @@
<Compile Include="AppDomains\GilesAppDomainRunner.cs" />
<Compile Include="Configuration\GilesConfig.cs" />
<Compile Include="Configuration\GilesConfigFactory.cs" />
+ <Compile Include="Configuration\MsBuildProject.cs" />
<Compile Include="Configuration\RunnerAssembly.cs" />
<Compile Include="Configuration\Settings.cs" />
+ <Compile Include="Configuration\TestAssemblyFinder.cs" />
<Compile Include="Encryption\EncryptionHelper.cs" />
<Compile Include="IO\IFileSystem.cs" />
<Compile Include="IO\FileWatcherFactory.cs" />
@@ -92,6 +94,7 @@
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Security" />
+ <Reference Include="System.Xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
View
57 src/Giles.Specs/Core/Configuration/MsBuildProjectSpecs.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Linq;
+using Giles.Core.Configuration;
+using Machine.Specifications;
+
+namespace Giles.Specs.Core.Configuration
+{
+ public class an_msbuild_project
+ {
+ protected static string projectPath;
+ protected static MsBuildProject project;
+
+ private Establish context = () => {
+ projectPath = "Giles.Specs.Core.Configuration.Resources.Giles.Specs.csproj";
+ };
+ }
+
+ public class when_an_msbuild_project_is_loaded : an_msbuild_project
+ {
+ Because of = () => {
+ project = MsBuildProject.Load(TestResources.Read(projectPath));
+ };
+
+ It returns_referenced_assemblies_with_local_paths = () => {
+ project.GetLocalAssemblyRefs()
+ .Any(x => x == @"..\..\lib\NSubstitute.1.0.0.0\lib\35\NSubstitute.dll")
+ .ShouldEqual(true);
+ project.GetLocalAssemblyRefs()
+ .Any(x => x == @"..\..\tools\mspec\Machine.Specifications.dll")
+ .ShouldEqual(true);
+ project.GetLocalAssemblyRefs().Count().ShouldEqual(2);
+ };
+
+ It returns_the_default_platform_configuration = () =>
+ project.GetDefaultPlatformConfig().ShouldEqual("Debug|AnyCPU");
+
+ It returns_property_values_based_on_platform_configuration = () => {
+ project.GetPropertyValue("Release|AnyCPU", "OutputPath").ShouldEqual(@"bin\Release\");
+ project.GetPropertyValue("Debug|AnyCPU", "OutputPath").ShouldEqual(@"bin\Debug\");
+ project.GetPropertyValue("Debug|AnyCPU", "DefineConstants").ShouldEqual("DEBUG;TRACE");
+ };
+
+ It returns_the_default_property_value_if_platform_specific_not_found = () =>
+ project.GetPropertyValue("Release|AnyCPU", "AssemblyName").ShouldEqual(@"Giles.Specs");
+
+ It should_not_return_property_value_for_other_platform_configurations = () =>
+ typeof(InvalidOperationException).ShouldBeThrownBy(
+ () => project.GetPropertyValue("Release|AnyCPU", "DebugSymbols"));
+
+ It returns_the_output_assembly_path = () =>
+ project.GetAssemblyFilePath(@"C:\projects\Giles\src\Giles.Specs\Giles.Specs.csproj")
+ .ShouldEqual(@"C:\projects\Giles\src\Giles.Specs\bin\Debug\Giles.Specs.dll");
+
+ private It returns_the_assembly_name = () =>
+ project.GetAssemblyName().ShouldEqual(@"Giles.Specs");
+ }
+}
View
98 src/Giles.Specs/Core/Configuration/Resources/Giles.Core.WithMSpec.csproj
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{9039E7FA-989E-46ED-B031-FB67571E8385}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Giles.Core</RootNamespace>
+ <AssemblyName>Giles.Core</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'AutomatedRelease|AnyCPU'">
+ <OutputPath>..\..\build\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <CodeAnalysisLogFile>bin\Release\Giles.Core.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+ <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+ <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+ <CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
+ <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+ <CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
+ <CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="..\ProjectVersion.cs">
+ <Link>Properties\ProjectVersion.cs</Link>
+ </Compile>
+ <Compile Include="Configuration\GilesConfig.cs" />
+ <Compile Include="Configuration\GilesConfigFactory.cs" />
+ <Compile Include="Configuration\RunnerAssembly.cs" />
+ <Compile Include="Configuration\Settings.cs" />
+ <Compile Include="Configuration\SolutionConfig.cs" />
+ <Compile Include="Configuration\SolutionConfigLoader.cs" />
+ <Compile Include="Encryption\EncryptionHelper.cs" />
+ <Compile Include="IO\IFileSystem.cs" />
+ <Compile Include="IO\FileWatcherFactory.cs" />
+ <Compile Include="IO\IFileWatcherFactory.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Runners\BuildRunner.cs" />
+ <Compile Include="Runners\CommandProcessExecutor.cs" />
+ <Compile Include="Runners\IRunner.cs" />
+ <Compile Include="Runners\TestRunner.cs" />
+ <Compile Include="UI\ConsoleUserDisplay.cs" />
+ <Compile Include="UI\GrowlUserDisplay.cs" />
+ <Compile Include="UI\IUserDisplay.cs" />
+ <Compile Include="Watchers\SourceWatcher.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Reference Include="Growl.Connector">
+ <HintPath>..\..\lib\Growl.Connector\Growl.Connector.dll</HintPath>
+ </Reference>
+ <Reference Include="Growl.CoreLibrary">
+ <HintPath>..\..\lib\Growl.Connector\Growl.CoreLibrary.dll</HintPath>
+ </Reference>
+ <Reference Include="Machine.Specifications, Version=0.3.0.0, Culture=neutral, PublicKeyToken=5c474de7a495cff1, processorArchitecture=MSIL">
+ <HintPath>..\..\tools\mspec\Machine.Specifications.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Configuration" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Security" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
95 src/Giles.Specs/Core/Configuration/Resources/Giles.Core.csproj
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{9039E7FA-989E-46ED-B031-FB67571E8385}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Giles.Core</RootNamespace>
+ <AssemblyName>Giles.Core</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'AutomatedRelease|AnyCPU'">
+ <OutputPath>..\..\build\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <CodeAnalysisLogFile>bin\Release\Giles.Core.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+ <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+ <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+ <CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
+ <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+ <CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
+ <CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="..\ProjectVersion.cs">
+ <Link>Properties\ProjectVersion.cs</Link>
+ </Compile>
+ <Compile Include="Configuration\GilesConfig.cs" />
+ <Compile Include="Configuration\GilesConfigFactory.cs" />
+ <Compile Include="Configuration\RunnerAssembly.cs" />
+ <Compile Include="Configuration\Settings.cs" />
+ <Compile Include="Configuration\SolutionConfig.cs" />
+ <Compile Include="Configuration\SolutionConfigLoader.cs" />
+ <Compile Include="Encryption\EncryptionHelper.cs" />
+ <Compile Include="IO\IFileSystem.cs" />
+ <Compile Include="IO\FileWatcherFactory.cs" />
+ <Compile Include="IO\IFileWatcherFactory.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Runners\BuildRunner.cs" />
+ <Compile Include="Runners\CommandProcessExecutor.cs" />
+ <Compile Include="Runners\IRunner.cs" />
+ <Compile Include="Runners\TestRunner.cs" />
+ <Compile Include="UI\ConsoleUserDisplay.cs" />
+ <Compile Include="UI\GrowlUserDisplay.cs" />
+ <Compile Include="UI\IUserDisplay.cs" />
+ <Compile Include="Watchers\SourceWatcher.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Reference Include="Growl.Connector">
+ <HintPath>..\..\lib\Growl.Connector\Growl.Connector.dll</HintPath>
+ </Reference>
+ <Reference Include="Growl.CoreLibrary">
+ <HintPath>..\..\lib\Growl.Connector\Growl.CoreLibrary.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Configuration" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Security" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
86 src/Giles.Specs/Core/Configuration/Resources/Giles.Specs.csproj
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Giles.Specs</RootNamespace>
+ <AssemblyName>Giles.Specs</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'AutomatedRelease|AnyCPU'">
+ <OutputPath>..\..\build\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <CodeAnalysisLogFile>bin\Release\Giles.Specs.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+ <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+ <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+ <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
+ <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+ <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
+ <CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="..\ProjectVersion.cs">
+ <Link>Properties\ProjectVersion.cs</Link>
+ </Compile>
+ <Compile Include="Core\Configuration\GilesConfigFactorySpecs.cs" />
+ <Compile Include="Core\Configuration\SolutionConfigSpecs.cs" />
+ <Compile Include="Core\Runners\CommandProcessExecutorSpecs.cs" />
+ <Compile Include="Core\Runners\TestRunnerSpecs.cs" />
+ <Compile Include="Core\Watchers\SourceWatcherSpecs.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Reference Include="Machine.Specifications, Version=0.3.0.0, Culture=neutral, PublicKeyToken=5c474de7a495cff1, processorArchitecture=MSIL">
+ <HintPath>..\..\tools\mspec\Machine.Specifications.dll</HintPath>
+ </Reference>
+ <Reference Include="NSubstitute">
+ <HintPath>..\..\lib\NSubstitute.1.0.0.0\lib\35\NSubstitute.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Giles.Core\Giles.Core.csproj">
+ <Project>{9039E7FA-989E-46ED-B031-FB67571E8385}</Project>
+ <Name>Giles.Core</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.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
110 src/Giles.Specs/Core/Configuration/Resources/Giles.csproj
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{ACCEC948-8032-4D2B-AD53-1DD1390EDA78}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Giles</RootNamespace>
+ <AssemblyName>Giles</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>
+ </TargetFrameworkProfile>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <OutputPath>bin\Debug\</OutputPath>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <OutputPath>bin\Release\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'AutomatedRelease|x86'">
+ <OutputPath>bin\x86\AutomatedRelease\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisLogFile>bin\Release\Giles.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+ <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+ <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+ <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+ <CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'AutomatedRelease|AnyCPU'">
+ <OutputPath>..\..\build\</OutputPath>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <CodeAnalysisLogFile>bin\Release\Giles.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+ <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+ <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+ <CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
+ <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+ <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
+ <CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="..\ProjectVersion.cs">
+ <Link>Properties\ProjectVersion.cs</Link>
+ </Compile>
+ <Compile Include="Options\CLOptions.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="SlayerModule.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Reference Include="CommandLine">
+ <HintPath>..\..\lib\CommandLineParser\CommandLine.dll</HintPath>
+ </Reference>
+ <Reference Include="Ninject">
+ <HintPath>..\..\lib\Ninject.2.1.0.76\lib\40\Ninject.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Giles.Core\Giles.Core.csproj">
+ <Project>{9039E7FA-989E-46ED-B031-FB67571E8385}</Project>
+ <Name>Giles.Core</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.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
84 src/Giles.Specs/Core/Configuration/Resources/Giles.sln
@@ -0,0 +1,84 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Giles", "Giles\Giles.csproj", "{ACCEC948-8032-4D2B-AD53-1DD1390EDA78}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Giles.Core", "Giles.Core\Giles.Core.csproj", "{9039E7FA-989E-46ED-B031-FB67571E8385}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Giles.Specs", "Giles.Specs\Giles.Specs.csproj", "{8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{D2D91826-7DA4-4AD2-B102-B1389C0B4A23}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8046A0FB-21E0-4F65-A62C-580916EB31A3}"
+ ProjectSection(SolutionItems) = preProject
+ ProjectVersion.cs = ProjectVersion.cs
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ AutomatedRelease|Any CPU = AutomatedRelease|Any CPU
+ AutomatedRelease|Mixed Platforms = AutomatedRelease|Mixed Platforms
+ AutomatedRelease|x86 = AutomatedRelease|x86
+ Debug|Any CPU = Debug|Any CPU
+ Debug|Mixed Platforms = Debug|Mixed Platforms
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|Mixed Platforms = Release|Mixed Platforms
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.AutomatedRelease|Any CPU.ActiveCfg = AutomatedRelease|Any CPU
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.AutomatedRelease|Any CPU.Build.0 = AutomatedRelease|Any CPU
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.AutomatedRelease|Mixed Platforms.ActiveCfg = AutomatedRelease|Any CPU
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.AutomatedRelease|Mixed Platforms.Build.0 = AutomatedRelease|Any CPU
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.AutomatedRelease|x86.ActiveCfg = AutomatedRelease|x86
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.AutomatedRelease|x86.Build.0 = AutomatedRelease|x86
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.Debug|Any CPU.ActiveCfg = Debug|x86
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.Debug|x86.ActiveCfg = Debug|x86
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.Debug|x86.Build.0 = Debug|x86
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.Release|Any CPU.Build.0 = Release|Any CPU
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.Release|Mixed Platforms.ActiveCfg = Release|x86
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.Release|Mixed Platforms.Build.0 = Release|x86
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.Release|x86.ActiveCfg = Release|x86
+ {ACCEC948-8032-4D2B-AD53-1DD1390EDA78}.Release|x86.Build.0 = Release|x86
+ {9039E7FA-989E-46ED-B031-FB67571E8385}.AutomatedRelease|Any CPU.ActiveCfg = AutomatedRelease|Any CPU
+ {9039E7FA-989E-46ED-B031-FB67571E8385}.AutomatedRelease|Any CPU.Build.0 = AutomatedRelease|Any CPU
+ {9039E7FA-989E-46ED-B031-FB67571E8385}.AutomatedRelease|Mixed Platforms.ActiveCfg = AutomatedRelease|Any CPU
+ {9039E7FA-989E-46ED-B031-FB67571E8385}.AutomatedRelease|Mixed Platforms.Build.0 = AutomatedRelease|Any CPU
+ {9039E7FA-989E-46ED-B031-FB67571E8385}.AutomatedRelease|x86.ActiveCfg = AutomatedRelease|Any CPU
+ {9039E7FA-989E-46ED-B031-FB67571E8385}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9039E7FA-989E-46ED-B031-FB67571E8385}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9039E7FA-989E-46ED-B031-FB67571E8385}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {9039E7FA-989E-46ED-B031-FB67571E8385}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {9039E7FA-989E-46ED-B031-FB67571E8385}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {9039E7FA-989E-46ED-B031-FB67571E8385}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9039E7FA-989E-46ED-B031-FB67571E8385}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9039E7FA-989E-46ED-B031-FB67571E8385}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {9039E7FA-989E-46ED-B031-FB67571E8385}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {9039E7FA-989E-46ED-B031-FB67571E8385}.Release|x86.ActiveCfg = Release|Any CPU
+ {8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}.AutomatedRelease|Any CPU.ActiveCfg = AutomatedRelease|Any CPU
+ {8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}.AutomatedRelease|Any CPU.Build.0 = AutomatedRelease|Any CPU
+ {8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}.AutomatedRelease|Mixed Platforms.ActiveCfg = AutomatedRelease|Any CPU
+ {8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}.AutomatedRelease|Mixed Platforms.Build.0 = AutomatedRelease|Any CPU
+ {8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}.AutomatedRelease|x86.ActiveCfg = AutomatedRelease|Any CPU
+ {8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {8FAE1516-9D4A-4575-83BF-515BC6AF8AC3}.Release|x86.ActiveCfg = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {8FAE1516-9D4A-4575-83BF-515BC6AF8AC3} = {D2D91826-7DA4-4AD2-B102-B1389C0B4A23}
+ EndGlobalSection
+EndGlobal
View
92 src/Giles.Specs/Core/Configuration/TestAssemblyFinderSpecs.cs
@@ -0,0 +1,92 @@
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Giles.Core.Configuration;
+using Giles.Core.IO;
+using Machine.Specifications;
+using NSubstitute;
+
+namespace Giles.Specs.Core.Configuration
+{
+ public class a_solution_with_a_test_project
+ {
+ protected static TestAssemblyFinder testFinder;
+ protected static IEnumerable<string> configuration;
+ protected static string solutionFilePath;
+ protected static IFileSystem fileSystem;
+
+ Establish context = () => {
+ solutionFilePath = @"c:\app\src\solution.sln";
+ fileSystem = Substitute.For<IFileSystem>();
+ fileSystem.ReadAllText(solutionFilePath).Returns(
+ TestResources.ReadAllText(
+ "Giles.Specs.Core.Configuration.Resources.Giles.sln"));
+
+ fileSystem.OpenFile(@"c:\app\src\Giles\Giles.csproj",
+ FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
+ .Returns(TestResources.Read(
+ "Giles.Specs.Core.Configuration.Resources.Giles.csproj"));
+
+ fileSystem.OpenFile(@"c:\app\src\Giles.Core\Giles.Core.csproj",
+ FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
+ .Returns(TestResources.Read(
+ "Giles.Specs.Core.Configuration.Resources.Giles.Core.csproj"));
+
+ fileSystem.OpenFile(@"c:\app\src\Giles.Specs\Giles.Specs.csproj",
+ FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
+ .Returns(TestResources.Read(
+ "Giles.Specs.Core.Configuration.Resources.Giles.Specs.csproj"));
+
+ testFinder = new TestAssemblyFinder(fileSystem);
+ };
+ }
+
+ public class when_loading_configuration_settings_from_a_solution_with_a_test_project : a_solution_with_a_test_project
+ {
+ Because of = () =>
+ configuration = testFinder.FindTestAssembliesIn(solutionFilePath);
+
+ It reads_the_solution_file = () =>
+ fileSystem.Received().ReadAllText(solutionFilePath);
+
+ It reads_the_csharp_project_files = () =>
+ {
+ fileSystem.Received().OpenFile(@"c:\app\src\Giles\Giles.csproj",
+ FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+ fileSystem.Received().OpenFile(@"c:\app\src\Giles.Core\Giles.Core.csproj",
+ FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+ fileSystem.Received().OpenFile(@"c:\app\src\Giles.Specs\Giles.Specs.csproj",
+ FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+ };
+
+ It determines_the_test_assembly_file_path = () =>
+ configuration.Single().ShouldEqual(
+ @"c:\app\src\Giles.Specs\bin\Debug\Giles.Specs.dll");
+ }
+
+ public class a_solution_with_two_projects_referencing_test_frameworks : a_solution_with_a_test_project
+ {
+ Establish context = () => {
+ // switch call for Core project to return core project with MSpec reference
+ fileSystem.OpenFile(@"c:\app\src\Giles.Core\Giles.Core.csproj",
+ FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
+ .Returns(TestResources.Read(
+ "Giles.Specs.Core.Configuration.Resources.Giles.Core.WithMSpec.csproj"));
+ };
+ }
+
+ public class when_a_solution_contains_two_projects_referencing_test_frameworks : a_solution_with_two_projects_referencing_test_frameworks
+ {
+ private static IEnumerable<string> assemblies;
+
+ Because of = () =>
+ assemblies = testFinder.FindTestAssembliesIn(solutionFilePath);
+
+ It should_find_both_test_projects = () =>
+ assemblies.Count().ShouldEqual(2);
+
+ // HERE: implement this
+ It should_list_the_project_with_Spec_in_the_name_first = () =>
+ assemblies.First().ShouldEqual(@"c:\app\src\Giles.Specs\bin\Debug\Giles.Specs.dll");
+ }
+}
View
13 src/Giles.Specs/Giles.Specs.csproj
@@ -52,7 +52,10 @@
<Compile Include="..\ProjectVersion.cs">
<Link>Properties\ProjectVersion.cs</Link>
</Compile>
+ <Compile Include="Core\Configuration\TestAssemblyFinderSpecs.cs" />
+ <Compile Include="TestResources.cs" />
<Compile Include="Core\Configuration\GilesConfigFactorySpecs.cs" />
+ <Compile Include="Core\Configuration\MsBuildProjectSpecs.cs" />
<Compile Include="Core\Runners\BuildRunnerSpecs.cs" />
<Compile Include="Core\Runners\CommandProcessExecutorSpecs.cs" />
<Compile Include="Core\Runners\FakeUserDisplay.cs" />
@@ -72,6 +75,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
+ <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Giles.Core\Giles.Core.csproj">
@@ -83,6 +87,15 @@
<Name>Giles.Runner.Machine.Specifications</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Core\Configuration\Resources\Giles.Core.csproj" />
+ <EmbeddedResource Include="Core\Configuration\Resources\Giles.csproj" />
+ <EmbeddedResource Include="Core\Configuration\Resources\Giles.sln" />
+ <EmbeddedResource Include="Core\Configuration\Resources\Giles.Specs.csproj" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Core\Configuration\Resources\Giles.Core.WithMSpec.csproj" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
View
30 src/Giles.Specs/TestResources.cs
@@ -0,0 +1,30 @@
+using System;
+using System.IO;
+using System.Reflection;
+
+namespace Giles.Specs
+{
+ public class TestResources
+ {
+ /// <param name="resourcePath">The full namespace and file name.</param>
+ public static string ReadAllText(string resourcePath)
+ {
+ using (var reader = Read(resourcePath))
+ using (var sr = new StreamReader(reader))
+ {
+ return sr.ReadToEnd();
+ }
+ }
+
+ /// <param name="resourcePath">The full namespace and file name.</param>
+ public static Stream Read(string resourcePath)
+ {
+ var stream = TestAssembly.GetManifestResourceStream(resourcePath);
+ if (stream == null)
+ throw new ArgumentException("Invalid resource path: " + resourcePath, "resourcePath");
+ return stream;
+ }
+
+ private static readonly Assembly TestAssembly = typeof(TestResources).Assembly;
+ }
+}
View
2  src/Giles/Options/CLOptions.cs
@@ -8,7 +8,7 @@ public class CLOptions
[Option("s", "SolutionPath", Required = true, HelpText = "Path to the sln file")]
public string SolutionPath;
- [Option("t", "TestAssemblyPath", Required = true, HelpText = "Path to the test assembly dll")]
+ [Option("t", "TestAssemblyPath", Required = false, HelpText = "Path to the test assembly dll")]
public string TestAssemblyPath;
[HelpOption(HelpText = "Display this help screen.")]
View
32 src/Giles/Program.cs
@@ -3,6 +3,7 @@
using System.Linq;
using CommandLine;
using Giles.Core.Configuration;
+using Giles.Core.IO;
using Giles.Core.Utility;
using Giles.Core.Watchers;
using Giles.Options;
@@ -41,13 +42,40 @@ class Program {
static void SetupSourceWatcher(CLOptions options) {
var solutionPath = options.SolutionPath.Replace("\"", string.Empty);
- var testAssemblyPath = options.TestAssemblyPath.Replace("\"", string.Empty);
+ var testAssemblyPath = GetTestAssemblyPath(options);
GetSourceWatcher(solutionPath, testAssemblyPath);
sourceWatcher.Watch(solutionPath, @"*.cs");
}
+ private static string GetTestAssemblyPath(CLOptions options)
+ {
+ var testAssemblyPath = options.TestAssemblyPath != null
+ ? options.TestAssemblyPath.Replace("\"", string.Empty)
+ : FindTestAssembly(options);
+
+ if (testAssemblyPath == null)
+ {
+ Console.Error.Write(options.GetUsage());
+ Console.Error.WriteLine("No test assemblies detected. Please specify"
+ + " the TestAssemblyPath command line option.");
+ Console.Error.WriteLine();
+ Environment.Exit(1);
+ }
+ return testAssemblyPath;
+ }
+
+ private static string FindTestAssembly(CLOptions options)
+ {
+ var testAssemblyFinder = new TestAssemblyFinder(new FileSystem());
+ var testAssemblies = testAssemblyFinder.FindTestAssembliesIn(options.SolutionPath);
+
+ if (testAssemblies.Count() == 0)
+ return null;
+
+ return testAssemblies.First();
+ }
static void GetSourceWatcher(string solutionPath, string testAssemblyPath) {
var kernel = SetupGilesKernelAndConfig(solutionPath, testAssemblyPath);
@@ -55,7 +83,6 @@ class Program {
sourceWatcher = kernel.Get<SourceWatcher>();
}
-
static StandardKernel SetupGilesKernelAndConfig(string solutionPath, string testAssemblyPath) {
var kernel = new StandardKernel(new SlayerModule(solutionPath, testAssemblyPath));
@@ -64,7 +91,6 @@ class Program {
return kernel;
}
-
private static int Height {
get {
return (69 > Console.LargestWindowHeight) ? Console.LargestWindowHeight : 69;
View
2  watch.ps1
@@ -1 +1 @@
-& .\build\Giles.exe -s .\src\Giles.sln -t .\src\Giles.specs\bin\debug\Giles.Specs.dll
Please sign in to comment.
Something went wrong with that request. Please try again.