-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce SpecFlowJsonLocator (#2069)
* Introduce SpecFlowJsonLocator * Create interface for SpecFlowJsonLocator - Adjust callers to use DI * Adapt tests for DI
- Loading branch information
Showing
9 changed files
with
82 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 8 additions & 6 deletions
14
TechTalk.SpecFlow.Generator/Project/MsBuildProjectReader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
using TechTalk.SpecFlow.Configuration; | ||
using TechTalk.SpecFlow.Generator.Configuration; | ||
|
||
namespace TechTalk.SpecFlow.Generator.Project | ||
{ | ||
public class MSBuildProjectReader : IMSBuildProjectReader | ||
{ | ||
private readonly ISpecFlowProjectReader _projectReader; | ||
|
||
public MSBuildProjectReader(ISpecFlowProjectReader projectReader) | ||
{ | ||
_projectReader = projectReader; | ||
} | ||
|
||
public SpecFlowProject LoadSpecFlowProjectFromMsBuild(string projectFilePath, string rootNamespace) | ||
{ | ||
var configurationProvider = new GeneratorConfigurationProvider(new ConfigurationLoader()); | ||
var projectReader = new ProjectReader(configurationProvider, new ProjectLanguageReader()); | ||
return projectReader.ReadSpecFlowProject(projectFilePath, rootNamespace); | ||
return _projectReader.ReadSpecFlowProject(projectFilePath, rootNamespace); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace TechTalk.SpecFlow.Configuration | ||
{ | ||
public interface ISpecFlowJsonLocator | ||
{ | ||
string GetSpecFlowJsonFilePath(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.IO; | ||
|
||
namespace TechTalk.SpecFlow.Configuration | ||
{ | ||
public class SpecFlowJsonLocator : ISpecFlowJsonLocator | ||
{ | ||
public const string JsonConfigurationFileName = "specflow.json"; | ||
|
||
public string GetSpecFlowJsonFilePath() | ||
{ | ||
var specflowJsonFileInAppDomainBaseDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, JsonConfigurationFileName); | ||
|
||
if (File.Exists(specflowJsonFileInAppDomainBaseDirectory)) | ||
{ | ||
return specflowJsonFileInAppDomainBaseDirectory; | ||
} | ||
|
||
var specflowJsonFileTwoDirectoriesUp = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", JsonConfigurationFileName); | ||
|
||
if (File.Exists(specflowJsonFileTwoDirectoriesUp)) | ||
{ | ||
return specflowJsonFileTwoDirectoriesUp; | ||
} | ||
|
||
var specflowJsonFileInCurrentDirectory = Path.Combine(Environment.CurrentDirectory, JsonConfigurationFileName); | ||
|
||
if (File.Exists(specflowJsonFileInCurrentDirectory)) | ||
{ | ||
return specflowJsonFileInCurrentDirectory; | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters