public string Setup()
{
const string OutputDirectoryName = FileSystemPrefix + @"JSONFeatureOutput";
const string RootPath = FileSystemPrefix + @"JSON\Features";
const string TestResultFilePath = FileSystemPrefix + @"JSON\results-example-failing-and-pasing-mstest.trx";
string filePath = FileSystem.Path.Combine(OutputDirectoryName, JsonDocumentationBuilder.JsonFileName);
this.AddFakeFolderAndFiles("JSON", new[] { "results-example-failing-and-pasing-mstest.trx" });
this.AddFakeFolderAndFiles(
@"JSON\Features",
new[]
{
"OneScenarioTransferingMoneyBetweenAccountsFailing.feature",
"TransferBetweenAccounts_WithSuccess.feature",
"TwoScenariosTransferingFundsOneFailingOneSuccess.feature",
"TwoScenariosTransferingMoneyBetweenAccoutsWithSuccess.feature",
});
var resultFile = RetrieveContentOfFileFromResources(ResourcePrefix + "JSON.results-example-failing-and-pasing-mstest.trx");
FileSystem.AddFile(TestResultFilePath, resultFile);
Tree features = Container.Resolve<DirectoryTreeCrawler>().Crawl(RootPath);
var outputDirectory = FileSystem.DirectoryInfo.FromDirectoryName(OutputDirectoryName);
if (!outputDirectory.Exists)
{
outputDirectory.Create();
}
var configuration = new Configuration
{
OutputFolder = FileSystem.DirectoryInfo.FromDirectoryName(OutputDirectoryName),
DocumentationFormat = DocumentationFormat.Json,
TestResultsFormat = TestResultsFormat.MsTest,
SystemUnderTestName = "SUT Name",
SystemUnderTestVersion = "SUT Version"
};
configuration.AddTestResultFile(FileSystem.FileInfo.FromFileName(TestResultFilePath));
ITestResults testResults = new MsTestResults(configuration, new MsTestSingleResultLoader(), new MsTestScenarioOutlineExampleMatcher());
var jsonDocumentationBuilder = new JsonDocumentationBuilder(configuration, testResults, FileSystem);
jsonDocumentationBuilder.Build(features);
string content = FileSystem.File.ReadAllText(filePath);
return content;
}