*/
- var directoryInfo = node.OriginalLocation as DirectoryInfoBase;
+ var directoryInfo = node.OriginalLocation as IDirectoryInfo;
if (directoryInfo == null)
{
@@ -55,7 +55,7 @@ public XElement Format(INode node, IEnumerable
features)
string[] files = directoryInfo.GetFiles().Select(f => f.FullName).ToArray();
INode[] featuresThatAreDirectChildrenOfFolder =
- features.Where(f => f.OriginalLocation is FileInfoBase).Where(
+ features.Where(f => f.OriginalLocation is IFileInfo).Where(
f => files.Contains(f.OriginalLocation.FullName)).ToArray();
var div = new XElement(
diff --git a/src/Pickles/Pickles.DocumentationBuilders.Html/HtmlTableOfContentsFormatter.cs b/src/Pickles/Pickles.DocumentationBuilders.Html/HtmlTableOfContentsFormatter.cs
index 96cb2ea3d..565bd93bc 100644
--- a/src/Pickles/Pickles.DocumentationBuilders.Html/HtmlTableOfContentsFormatter.cs
+++ b/src/Pickles/Pickles.DocumentationBuilders.Html/HtmlTableOfContentsFormatter.cs
@@ -81,10 +81,9 @@ private XElement AddNodeForDirectory(XNamespace xmlns, Uri file, Tree childNode)
return xElement;
}
- private XElement AddNodeForHome(XNamespace xmlns, Uri file, DirectoryInfoBase rootFolder)
+ private XElement AddNodeForHome(XNamespace xmlns, Uri file, IDirectoryInfo rootFolder)
{
- var rootfile = this.fileSystem.FileInfo.FromFileName(this.fileSystem.Path.Combine(rootFolder.FullName, "index.html"));
-
+ var rootfile = (IFileInfo)this.fileSystem.FileInfo.FromFileName(this.fileSystem.Path.Combine(rootFolder.FullName, "index.html"));
var xElement = new XElement(xmlns + "li", new XAttribute("class", "file"), new XAttribute("id", "root"));
string nodeText = "Home";
@@ -105,7 +104,7 @@ private XElement AddNodeForHome(XNamespace xmlns, Uri file, DirectoryInfoBase ro
return xElement;
}
- private bool DetermineWhetherFileIsTheRootFile(Uri file, FileInfoBase rootfile)
+ private bool DetermineWhetherFileIsTheRootFile(Uri file, IFileInfo rootfile)
{
var fileInfo = this.fileSystem.FileInfo.FromFileName(file.LocalPath);
@@ -171,7 +170,7 @@ private XElement BuildCollapser(XNamespace xmlns)
new XText("«"));
}
- public XElement Format(Uri file, Tree features, DirectoryInfoBase outputFolder)
+ public XElement Format(Uri file, Tree features, IDirectoryInfo outputFolder)
{
XNamespace xmlns = HtmlNamespace.Xhtml;
diff --git a/src/Pickles/Pickles.DocumentationBuilders.Markdown.AcceptanceTests/Features/File Location.feature b/src/Pickles/Pickles.DocumentationBuilders.Markdown.AcceptanceTests/Features/File Location.feature
index c199d8524..f9dbd6624 100644
--- a/src/Pickles/Pickles.DocumentationBuilders.Markdown.AcceptanceTests/Features/File Location.feature
+++ b/src/Pickles/Pickles.DocumentationBuilders.Markdown.AcceptanceTests/Features/File Location.feature
@@ -6,8 +6,8 @@
Scenario: Output is written to specified location
- Given I specify the output folder as 'C:\testing'
-
+ Given I specify the output folder as 'testing'
+
When I generate Markdown output
-
- Then the file 'C:\testing\features.md' exists
\ No newline at end of file
+
+ Then the file 'features.md' exists in folder 'testing'
\ No newline at end of file
diff --git a/src/Pickles/Pickles.DocumentationBuilders.Markdown.AcceptanceTests/Steps/MarkdownSteps.cs b/src/Pickles/Pickles.DocumentationBuilders.Markdown.AcceptanceTests/Steps/MarkdownSteps.cs
index 138b7904c..f1e9a31b1 100644
--- a/src/Pickles/Pickles.DocumentationBuilders.Markdown.AcceptanceTests/Steps/MarkdownSteps.cs
+++ b/src/Pickles/Pickles.DocumentationBuilders.Markdown.AcceptanceTests/Steps/MarkdownSteps.cs
@@ -31,6 +31,8 @@ namespace PicklesDoc.Pickles.DocumentationBuilders.Markdown.AcceptanceTests.Step
[Binding]
public sealed class MarkdownSteps : BaseFixture
{
+ private string filePath;
+
[Given(@"I specify the output folder as '(.*)'")]
public void Given_I_Specify_The_Output_File_As(string outputFolder)
{
@@ -125,10 +127,12 @@ public void Then_The_Markdown_Output_Has_The_Lines_In_The_Following_Order(Table
}
}
- [Then(@"the file '(.*)' exists")]
- public void Then_The_File_Exists(string expectedFile)
+ [Then(@"the file '(.*)' exists in folder '(.*)'")]
+
+ public void Then_The_File_Exists(string expectedFile, string expectedFolder)
{
- Assert.IsTrue(this.FileSystem.File.Exists(expectedFile),string.Format("File \"{0}\" not found",expectedFile));
+ this.filePath = FileSystem.Path.Combine(expectedFolder,expectedFile);
+ Assert.IsTrue(this.FileSystem.File.Exists(this.filePath),string.Format("File \"{0}\" not found",filePath));
}
// Duplicated logic from Builder class, should be moved to it's own class?
@@ -139,11 +143,11 @@ private string TargetFile(IConfiguration configuration)
string defaultOutputFile = string.Empty;
if (configuration.OutputFolder == null)
{
- defaultOutputFile = Path.Combine(@"C:\testing", fileName);
+ defaultOutputFile =FileSystem.Path.Combine(@"C:\testing", fileName);
}
else
{
- defaultOutputFile = Path.Combine(configuration.OutputFolder.FullName, fileName);
+ defaultOutputFile =FileSystem.Path.Combine(configuration.OutputFolder.FullName, fileName);
}
return defaultOutputFile;
diff --git a/src/Pickles/Pickles.DocumentationBuilders.Markdown.UnitTests/Blocks_Tests/Block_Tests.cs b/src/Pickles/Pickles.DocumentationBuilders.Markdown.UnitTests/Blocks_Tests/Block_Tests.cs
index 5b69adf8d..56ac232e5 100644
--- a/src/Pickles/Pickles.DocumentationBuilders.Markdown.UnitTests/Blocks_Tests/Block_Tests.cs
+++ b/src/Pickles/Pickles.DocumentationBuilders.Markdown.UnitTests/Blocks_Tests/Block_Tests.cs
@@ -18,6 +18,7 @@
//
// --------------------------------------------------------------------------------------------------------------------
+using System;
using NUnit.Framework;
using PicklesDoc.Pickles.DocumentationBuilders.Markdown.Blocks;
@@ -34,7 +35,7 @@ public void ToString_Returns_Blocks_Markdown_Content()
(mockBlock as MockBlock).Add("Hello, World");
- Assert.AreEqual("Hello, World\r\n", mockBlock.ToString());
+ Assert.AreEqual("Hello, World"+Environment.NewLine, mockBlock.ToString());
}
[Test]
diff --git a/src/Pickles/Pickles.DocumentationBuilders.Markdown.UnitTests/Lines_Tests.cs b/src/Pickles/Pickles.DocumentationBuilders.Markdown.UnitTests/Lines_Tests.cs
index 97841b306..a58e8a110 100644
--- a/src/Pickles/Pickles.DocumentationBuilders.Markdown.UnitTests/Lines_Tests.cs
+++ b/src/Pickles/Pickles.DocumentationBuilders.Markdown.UnitTests/Lines_Tests.cs
@@ -18,6 +18,7 @@
//
// --------------------------------------------------------------------------------------------------------------------
+using System;
using NUnit.Framework;
namespace PicklesDoc.Pickles.DocumentationBuilders.Markdown.UnitTests
@@ -66,7 +67,7 @@ public void Converting_Lines_Object_To_String_Returns_All_Lines_With_NewLine_Sep
lines.Add("Hello");
lines.Add("World");
- Assert.AreEqual("Hello\r\nWorld\r\n", lines.ToString());
+ Assert.AreEqual($"Hello{Environment.NewLine}World{Environment.NewLine}", lines.ToString());
}
}
}
diff --git a/src/Pickles/Pickles.DocumentationBuilders.Markdown.UnitTests/MarkdownDocumentationBuilder_Tests.cs b/src/Pickles/Pickles.DocumentationBuilders.Markdown.UnitTests/MarkdownDocumentationBuilder_Tests.cs
index 04882bff9..2cd1444a4 100644
--- a/src/Pickles/Pickles.DocumentationBuilders.Markdown.UnitTests/MarkdownDocumentationBuilder_Tests.cs
+++ b/src/Pickles/Pickles.DocumentationBuilders.Markdown.UnitTests/MarkdownDocumentationBuilder_Tests.cs
@@ -24,6 +24,7 @@
using PicklesDoc.Pickles.DirectoryCrawler;
using PicklesDoc.Pickles.ObjectModel;
using System;
+using System.IO;
using System.IO.Abstractions;
using System.IO.Abstractions.TestingHelpers;
using System.Reflection;
@@ -58,12 +59,13 @@ public void Autofac_Can_Resolve_MarkdownDocumentationBuilder_Request()
[Test]
public void When_I_Build_Documentation_A_File_Is_Created()
{
- var outputFolder = @"c:\output";
- var defaultOutputFile = @"c:\output\features.md";
+ var outputFolder = "output";
var container = BuildContainer();
var configuration = container.Resolve();
var fileSystem = (MockFileSystem)container.Resolve();
+ var defaultOutputFile = fileSystem.Path.Combine("output","features.md");
+
configuration.OutputFolder = fileSystem.DirectoryInfo.FromDirectoryName(outputFolder);
var markdownDocumentationBuilder = container.Resolve();
@@ -75,7 +77,7 @@ public void When_I_Build_Documentation_A_File_Is_Created()
[Test]
public void When_I_Build_Documentation_Icon_Files_Are_Created()
{
- var outputFolder = @"c:\output";
+ var outputFolder = "output";
var container = BuildContainer();
var configuration = container.Resolve();
@@ -85,16 +87,15 @@ public void When_I_Build_Documentation_Icon_Files_Are_Created()
markdownDocumentationBuilder.Build(null);
- Assert.IsTrue(fileSystem.FileExists(@"c:\output\pass.png"));
- Assert.IsTrue(fileSystem.FileExists(@"c:\output\fail.png"));
- Assert.IsTrue(fileSystem.FileExists(@"c:\output\inconclusive.png"));
+ Assert.IsTrue(fileSystem.FileExists(fileSystem.Path.Combine("output","pass.png")));
+ Assert.IsTrue(fileSystem.FileExists(fileSystem.Path.Combine("output","fail.png")));
+ Assert.IsTrue(fileSystem.FileExists(fileSystem.Path.Combine("output","inconclusive.png")));
}
[Test]
public void With_A_Null_Tree_The_Output_Has_Default_Content()
{
- var outputFolder = @"c:\output";
- var defaultOutputFile = @"c:\output\features.md";
+ var outputFolder = "output";
var expectedFile = new string[]
{
"# Features",
@@ -105,6 +106,8 @@ public void With_A_Null_Tree_The_Output_Has_Default_Content()
var container = BuildContainer();
var configuration = container.Resolve();
var fileSystem = (MockFileSystem)container.Resolve();
+ var defaultOutputFile = fileSystem.Path.Combine("output","features.md");
+
configuration.OutputFolder = fileSystem.DirectoryInfo.FromDirectoryName(outputFolder);
var markdownDocumentationBuilder = container.Resolve();
@@ -121,8 +124,7 @@ public void With_A_Null_Tree_The_Output_Has_Default_Content()
[Test]
public void With_A_Simple_Feature_The_Output_Has_Default_Content()
{
- var outputFolder = @"c:\output";
- var defaultOutputFile = @"c:\output\features.md";
+ var outputFolder = "output";
var expectedFile = new string[]
{
"# Features",
@@ -136,13 +138,15 @@ public void With_A_Simple_Feature_The_Output_Has_Default_Content()
var container = BuildContainer();
var configuration = container.Resolve();
var fileSystem = (MockFileSystem)container.Resolve();
+ var defaultOutputFile = fileSystem.Path.Combine("output", "features.md");
+
configuration.OutputFolder = fileSystem.DirectoryInfo.FromDirectoryName(outputFolder);
var markdownDocumentationBuilder = container.Resolve();
var simpleFeature = new Feature();
simpleFeature.Name = "Simple Feature";
var relPath = "fakedir";
- var location = fileSystem.FileInfo.FromFileName(@"c:\");
+ var location = fileSystem.FileInfo.FromFileName(fileSystem.Directory.GetCurrentDirectory());
var newNode = new FeatureNode(location, relPath, simpleFeature);
var featureTree = new Tree(new FolderNode(location, relPath));
featureTree.Add(newNode);
diff --git a/src/Pickles/Pickles.DocumentationBuilders.Markdown.UnitTests/Pickles.DocumentationBuilders.Markdown.UnitTests.csproj b/src/Pickles/Pickles.DocumentationBuilders.Markdown.UnitTests/Pickles.DocumentationBuilders.Markdown.UnitTests.csproj
index e3c8ce38c..ded96cf3f 100644
--- a/src/Pickles/Pickles.DocumentationBuilders.Markdown.UnitTests/Pickles.DocumentationBuilders.Markdown.UnitTests.csproj
+++ b/src/Pickles/Pickles.DocumentationBuilders.Markdown.UnitTests/Pickles.DocumentationBuilders.Markdown.UnitTests.csproj
@@ -1,4 +1,4 @@
-
+
PicklesDoc.Pickles.DocumentationBuilders.Markdown.UnitTests
PicklesDoc.Pickles.DocumentationBuilders.Markdown.UnitTests
@@ -30,10 +30,10 @@
-
+
-
+
\ No newline at end of file
diff --git a/src/Pickles/Pickles.DocumentationBuilders.Markdown/MarkdownDocumentationBuilder.cs b/src/Pickles/Pickles.DocumentationBuilders.Markdown/MarkdownDocumentationBuilder.cs
index 58e2ee5bb..19692ba82 100644
--- a/src/Pickles/Pickles.DocumentationBuilders.Markdown/MarkdownDocumentationBuilder.cs
+++ b/src/Pickles/Pickles.DocumentationBuilders.Markdown/MarkdownDocumentationBuilder.cs
@@ -45,19 +45,19 @@ public MarkdownDocumentationBuilder(IFileSystem fileSystem, IConfiguration confi
if (configuration.OutputFolder == null)
{
- outputFolder = @"C:\testing";
- }
- else
- {
- outputFolder = configuration.OutputFolder.FullName;
+ configuration.OutputFolder = fileSystem.DirectoryInfo.FromDirectoryName("testing");
}
+ if(!configuration.OutputFolder.Exists)
+ configuration.OutputFolder.Create();
+
+ outputFolder = configuration.OutputFolder.FullName;
}
public void Build(Tree featureTree)
{
var documentation = new Documentation(featureTree);
- WriteContentToFile(TargetFile(), documentation.CurrentPage);
+ this.WriteContentToFile(fileSystem.Path.Combine(this.outputFolder, "features.md"), documentation.CurrentPage);
WriteImage(outputFolder, "pass_32.png", "pass.png");
WriteImage(outputFolder, "fail_32.png", "fail.png");
@@ -75,17 +75,6 @@ private void WriteContentToFile(string filePath, string content)
}
}
- private string TargetFile()
- {
- var fileName = "features.md";
-
- string defaultOutputFile = string.Empty;
- defaultOutputFile = Path.Combine(outputFolder, fileName);
-
- return defaultOutputFile;
- }
-
-
private void WriteImage(string folder, string sourcefilename, string targetfilename)
{
diff --git a/src/Pickles/Pickles.DocumentationBuilders.Markdown/Pickles.DocumentationBuilders.Markdown.csproj b/src/Pickles/Pickles.DocumentationBuilders.Markdown/Pickles.DocumentationBuilders.Markdown.csproj
index f51a5b14c..176a17a38 100644
--- a/src/Pickles/Pickles.DocumentationBuilders.Markdown/Pickles.DocumentationBuilders.Markdown.csproj
+++ b/src/Pickles/Pickles.DocumentationBuilders.Markdown/Pickles.DocumentationBuilders.Markdown.csproj
@@ -35,6 +35,6 @@
-
+
\ No newline at end of file
diff --git a/src/Pickles/Pickles.DocumentationBuilders.Word.UnitTests/WhenBuildingWordDocuments.cs b/src/Pickles/Pickles.DocumentationBuilders.Word.UnitTests/WhenBuildingWordDocuments.cs
index 914553366..db2357b30 100644
--- a/src/Pickles/Pickles.DocumentationBuilders.Word.UnitTests/WhenBuildingWordDocuments.cs
+++ b/src/Pickles/Pickles.DocumentationBuilders.Word.UnitTests/WhenBuildingWordDocuments.cs
@@ -41,7 +41,12 @@ public class WhenBuildingWordDocuments : BaseFixture
{
private WordDocumentationBuilder builder;
private Tree features;
- private const string RootPath = FileSystemPrefix + @"OrderingTests";
+ private string RootPath { get; }
+
+ public WhenBuildingWordDocuments()
+ {
+ this.RootPath =FileSystem.Path.Combine(FileSystemPrefix,"OrderingTests");
+ }
[SetUp]
public void Setup()
@@ -75,7 +80,7 @@ public void ShouldOutputFeaturesInParsedOrder()
this.builder.Build(this.features);
- var outputPath = Path.Combine(Configuration.OutputFolder.FullName, "features.docx");
+ var outputPath =FileSystem.Path.Combine(Configuration.OutputFolder.FullName, "features.docx");
using (var stream = this.FileSystem.File.OpenRead(outputPath))
{
diff --git a/src/Pickles/Pickles.DocumentationBuilders.Word/Pickles.DocumentationBuilders.Word.csproj b/src/Pickles/Pickles.DocumentationBuilders.Word/Pickles.DocumentationBuilders.Word.csproj
index 76f0049c0..e494d61aa 100644
--- a/src/Pickles/Pickles.DocumentationBuilders.Word/Pickles.DocumentationBuilders.Word.csproj
+++ b/src/Pickles/Pickles.DocumentationBuilders.Word/Pickles.DocumentationBuilders.Word.csproj
@@ -25,8 +25,9 @@
-
+
+
diff --git a/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/FeatureNode.cs b/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/FeatureNode.cs
index 1f8abe6b6..2fe4cf091 100644
--- a/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/FeatureNode.cs
+++ b/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/FeatureNode.cs
@@ -27,7 +27,7 @@ namespace PicklesDoc.Pickles.DirectoryCrawler
{
public class FeatureNode : INode
{
- public FeatureNode(FileSystemInfoBase location, string relativePathFromRoot, Feature feature)
+ public FeatureNode(IFileSystemInfo location, string relativePathFromRoot, Feature feature)
{
this.OriginalLocation = location;
this.OriginalLocationUrl = location.ToUri();
@@ -47,7 +47,7 @@ public string Name
get { return this.Feature.Name; }
}
- public FileSystemInfoBase OriginalLocation { get; }
+ public IFileSystemInfo OriginalLocation { get; }
public Uri OriginalLocationUrl { get; }
diff --git a/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/FolderNode.cs b/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/FolderNode.cs
index 034cf512e..4a30734c2 100644
--- a/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/FolderNode.cs
+++ b/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/FolderNode.cs
@@ -26,7 +26,7 @@ namespace PicklesDoc.Pickles.DirectoryCrawler
{
public class FolderNode : INode
{
- public FolderNode(FileSystemInfoBase location, string relativePathFromRoot)
+ public FolderNode(IFileSystemInfo location, string relativePathFromRoot)
{
this.OriginalLocation = location;
this.OriginalLocationUrl = location.ToUri();
@@ -43,7 +43,7 @@ public string Name
get { return this.OriginalLocation.Name.ExpandWikiWord(); }
}
- public FileSystemInfoBase OriginalLocation { get; }
+ public IFileSystemInfo OriginalLocation { get; }
public Uri OriginalLocationUrl { get; }
diff --git a/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/INode.cs b/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/INode.cs
index 279bea1ee..3c894c656 100644
--- a/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/INode.cs
+++ b/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/INode.cs
@@ -47,7 +47,7 @@ public interface INode
string Name { get; }
- FileSystemInfoBase OriginalLocation { get; }
+ IFileSystemInfo OriginalLocation { get; }
Uri OriginalLocationUrl { get; }
diff --git a/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/ImageNode.cs b/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/ImageNode.cs
index 925e84d96..421c03e3d 100644
--- a/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/ImageNode.cs
+++ b/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/ImageNode.cs
@@ -27,7 +27,7 @@ namespace PicklesDoc.Pickles.DirectoryCrawler
{
public class ImageNode : INode
{
- public ImageNode(FileSystemInfoBase location, string relativePathFromRoot)
+ public ImageNode(IFileSystemInfo location, string relativePathFromRoot)
{
this.OriginalLocation = location;
this.OriginalLocationUrl = location.ToUri();
@@ -44,7 +44,7 @@ public string Name
get { return this.OriginalLocation.Name; }
}
- public FileSystemInfoBase OriginalLocation { get; }
+ public IFileSystemInfo OriginalLocation { get; }
public Uri OriginalLocationUrl { get; }
diff --git a/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/MarkdownNode.cs b/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/MarkdownNode.cs
index dad81770d..4316178eb 100644
--- a/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/MarkdownNode.cs
+++ b/src/Pickles/Pickles.ObjectModel/DirectoryCrawler/MarkdownNode.cs
@@ -28,7 +28,7 @@ namespace PicklesDoc.Pickles.DirectoryCrawler
{
public class MarkdownNode : INode
{
- public MarkdownNode(FileSystemInfoBase location, string relativePathFromRoot, XElement markdownContent)
+ public MarkdownNode(IFileSystemInfo location, string relativePathFromRoot, XElement markdownContent)
{
this.OriginalLocation = location;
this.OriginalLocationUrl = location.ToUri();
@@ -55,7 +55,7 @@ public string Name
}
}
- public FileSystemInfoBase OriginalLocation { get; }
+ public IFileSystemInfo OriginalLocation { get; }
public Uri OriginalLocationUrl { get; }
diff --git a/src/Pickles/Pickles.ObjectModel/Extensions/UriExtensions.cs b/src/Pickles/Pickles.ObjectModel/Extensions/UriExtensions.cs
index bf96f1d31..a7ec3e05e 100644
--- a/src/Pickles/Pickles.ObjectModel/Extensions/UriExtensions.cs
+++ b/src/Pickles/Pickles.ObjectModel/Extensions/UriExtensions.cs
@@ -19,64 +19,84 @@
// --------------------------------------------------------------------------------------------------------------------
using System;
+using System.IO;
using System.IO.Abstractions;
namespace PicklesDoc.Pickles.Extensions
{
public static class UriExtensions
{
- public static Uri ToUri(this DirectoryInfoBase instance)
- {
- string fullName = instance.FullName;
+ private const string _fileSchema = "file://";
+ private static readonly string _directorySeparator = Path.DirectorySeparatorChar.ToString();
- if (!instance.FullName.EndsWith(@"\"))
- {
- fullName = fullName + @"\";
- }
-
- return fullName.ToFolderUri();
+ public static Uri ToUri(this IDirectoryInfo instance)
+ {
+ return instance.FullName.ToFolderUri();
}
- public static Uri ToFileUriCombined(this DirectoryInfoBase instance, string file, IFileSystem fileSystem)
+ public static Uri ToFileUriCombined(this IDirectoryInfo instance, string file, IFileSystem fileSystem)
{
string path = fileSystem.Path.Combine(instance.FullName, file);
return path.ToFileUri();
}
- public static Uri ToUri(this FileSystemInfoBase instance)
+ public static Uri GetFileUri(this IDirectoryInfo instance, string file)
{
- var di = instance as DirectoryInfoBase;
+ return instance.FileSystem.Path.Combine(instance.FullName, file).ToFileUri();
+ }
+
+ public static Uri ToUri(this IFileSystemInfo instance)
+ {
+ var di = instance as IDirectoryInfo;
if (di != null)
{
return ToUri(di);
}
- return ToUri((FileInfoBase)instance);
+ return ToFileUri(instance.FullName);
}
- public static Uri ToUri(this FileInfoBase instance)
+ public static Uri ToUri(this IFileInfo instance)
{
return ToFileUri(instance.FullName);
}
- public static Uri ToFileUri(this string instance)
+ public static Uri ToFileUri(this string filePath)
{
- return new Uri(instance);
+ filePath = AddFileSchema(filePath);
+ return new Uri(filePath);
}
- public static Uri ToFolderUri(this string instance)
+ private static string AddFileSchema(string filePath)
{
- if (!instance.EndsWith(@"\"))
- {
- return new Uri(instance + @"\");
- }
+ if (!filePath.StartsWith(_fileSchema))
+ filePath = _fileSchema + filePath;
+ return filePath;
+ }
+
+ public static Uri ToFolderUri(this string folderPath)
+ {
+ folderPath = AddFileSchema(folderPath);
+
+ //Win-specific folder path
+ if (folderPath.EndsWith("\\"))
+ return new Uri(folderPath);
- return new Uri(instance);
+ if (!folderPath.EndsWith(_directorySeparator))
+ folderPath = folderPath + _directorySeparator;
+
+ return new Uri(folderPath);
+ }
+
+ public static Uri ToFolderUri(this Uri uri)
+ {
+ var uriString = uri.IsAbsoluteUri ? uri.AbsoluteUri : uri.ToString();
+ return uriString.EndsWith("/") ? uri : new Uri(uriString + "/",UriKind.RelativeOrAbsolute);
}
- public static string GetUriForTargetRelativeToMe(this Uri me, FileSystemInfoBase target, string newExtension)
+ public static string GetUriForTargetRelativeToMe(this Uri me, IFileSystemInfo target, string newExtension)
{
return target.FullName != me.LocalPath
? me.MakeRelativeUri(target.ToUri()).ToString().Replace(target.Extension, newExtension)
diff --git a/src/Pickles/Pickles.ObjectModel/IConfiguration.cs b/src/Pickles/Pickles.ObjectModel/IConfiguration.cs
index 11353f03c..5cc67dcb9 100644
--- a/src/Pickles/Pickles.ObjectModel/IConfiguration.cs
+++ b/src/Pickles/Pickles.ObjectModel/IConfiguration.cs
@@ -1,4 +1,4 @@
-// --------------------------------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------------------------------
//
// Copyright 2011 Jeffrey Cameron
// Copyright 2012-present PicklesDoc team and community contributors
@@ -25,9 +25,9 @@ namespace PicklesDoc.Pickles
{
public interface IConfiguration
{
- DirectoryInfoBase FeatureFolder { get; set; }
+ IDirectoryInfo FeatureFolder { get; set; }
- DirectoryInfoBase OutputFolder { get; set; }
+ IDirectoryInfo OutputFolder { get; set; }
DocumentationFormat DocumentationFormat { get; set; }
@@ -37,9 +37,9 @@ public interface IConfiguration
bool HasTestResults { get; }
- FileInfoBase TestResultsFile { get; }
+ IFileInfo TestResultsFile { get; }
- IEnumerable TestResultsFiles { get; }
+ IEnumerable TestResultsFiles { get; }
string SystemUnderTestName { get; set; }
@@ -50,9 +50,9 @@ public interface IConfiguration
string ExcludeTags { get; set; }
string HideTags { get; set; }
- void AddTestResultFile(FileInfoBase fileInfoBase);
+ void AddTestResultFile(IFileInfo IFileInfo);
- void AddTestResultFiles(IEnumerable fileInfoBases);
+ void AddTestResultFiles(IEnumerable IFileInfos);
void EnableExperimentalFeatures();
diff --git a/src/Pickles/Pickles.ObjectModel/Pickles.ObjectModel.csproj b/src/Pickles/Pickles.ObjectModel/Pickles.ObjectModel.csproj
index a0be11afd..d4f9cb58a 100644
--- a/src/Pickles/Pickles.ObjectModel/Pickles.ObjectModel.csproj
+++ b/src/Pickles/Pickles.ObjectModel/Pickles.ObjectModel.csproj
@@ -14,6 +14,6 @@
pdbonly
-
+
\ No newline at end of file
diff --git a/src/Pickles/Pickles.PowerShell/Pickle_Features.cs b/src/Pickles/Pickles.PowerShell/Pickle_Features.cs
index b9347d916..965c1aaf7 100644
--- a/src/Pickles/Pickles.PowerShell/Pickle_Features.cs
+++ b/src/Pickles/Pickles.PowerShell/Pickle_Features.cs
@@ -68,7 +68,7 @@ public class Pickle_Features : PSCmdlet
[Parameter(HelpMessage = CommandLineArgumentHelpTexts.HelpHideTags, Mandatory = false)]
public string HideTags { get; set; }
-
+
protected override void ProcessRecord()
{
@@ -149,9 +149,9 @@ private void ParseParameters(IConfiguration configuration, IFileSystem fileSyste
}
}
- private DirectoryInfoBase DetermineFeatureFolder(IFileSystem fileSystem, PathInfo currentFileSystemLocation, string directory)
+ private IDirectoryInfo DetermineFeatureFolder(IFileSystem fileSystem, PathInfo currentFileSystemLocation, string directory)
{
- DirectoryInfoBase result;
+ IDirectoryInfo result;
if (fileSystem.Path.IsPathRooted(directory))
{
diff --git a/src/Pickles/Pickles.Test/AssertExtensions.cs b/src/Pickles/Pickles.Test/AssertExtensions.cs
index cf121ddfe..18ae029a3 100644
--- a/src/Pickles/Pickles.Test/AssertExtensions.cs
+++ b/src/Pickles/Pickles.Test/AssertExtensions.cs
@@ -23,6 +23,8 @@
using System.Xml.Linq;
using NFluent;
using NFluent.Extensibility;
+using NFluent.Kernel;
+using NFluent.Messages;
namespace PicklesDoc.Pickles.Test
{
@@ -65,7 +67,7 @@ public static void IsDeeplyEqualTo(this ICheck check, XElement actual)
if (!XNode.DeepEquals(element, actual))
{
- var fluentMessage = FluentMessage.BuildMessage("The {0} is not equal to the given one (using deep comparison)").For("XML element").On(element.ToString()).And.WithGivenValue(actual.ToString());
+ var fluentMessage = FluentMessage.BuildMessage("The {0} is not equal to the given one (using deep comparison)").For(new EntityNamingLogic("XML element")).On(element.ToString()).And.WithGivenValue(actual.ToString());
throw new FluentCheckException(fluentMessage.ToString());
}
diff --git a/src/Pickles/Pickles.Test/BaseFixture.cs b/src/Pickles/Pickles.Test/BaseFixture.cs
index a2f4635f0..48b9fb15f 100644
--- a/src/Pickles/Pickles.Test/BaseFixture.cs
+++ b/src/Pickles/Pickles.Test/BaseFixture.cs
@@ -1,4 +1,4 @@
-// --------------------------------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------------------------------
//
// Copyright 2011 Jeffrey Cameron
// Copyright 2012-present PicklesDoc team and community contributors
@@ -20,6 +20,7 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.IO.Abstractions;
using System.IO.Abstractions.TestingHelpers;
using System.Reflection;
@@ -32,7 +33,7 @@ namespace PicklesDoc.Pickles.Test
{
public class BaseFixture
{
- protected const string FileSystemPrefix = @"c:\temp\FakeFolderStructures\";
+ protected readonly string FileSystemPrefix;
protected const string ResourcePrefix = "PicklesDoc.Pickles.Test.FakeFolderStructures.";
private IContainer container;
private readonly string currentDirectory;
@@ -40,10 +41,11 @@ public class BaseFixture
public BaseFixture(string currentDirectory)
{
this.currentDirectory = currentDirectory;
+ FileSystemPrefix =FileSystem.Path.Combine(currentDirectory,"temp","FakeFolderStructures");
}
public BaseFixture()
- : this(Assembly.GetExecutingAssembly().Location)
+ : this(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))
{
}
@@ -103,26 +105,26 @@ protected void AddFakeFolderStructures()
this.AddFakeFolderAndFiles("EmptyFolderTests", new string[0]);
this.AddFakeFolderAndFiles("FeatureCrawlerTests", new[] { "index.md", "LevelOne.feature", "image.png", "LevelOneIgnoredFeature.feature", "LevelOneRemoveTagsToHide.feature" });
- this.AddFakeFolderAndFiles(@"FeatureCrawlerTests\SubLevelOne", new[] { "ignorethisfile.ignore", "LevelOneSublevelOne.feature", "LevelOneSublevelTwo.feature" });
- this.AddFakeFolderAndFiles(@"FeatureCrawlerTests\SubLevelOne\SubLevelTwo", new[] { "LevelOneSublevelOneSubLevelTwo.feature" });
- this.AddFakeFolderAndFiles(@"FeatureCrawlerTests\SubLevelOne\SubLevelTwo\IgnoreThisDirectory", new[] { "IgnoreThisFile.ignore" });
+ this.AddFakeFolderAndFiles(FileSystem.Path.Combine("FeatureCrawlerTests","SubLevelOne"), new[] { "ignorethisfile.ignore", "LevelOneSublevelOne.feature", "LevelOneSublevelTwo.feature" });
+ this.AddFakeFolderAndFiles(FileSystem.Path.Combine("FeatureCrawlerTests","SubLevelOne","SubLevelTwo"), new[] { "LevelOneSublevelOneSubLevelTwo.feature" });
+ this.AddFakeFolderAndFiles(FileSystem.Path.Combine("FeatureCrawlerTests","SubLevelOne","SubLevelTwo","IgnoreThisDirectory"), new[] { "IgnoreThisFile.ignore" });
this.AddFakeFolderAndFiles(@"OrderingTests", new string[0]);
- this.AddFakeFolderAndFiles(@"OrderingTests\A", new [] {"a-a.feature", "a-b.feature"});
- this.AddFakeFolderAndFiles(@"OrderingTests\B", new [] {"b-a.feature", "b-b.feature"});
+ this.AddFakeFolderAndFiles(FileSystem.Path.Combine("OrderingTests","A"), new [] {"a-a.feature", "a-b.feature"});
+ this.AddFakeFolderAndFiles(FileSystem.Path.Combine("OrderingTests","B"), new [] {"b-a.feature", "b-b.feature"});
}
protected void AddFakeFolderAndFiles(string directoryName, IEnumerable fileNames)
{
- string directoryPath = FileSystemPrefix + directoryName + @"\";
- string resourceIdentifier = ResourcePrefix + directoryName.Replace(@"\", ".") + ".";
+ string directoryPath =FileSystem.Path.Combine(FileSystemPrefix, directoryName);
+ string resourceIdentifier = ResourcePrefix + directoryName.Replace(Path.DirectorySeparatorChar, '.') + ".";
this.FileSystem.AddDirectory(directoryPath);
foreach (var fileName in fileNames)
{
this.FileSystem.AddFile(
- directoryPath + fileName,
+ FileSystem.Path.Combine(directoryPath,fileName),
RetrieveContentOfFileFromResources(resourceIdentifier + fileName));
}
}
diff --git a/src/Pickles/Pickles.Test/DataStructures/TreeTests.cs b/src/Pickles/Pickles.Test/DataStructures/TreeTests.cs
index d302700f7..1e0976dfb 100644
--- a/src/Pickles/Pickles.Test/DataStructures/TreeTests.cs
+++ b/src/Pickles/Pickles.Test/DataStructures/TreeTests.cs
@@ -19,6 +19,7 @@
// --------------------------------------------------------------------------------------------------------------------
using System;
+using System.IO;
using System.IO.Abstractions;
using System.Linq;
@@ -34,8 +35,12 @@ namespace PicklesDoc.Pickles.Test.DataStructures
[TestFixture]
public class TreeTests : BaseFixture
{
- private const string RootPath = FileSystemPrefix + @"OrderingTests";
+ private string RootPath {get;}
+ public TreeTests()
+ {
+ RootPath =FileSystem.Path.Combine(FileSystemPrefix,"OrderingTests");
+ }
[Test]
public void ShouldIterateInRightOrder()
{
@@ -102,7 +107,7 @@ public MyNode(string name)
public string Name { get; }
- public FileSystemInfoBase OriginalLocation { get; }
+ public IFileSystemInfo OriginalLocation { get; }
public Uri OriginalLocationUrl { get; }
diff --git a/src/Pickles/Pickles.Test/DirectoryCrawlers/FolderDirectoryTreeNodeTests.cs b/src/Pickles/Pickles.Test/DirectoryCrawlers/FolderDirectoryTreeNodeTests.cs
index a34f33c1e..3b5d218ba 100644
--- a/src/Pickles/Pickles.Test/DirectoryCrawlers/FolderDirectoryTreeNodeTests.cs
+++ b/src/Pickles/Pickles.Test/DirectoryCrawlers/FolderDirectoryTreeNodeTests.cs
@@ -1,4 +1,4 @@
-// --------------------------------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------------------------------
//
// Copyright 2011 Jeffrey Cameron
// Copyright 2012-present PicklesDoc team and community contributors
@@ -19,39 +19,43 @@
// --------------------------------------------------------------------------------------------------------------------
using System;
+using System.IO;
+using System.IO.Abstractions;
using NFluent;
using NUnit.Framework;
using PicklesDoc.Pickles.DirectoryCrawler;
+using PicklesDoc.Pickles.Extensions;
namespace PicklesDoc.Pickles.Test.DirectoryCrawlers
{
+
[TestFixture]
public class FolderDirectoryTreeNodeTests : BaseFixture
{
[Test]
public void Constructor_ValidFileSystemInfo_SetsOriginalLocation()
{
- var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName(@"c:\temp\");
+ var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName(@"temp");
var node = new FolderNode(directoryInfo, "");
- Check.That(node.OriginalLocation.FullName).IsEqualTo(@"c:\temp");
+ Check.That(node.OriginalLocation.FullName).EndsWith(@"temp");
}
[Test]
public void Constructor_ValidFileSystemInfo_SetsOriginalLocationUrl()
{
- var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName(@"c:\temp");
+ var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName(@"temp");
var node = new FolderNode(directoryInfo, "");
- Check.That(node.OriginalLocationUrl.ToString()).IsEqualTo(@"file:///c:/temp/");
+ Check.That(node.OriginalLocationUrl.ToString()).Matches(@"file://(.*)temp");
}
[Test]
public void Constructor_ValidRelativePath()
{
- var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName(@"c:\temp");
+ var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName("temp");
var node = new FolderNode(directoryInfo, "../");
@@ -61,23 +65,24 @@ public void Constructor_ValidRelativePath()
[Test]
public void GetRelativeUriTo_DirectoryToChildDirectory_ReturnsRelativePath()
{
- var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName(@"c:\temp");
+ var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName("temp");
var node = new FolderNode(directoryInfo, "../");
+ var uri =FileSystem.Path.Combine(directoryInfo.FullName,"child").ToFolderUri();
+ string relative = node.GetRelativeUriTo(uri);
- string relative = node.GetRelativeUriTo(new Uri(@"file:///c:/temp/child/"));
-
- Check.That(relative).IsEqualTo("../");
+ Check.That(relative).Contains("../");
}
[Test]
public void GetRelativeUriTo_DirectoryToFileBelow_ReturnsCurrentDirectory()
{
- var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName(@"c:\temp");
+ var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName("temp");
var node = new FolderNode(directoryInfo, "../");
- string relative = node.GetRelativeUriTo(new Uri(@"file:///c:/temp/test2.html"));
+ var uri = directoryInfo.GetFileUri("test2.html");
+ string relative = node.GetRelativeUriTo(uri);
Check.That(relative).IsEqualTo("./");
}
@@ -85,11 +90,12 @@ public void GetRelativeUriTo_DirectoryToFileBelow_ReturnsCurrentDirectory()
[Test]
public void GetRelativeUriTo_DirectoryToFileOutside_ReturnsRelativePath()
{
- var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName(@"c:\temp");
+ var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName("temp");
var node = new FolderNode(directoryInfo, "../");
- string relative = node.GetRelativeUriTo(new Uri(@"file:///c:/temp2/test2.html"));
+ var uri =FileSystem.Path.Combine(FileSystem.DirectoryInfo.FromDirectoryName("temp2").FullName,"test2.html").ToFileUri();
+ string relative = node.GetRelativeUriTo(uri);
Check.That(relative).IsEqualTo("../temp/");
}
@@ -97,11 +103,12 @@ public void GetRelativeUriTo_DirectoryToFileOutside_ReturnsRelativePath()
[Test]
public void GetRelativeUriTo_DirectoryToParentDirectory_ReturnsRelativePath()
{
- var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName(@"c:\temp\child");
+ var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName(FileSystem.Path.Combine("temp","child"));
var node = new FolderNode(directoryInfo, "../");
- string relative = node.GetRelativeUriTo(new Uri(@"file:///c:/temp/"));
+ var uri = FileSystem.DirectoryInfo.FromDirectoryName("temp").FullName.ToFolderUri();
+ string relative = node.GetRelativeUriTo(uri);
Check.That(relative).IsEqualTo("child/");
}
@@ -109,11 +116,12 @@ public void GetRelativeUriTo_DirectoryToParentDirectory_ReturnsRelativePath()
[Test]
public void GetRelativeUriTo_FileToDirectory_ReturnsNodesFileName()
{
- var fileInfo = FileSystem.FileInfo.FromFileName(@"c:\temp\test1.html");
+ var fileInfo = FileSystem.FileInfo.FromFileName(FileSystem.Path.Combine("temp","test1.html"));
var node = new FolderNode(fileInfo, "../");
- string relative = node.GetRelativeUriTo(new Uri(@"file:///c:/temp/"));
+ var uri = FileSystem.FileInfo.FromFileName("temp").FullName.ToFolderUri();
+ string relative = node.GetRelativeUriTo(uri);
Check.That(relative).IsEqualTo("test1.html");
}
@@ -121,11 +129,12 @@ public void GetRelativeUriTo_FileToDirectory_ReturnsNodesFileName()
[Test]
public void GetRelativeUriTo_FileToFile_ReturnsNodesFileName()
{
- var fileInfo = FileSystem.FileInfo.FromFileName(@"c:\temp\test1.html");
+ var fileInfo = FileSystem.FileInfo.FromFileName(FileSystem.Path.Combine("temp","test1.html"));
var node = new FolderNode(fileInfo, "../");
- string relative = node.GetRelativeUriTo(new Uri(@"file:///c:/temp/test2.html"));
+ var uri = FileSystem.FileInfo.FromFileName(FileSystem.Path.Combine("temp","test2.html")).FullName.ToFileUri();
+ string relative = node.GetRelativeUriTo(uri);
Check.That(relative).IsEqualTo("test1.html");
}
@@ -134,18 +143,18 @@ public void GetRelativeUriTo_FileToFile_ReturnsNodesFileName()
public void RealData()
{
var originalLocation =
- FileSystem.DirectoryInfo.FromDirectoryName(
- @"C:\tfs\Dev.CAX\src\CAX_Main\src\net\Projects\Aim.Gain.GoldenCopy.FunctionalTesting\CAX\DistributionOfRights");
+ FileSystem.DirectoryInfo.FromDirectoryName(FileSystem.Path.Combine(
+ "tfs","Dev.CAX","src","CAX_Main","src","net","Projects","Aim.Gain.GoldenCopy.FunctionalTesting","CAX","DistributionOfRights"));
var node = new FolderNode(originalLocation, "");
- var other =
- new Uri(
- "file:///C:/tfs/Dev.CAX/src/CAX_Main/src/net/Projects/Aim.Gain.GoldenCopy.FunctionalTesting/CAX/");
+ var uri =
+ FileSystem.DirectoryInfo.FromDirectoryName(FileSystem.Path.Combine("tfs", "Dev.CAX", "src", "CAX_Main", "src", "net", "Projects",
+ "Aim.Gain.GoldenCopy.FunctionalTesting", "CAX")).FullName.ToFolderUri();
- string relative = node.GetRelativeUriTo(other);
+ string relative = node.GetRelativeUriTo(uri);
- Check.That(relative).IsEqualTo("DistributionOfRights/");
+ Check.That(relative).IsEqualTo("DistributionOfRights"+Path.DirectorySeparatorChar);
}
}
}
diff --git a/src/Pickles/Pickles.Test/Extensions/PathExtensionsTests.cs b/src/Pickles/Pickles.Test/Extensions/PathExtensionsTests.cs
index 157c436bb..e0cb66148 100644
--- a/src/Pickles/Pickles.Test/Extensions/PathExtensionsTests.cs
+++ b/src/Pickles/Pickles.Test/Extensions/PathExtensionsTests.cs
@@ -19,6 +19,7 @@
// --------------------------------------------------------------------------------------------------------------------
using System;
+using System.IO;
using System.IO.Abstractions.TestingHelpers;
using NFluent;
using NUnit.Framework;
@@ -33,22 +34,22 @@ internal class PathExtensionsTests : BaseFixture
public void Get_A_Relative_Path_When_Location_Is_Deeper_Than_Root()
{
MockFileSystem fileSystem = FileSystem;
- fileSystem.AddFile(@"c:\test\deep\blah.feature", "Feature:"); // adding a file automatically adds all parent directories
+ fileSystem.AddFile(FileSystem.Path.Combine("test","deep","blah.feature"),"Feature:"); // adding a file automatically adds all parent directories
- string actual = PathExtensions.MakeRelativePath(@"c:\test", @"c:\test\deep\blah.feature", fileSystem);
+ string actual = PathExtensions.MakeRelativePath("test",FileSystem.Path.Combine("test","deep","blah.feature"), fileSystem);
- Check.That(actual).IsEqualTo(@"deep\blah.feature");
+ Check.That(actual).IsEqualTo(FileSystem.Path.Combine("deep","blah.feature"));
}
[Test]
public void Get_A_Relative_Path_When_Location_Is_Deeper_Than_Root_Even_When_Root_Contains_End_Slash()
{
MockFileSystem fileSystem = FileSystem;
- fileSystem.AddFile(@"c:\test\deep\blah.feature", "Feature:"); // adding a file automatically adds all parent directories
+ fileSystem.AddFile(FileSystem.Path.Combine("test","deep","blah.feature"), "Feature:"); // adding a file automatically adds all parent directories
- string actual = PathExtensions.MakeRelativePath(@"c:\test\", @"c:\test\deep\blah.feature", fileSystem);
+ string actual = PathExtensions.MakeRelativePath("test",FileSystem.Path.Combine("test","deep","blah.feature"), fileSystem);
- Check.That(actual).IsEqualTo(@"deep\blah.feature");
+ Check.That(actual).IsEqualTo(FileSystem.Path.Combine("deep","blah.feature"));
}
}
}
diff --git a/src/Pickles/Pickles.Test/Extensions/UriExtensionsTests.cs b/src/Pickles/Pickles.Test/Extensions/UriExtensionsTests.cs
index 9f94549c6..ad388c9b2 100644
--- a/src/Pickles/Pickles.Test/Extensions/UriExtensionsTests.cs
+++ b/src/Pickles/Pickles.Test/Extensions/UriExtensionsTests.cs
@@ -19,6 +19,7 @@
// --------------------------------------------------------------------------------------------------------------------
using System;
+using System.IO;
using NFluent;
using NUnit.Framework;
using PicklesDoc.Pickles.Extensions;
@@ -31,19 +32,19 @@ public class UriExtensionsTests : BaseFixture
[Test]
public void ToFileUriCombined_ValidIntput_ValidOutput()
{
- var info = FileSystem.DirectoryInfo.FromDirectoryName(@"c:\temp");
+ var info = FileSystem.DirectoryInfo.FromDirectoryName("temp");
Uri uri = info.ToFileUriCombined("test.txt", FileSystem);
- Check.That(uri.ToString()).IsEqualTo("file:///c:/temp/test.txt");
+ Check.That(uri).IsEqualTo(new Uri("file://" + FileSystem.Path.Combine(info.FullName,"test.txt")));
}
[Test]
public void ToFileUriString_WithoutTrailingSlash_ValidOutputWithTrailingSlash()
{
- Uri uri = @"c:\temp\test.txt".ToFileUri();
+ Uri uri =FileSystem.Path.Combine("temp","test.txt").ToFileUri();
- Check.That(uri.ToString()).IsEqualTo("file:///c:/temp/test.txt");
+ Check.That(uri).IsEqualTo(new Uri("file://" + FileSystem.Path.Combine("temp","test.txt")));
}
[Test]
@@ -65,51 +66,51 @@ public void ToFolderUriString_WithoutTrailingSlash_ValidOutputWithTrailingSlash(
[Test]
public void ToUriDirectoryInfo_WithTrailingSlash_ProducesUriWithTrailingSlash()
{
- var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName(@"c:\temp\");
+ var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName("temp"+Path.DirectorySeparatorChar);
Uri uri = directoryInfo.ToUri();
- Check.That(uri.ToString()).IsEqualTo("file:///c:/temp/");
+ Check.That(uri).IsEqualTo(new Uri("file://"+directoryInfo.FullName+"/"));
}
[Test]
public void ToUriDirectoryInfo_WithoutTrailingSlash_ProducesUriWithTrailingSlash()
{
- var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName(@"c:\temp");
+ var directoryInfo = FileSystem.DirectoryInfo.FromDirectoryName("temp");
Uri uri = directoryInfo.ToUri();
- Check.That(uri.ToString()).IsEqualTo("file:///c:/temp/");
+ Check.That(uri).IsEqualTo(new Uri("file://"+directoryInfo.FullName+"/"));
}
[Test]
public void ToUriFileInfo_NormalFilename_ProducesUri()
{
- var fileInfo = FileSystem.FileInfo.FromFileName(@"c:\temp\test.txt");
+ var fileInfo = FileSystem.FileInfo.FromFileName(FileSystem.Path.Combine("temp","test.txt"));
Uri uri = fileInfo.ToUri();
- Check.That(uri.ToString()).IsEqualTo("file:///c:/temp/test.txt");
+ Check.That(uri).IsEqualTo(new Uri("file://"+fileInfo.FullName));
}
[Test]
public void ToUriFileSystemInfo_DirectoryWithTrailingSlash_ProducesUriWithTrailingSlash()
{
- var fsi = FileSystem.DirectoryInfo.FromDirectoryName(@"c:\temp\");
+ var fsi = FileSystem.DirectoryInfo.FromDirectoryName("temp");
Uri uri = fsi.ToUri();
- Check.That(uri.ToString()).IsEqualTo("file:///c:/temp/");
+ Check.That(uri).IsEqualTo(new Uri("file://"+fsi.FullName+"/"));
}
[Test]
public void ToUriFileSystemInfo_FileInfo_ProducesUri()
{
- var fsi = FileSystem.FileInfo.FromFileName(@"c:\temp\test.txt");
+ var fsi = FileSystem.FileInfo.FromFileName(FileSystem.Path.Combine("temp","test.txt"));
Uri uri = fsi.ToUri();
- Check.That(uri.ToString()).IsEqualTo("file:///c:/temp/test.txt");
+ Check.That(uri).IsEqualTo(new Uri("file://"+fsi.FullName));
}
}
}
diff --git a/src/Pickles/Pickles.Test/Extensions/XElementExtensions.cs b/src/Pickles/Pickles.Test/Extensions/XElementExtensions.cs
index b73073446..671e2013b 100644
--- a/src/Pickles/Pickles.Test/Extensions/XElementExtensions.cs
+++ b/src/Pickles/Pickles.Test/Extensions/XElementExtensions.cs
@@ -23,6 +23,9 @@
using System.Xml.Linq;
using NFluent;
using NFluent.Extensibility;
+using NFluent.Kernel;
+using NFluent.Messages;
+using NUnit.Framework;
namespace PicklesDoc.Pickles.Test.Extensions
{
@@ -42,17 +45,17 @@ private static bool RecursiveSearch(this XElement element, Predicate s
public static ICheckLink> ContainsGherkinTable(this ICheck check)
{
var checker = ExtensibilityHelper.ExtractChecker(check);
-
return checker.ExecuteCheck(
() =>
{
if (!checker.Value.RecursiveSearch(element => element.HasAttribute("class", "table_container")))
{
- var errorMessage = FluentMessage.BuildMessage("The {0} does not contain a gherkin table (marked by the presence of a class attribute with value 'table_container')").For("XML element").On(checker.Value).ToString();
- throw new FluentCheckException(errorMessage);
+ var errorMessage = FluentMessage.BuildMessage("The {0} does not contain a gherkin table (marked by the presence of a class attribute with value 'table_container')").For(new EntityNamingLogic("XML element")).On(checker.Value).ToString();
+ //Somehow NFluent does not recognise FluentCheckException on netcoreapp 3.1
+ throw new AssertionException(errorMessage);
}
},
- FluentMessage.BuildMessage("The {0} contains a gherkin table (marked by the presence of a class attribute with value 'table_container'), whereas it must not.").For("XML element").On(checker.Value).ToString());
+ FluentMessage.BuildMessage("The {0} contains a gherkin table (marked by the presence of a class attribute with value 'table_container'), whereas it must not.").For(new EntityNamingLogic("XML element")).On(checker.Value).ToString());
}
public static ICheckLink> ContainsGherkinScenario(this ICheck check)
@@ -64,11 +67,11 @@ public static ICheckLink> ContainsGherkinScenario(this ICheck element.HasAttribute("class", "scenario")))
{
- var errorMessage = FluentMessage.BuildMessage("The {0} does not contain a gherkin scenario (marked by the presence of a class attribute with value 'scenario')").For("XML element").On(checker.Value).ToString();
+ var errorMessage = FluentMessage.BuildMessage("The {0} does not contain a gherkin scenario (marked by the presence of a class attribute with value 'scenario')").For(new EntityNamingLogic("XML element")).On(checker.Value).ToString();
throw new FluentCheckException(errorMessage);
}
},
- FluentMessage.BuildMessage("The {0} contains a gherkin scenario (marked by the presence of a class attribute with value 'scenario'), whereas it must not.").For("XML element").On(checker.Value).ToString());
+ FluentMessage.BuildMessage("The {0} contains a gherkin scenario (marked by the presence of a class attribute with value 'scenario'), whereas it must not.").For(new EntityNamingLogic("XML element")).On(checker.Value).ToString());
}
}
}
diff --git a/src/Pickles/Pickles.Test/FeatureNodeFactoryTests.cs b/src/Pickles/Pickles.Test/FeatureNodeFactoryTests.cs
index cf3e16b12..afb9d9a6e 100644
--- a/src/Pickles/Pickles.Test/FeatureNodeFactoryTests.cs
+++ b/src/Pickles/Pickles.Test/FeatureNodeFactoryTests.cs
@@ -20,6 +20,7 @@
using System;
using System.IO;
+using System.IO.Abstractions;
using System.IO.Abstractions.TestingHelpers;
using System.Linq;
using NFluent;
@@ -35,30 +36,31 @@ public class FeatureNodeFactoryTests : BaseFixture
[Test]
public void Create_InvalidFeatureFile_AddsEntryToReport()
{
- FileSystem.AddFile(@"c:\test.feature", new MockFileData("Invalid feature file"));
+ FileSystem.AddFile(@"test.feature", new MockFileData("Invalid feature file"));
var featureNodeFactory = this.CreateFeatureNodeFactory();
var report = new ParsingReport();
- featureNodeFactory.Create(null, FileSystem.FileInfo.FromFileName(@"c:\test.feature"), report);
+ featureNodeFactory.Create(null, FileSystem.FileInfo.FromFileName(@"test.feature"), report);
- Check.That(report.First()).Contains(@"c:\test.feature");
+ Check.That(report.First()).Contains(@"test.feature");
}
[Test]
public void Create_MarkdownParsingError_AddsEntryToReport()
{
- FileSystem.AddFile(@"c:\test.md", new MockFileData("* Some Markdown text"));
+ FileSystem.AddFile(@"test.md", new MockFileData("* Some Markdown text"));
var featureNodeFactory = this.CreateFeatureNodeFactory(new MockMarkdownProvider());
var report = new ParsingReport();
- featureNodeFactory.Create(null, FileSystem.FileInfo.FromFileName(@"c:\test.md"), report);
+ var fileInfo = FileSystem.FileInfo.FromFileName(@"test.md");
+ featureNodeFactory.Create(null, fileInfo, report);
Check.That(report.Count).Equals(1);
- Check.That(report.First()).Equals(@"Error parsing the Markdown file located at c:\test.md. Error: Error parsing text.");
+ Check.That(report.First()).Equals($"Error parsing the Markdown file located at {fileInfo.FullName}. Error: Error parsing text.");
}
private FeatureNodeFactory CreateFeatureNodeFactory()
@@ -99,41 +101,43 @@ public void Create_BogusLocationType_AddsEntryToReport()
var report = new ParsingReport();
- featureNodeFactory.Create(null, new BogusFileSystemInfoBase { fullName = "Totally Bad Name"}, report);
+ featureNodeFactory.Create(null, new BogusIFileSystemInfo { fullName = "Totally Bad Name"}, report);
Check.That(report.First()).Contains(@"Totally Bad Name");
}
- private class BogusFileSystemInfoBase : System.IO.Abstractions.FileSystemInfoBase
+ private class BogusIFileSystemInfo : System.IO.Abstractions.IFileSystemInfo
{
internal string fullName;
- public override void Delete()
+ public void Delete()
{
throw new NotImplementedException();
}
- public override void Refresh()
+ public void Refresh()
{
throw new NotImplementedException();
}
- public override FileAttributes Attributes { get; set; }
- public override DateTime CreationTime { get; set; }
- public override DateTime CreationTimeUtc { get; set; }
- public override bool Exists { get; }
- public override string Extension { get; }
+ public IFileSystem FileSystem { get; set; }
- public override string FullName
+ public FileAttributes Attributes { get; set; }
+ public DateTime CreationTime { get; set; }
+ public DateTime CreationTimeUtc { get; set; }
+ public bool Exists { get; }
+ public string Extension { get; }
+
+ public string FullName
{
get { return this.fullName; }
}
- public override DateTime LastAccessTime { get; set; }
- public override DateTime LastAccessTimeUtc { get; set; }
- public override DateTime LastWriteTime { get; set; }
- public override DateTime LastWriteTimeUtc { get; set; }
- public override string Name { get; }
+ public DateTime LastAccessTime { get; set; }
+ public DateTime LastAccessTimeUtc { get; set; }
+ public DateTime LastWriteTime { get; set; }
+ public DateTime LastWriteTimeUtc { get; set; }
+ public string Name { get; }
}
private class MockMarkdownProvider : IMarkdownProvider
diff --git a/src/Pickles/Pickles.Test/FileSystemBasedFeatureParserTests.cs b/src/Pickles/Pickles.Test/FileSystemBasedFeatureParserTests.cs
index 08765ed15..7848f1258 100644
--- a/src/Pickles/Pickles.Test/FileSystemBasedFeatureParserTests.cs
+++ b/src/Pickles/Pickles.Test/FileSystemBasedFeatureParserTests.cs
@@ -19,9 +19,11 @@
// --------------------------------------------------------------------------------------------------------------------
using System;
+using System.IO;
using System.IO.Abstractions.TestingHelpers;
using NFluent;
using NUnit.Framework;
+using PicklesDoc.Pickles.Extensions;
namespace PicklesDoc.Pickles.Test
{
@@ -31,13 +33,14 @@ public class FileSystemBasedFeatureParserTests : BaseFixture
[Test]
public void Parse_InvalidFeatureFile_ThrowsFeatureParseExceptionWithFilename()
{
- FileSystem.AddFile(@"c:\temp\featurefile.feature", new MockFileData("Invalid feature file"));
+ var filePath =FileSystem.Path.Combine("temp","featurefile.feature");
+ FileSystem.AddFile(filePath, new MockFileData("Invalid feature file"));
+ var fileInfo=FileSystem.FileInfo.FromFileName(filePath);
var parser = new FileSystemBasedFeatureParser(new FeatureParser(Configuration), FileSystem);
- Check.ThatCode(() => parser.Parse(@"c:\temp\featurefile.feature")).Throws()
- .WithMessage(@"There was an error parsing the feature file here: c:\temp\featurefile.feature" +
+ Check.ThatCode(() => parser.Parse(filePath)).Throws()
+ .WithMessage(@"There was an error parsing the feature file here: "+ fileInfo.FullName +
Environment.NewLine + @"Errormessage was: 'Unable to parse feature'");
}
-
}
}
\ No newline at end of file
diff --git a/src/Pickles/Pickles.Test/FileSystemExtensions.cs b/src/Pickles/Pickles.Test/FileSystemExtensions.cs
new file mode 100644
index 000000000..a2a0e04e4
--- /dev/null
+++ b/src/Pickles/Pickles.Test/FileSystemExtensions.cs
@@ -0,0 +1,35 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright 2011 Jeffrey Cameron
+// Copyright 2012-present PicklesDoc team and community contributors
+//
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+using System.IO.Abstractions;
+
+namespace PicklesDoc.Pickles.Test
+{
+ public static class FileSystemExtensions
+ {
+ public static IDirectoryInfo GetOrCreateDirectory(this IFileSystem fileSystem, string directory)
+ {
+ var directoryInfo = fileSystem.DirectoryInfo.FromDirectoryName(directory);
+ if(!directoryInfo.Exists)
+ directoryInfo.Create();
+ return directoryInfo;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Pickles/Pickles.Test/Formatters/HtmlDocumentationBuilderTests.cs b/src/Pickles/Pickles.Test/Formatters/HtmlDocumentationBuilderTests.cs
index 33cf658eb..d1cefc0f9 100644
--- a/src/Pickles/Pickles.Test/Formatters/HtmlDocumentationBuilderTests.cs
+++ b/src/Pickles/Pickles.Test/Formatters/HtmlDocumentationBuilderTests.cs
@@ -19,7 +19,7 @@
// --------------------------------------------------------------------------------------------------------------------
using System;
-
+using System.IO;
using Autofac;
using NUnit.Framework;
using PicklesDoc.Pickles.DirectoryCrawler;
@@ -30,8 +30,12 @@ namespace PicklesDoc.Pickles.Test.Formatters
[TestFixture]
public class HtmlDocumentationBuilderTests : BaseFixture
{
- private const string RootPath = FileSystemPrefix + @"EmptyFolderTests";
+ private string RootPath { get; }
+ public HtmlDocumentationBuilderTests()
+ {
+ RootPath =FileSystem.Path.Combine(FileSystemPrefix, "EmptyFolderTests");
+ }
[Test]
public void ShouldNotBlowUpWHenParsingEmptyFolder()
{
diff --git a/src/Pickles/Pickles.Test/Formatters/JSON/WhenCreatingAFeatureWithMetaInfo.cs b/src/Pickles/Pickles.Test/Formatters/JSON/WhenCreatingAFeatureWithMetaInfo.cs
index 2acde7170..49c6c6f92 100644
--- a/src/Pickles/Pickles.Test/Formatters/JSON/WhenCreatingAFeatureWithMetaInfo.cs
+++ b/src/Pickles/Pickles.Test/Formatters/JSON/WhenCreatingAFeatureWithMetaInfo.cs
@@ -19,6 +19,7 @@
// --------------------------------------------------------------------------------------------------------------------
using System;
+using System.IO;
using System.IO.Abstractions;
using NFluent;
using NUnit.Framework;
@@ -31,14 +32,18 @@ namespace PicklesDoc.Pickles.Test.Formatters.JSON
public class WhenCreatingAFeatureWithMetaInfo : BaseFixture
{
private const string RelativePath = @"AcceptanceTest";
- private const string RootPath = FileSystemPrefix + @"AcceptanceTest";
+ private string RootPath { get; }
private const string FeaturePath = @"AdvancedFeature.feature";
private FeatureNode featureDirectoryNode;
- private FileInfoBase featureFileInfo;
+ private IFileInfo featureFileInfo;
private JsonFeatureWithMetaInfo featureWithMeta;
private Feature testFeature;
+ public WhenCreatingAFeatureWithMetaInfo()
+ {
+ RootPath =FileSystem.Path.Combine(FileSystemPrefix,"AcceptanceTest");
+ }
public void Setup()
{
this.testFeature = new Feature { Name = "Test" };
diff --git a/src/Pickles/Pickles.Test/Formatters/JSON/WhenCreatingAFeatureWithMetaInfoAndTestResultInMstestFormat.cs b/src/Pickles/Pickles.Test/Formatters/JSON/WhenCreatingAFeatureWithMetaInfoAndTestResultInMstestFormat.cs
index 58c1bf72e..03491cb83 100644
--- a/src/Pickles/Pickles.Test/Formatters/JSON/WhenCreatingAFeatureWithMetaInfoAndTestResultInMstestFormat.cs
+++ b/src/Pickles/Pickles.Test/Formatters/JSON/WhenCreatingAFeatureWithMetaInfoAndTestResultInMstestFormat.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using Autofac;
using NFluent;
@@ -39,16 +40,16 @@ public class WhenCreatingAFeatureWithMetaInfoAndTestResultInMstestFormat : BaseF
{
public string Setup()
{
- const string OutputDirectoryName = FileSystemPrefix + @"JSONFeatureOutput";
- var rootPath = FileSystem.DirectoryInfo.FromDirectoryName(FileSystemPrefix + @"JSON\Features");
+ string OutputDirectoryName =FileSystem.Path.Combine(FileSystemPrefix,"JSONFeatureOutput");
+ var rootPath = FileSystem.DirectoryInfo.FromDirectoryName(FileSystem.Path.Combine(FileSystemPrefix,"JSON","Features"));
- const string TestResultFilePath = FileSystemPrefix + @"JSON\results-example-failing-and-pasing-mstest.trx";
+ var TestResultFilePath = FileSystem.Path.Combine(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",
+ FileSystem.Path.Combine("JSON","Features"),
new[]
{
"OneScenarioTransferingMoneyBetweenAccountsFailing.feature",
diff --git a/src/Pickles/Pickles.Test/Formatters/JSON/WhenFormattingAFolderStructureWithFeatures.cs b/src/Pickles/Pickles.Test/Formatters/JSON/WhenFormattingAFolderStructureWithFeatures.cs
index f244358bc..2791f0b0d 100644
--- a/src/Pickles/Pickles.Test/Formatters/JSON/WhenFormattingAFolderStructureWithFeatures.cs
+++ b/src/Pickles/Pickles.Test/Formatters/JSON/WhenFormattingAFolderStructureWithFeatures.cs
@@ -19,6 +19,7 @@
// --------------------------------------------------------------------------------------------------------------------
using System;
+using System.IO;
using Autofac;
using NUnit.Framework;
using PicklesDoc.Pickles.DataStructures;
@@ -31,8 +32,12 @@ namespace PicklesDoc.Pickles.Test.Formatters.JSON
[TestFixture]
public class WhenFormattingAFolderStructureWithFeatures : BaseFixture
{
- private const string OutputDirectory = FileSystemPrefix + @"JSONFeatureOutput";
+ private string OutputDirectory { get; }
+ public WhenFormattingAFolderStructureWithFeatures()
+ {
+ OutputDirectory =FileSystem.Path.Combine(FileSystemPrefix, "JSONFeatureOutput");
+ }
public void Setup()
{
var rootPath = FileSystem.DirectoryInfo.FromDirectoryName(FileSystemPrefix);
diff --git a/src/Pickles/Pickles.Test/Formatters/TableOfContentsShouldBeCreatedFromAFolderStructure.cs b/src/Pickles/Pickles.Test/Formatters/TableOfContentsShouldBeCreatedFromAFolderStructure.cs
index 5ac264e1e..085b0eb49 100644
--- a/src/Pickles/Pickles.Test/Formatters/TableOfContentsShouldBeCreatedFromAFolderStructure.cs
+++ b/src/Pickles/Pickles.Test/Formatters/TableOfContentsShouldBeCreatedFromAFolderStructure.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Xml.Linq;
@@ -36,9 +37,13 @@ namespace PicklesDoc.Pickles.Test.Formatters
[TestFixture]
public class TableOfContentsShouldBeCreatedFromAFolderStructure : BaseFixture
{
- private const string RootPath = FileSystemPrefix + @"FeatureCrawlerTests";
+ private string RootPath { get; }
private XElement toc;
+ public TableOfContentsShouldBeCreatedFromAFolderStructure()
+ {
+ RootPath =FileSystem.Path.Combine(FileSystemPrefix,"FeatureCrawlerTests");
+ }
public void Setup()
{
var rootPath = FileSystem.DirectoryInfo.FromDirectoryName(RootPath);
diff --git a/src/Pickles/Pickles.Test/Pickles.Test.csproj b/src/Pickles/Pickles.Test/Pickles.Test.csproj
index df28be3a7..f9e2cf6d0 100644
--- a/src/Pickles/Pickles.Test/Pickles.Test.csproj
+++ b/src/Pickles/Pickles.Test/Pickles.Test.csproj
@@ -83,13 +83,14 @@
-
+
-
+
-
+
+
diff --git a/src/Pickles/Pickles.Test/WhenCrawlingFoldersForFeatures.cs b/src/Pickles/Pickles.Test/WhenCrawlingFoldersForFeatures.cs
index 9198aa487..fc3595917 100644
--- a/src/Pickles/Pickles.Test/WhenCrawlingFoldersForFeatures.cs
+++ b/src/Pickles/Pickles.Test/WhenCrawlingFoldersForFeatures.cs
@@ -19,6 +19,7 @@
// --------------------------------------------------------------------------------------------------------------------
using System;
+using System.IO;
using Autofac;
using NFluent;
using NUnit.Framework;
@@ -35,7 +36,7 @@ public void Then_can_crawl_all_folders_including_subfolders_for_features_success
{
this.AddFakeFolderStructures();
- var rootPath = FileSystem.DirectoryInfo.FromDirectoryName(FileSystemPrefix + @"FeatureCrawlerTests");
+ var rootPath = FileSystem.DirectoryInfo.FromDirectoryName(FileSystem.Path.Combine(FileSystemPrefix,"FeatureCrawlerTests"));
Tree features = Container.Resolve().Crawl(rootPath, new ParsingReport());
Check.That(features).IsNotNull();
@@ -67,7 +68,7 @@ public void Then_can_crawl_all_folders_including_subfolders_for_features_success
INode subLevelOneDirectory = features.ChildNodes[4].Data;
Check.That(subLevelOneDirectory).IsNotNull();
Check.That(subLevelOneDirectory.Name).IsEqualTo("Sub Level One");
- Check.That(subLevelOneDirectory.RelativePathFromRoot).IsEqualTo(@"SubLevelOne\");
+ Check.That(subLevelOneDirectory.RelativePathFromRoot).IsEqualTo(@"SubLevelOne"+Path.DirectorySeparatorChar);
Check.That(subLevelOneDirectory).IsInstanceOf();
Tree subLevelOneNode = features.ChildNodes[4];
@@ -76,13 +77,13 @@ public void Then_can_crawl_all_folders_including_subfolders_for_features_success
INode levelOneSublevelOneFeature = subLevelOneNode.ChildNodes[0].Data;
Check.That(levelOneSublevelOneFeature).IsNotNull();
Check.That(levelOneSublevelOneFeature.Name).IsEqualTo("Addition");
- Check.That(levelOneSublevelOneFeature.RelativePathFromRoot).IsEqualTo(@"SubLevelOne\LevelOneSublevelOne.feature");
+ Check.That(levelOneSublevelOneFeature.RelativePathFromRoot).IsEqualTo(FileSystem.Path.Combine("SubLevelOne","LevelOneSublevelOne.feature"));
Check.That(levelOneSublevelOneFeature).IsInstanceOf();
INode levelOneSublevelTwoFeature = subLevelOneNode.ChildNodes[1].Data;
Check.That(levelOneSublevelTwoFeature).IsNotNull();
Check.That(levelOneSublevelTwoFeature.Name).IsEqualTo("Addition");
- Check.That(levelOneSublevelTwoFeature.RelativePathFromRoot).IsEqualTo(@"SubLevelOne\LevelOneSublevelTwo.feature");
+ Check.That(levelOneSublevelTwoFeature.RelativePathFromRoot).IsEqualTo(FileSystem.Path.Combine("SubLevelOne","LevelOneSublevelTwo.feature"));
Check.That(levelOneSublevelTwoFeature).IsInstanceOf();
Tree subLevelTwoNode = subLevelOneNode.ChildNodes[2];
@@ -91,13 +92,13 @@ public void Then_can_crawl_all_folders_including_subfolders_for_features_success
INode subLevelTwoDirectory = subLevelOneNode.ChildNodes[2].Data;
Check.That(subLevelTwoDirectory).IsNotNull();
Check.That(subLevelTwoDirectory.Name).IsEqualTo("Sub Level Two");
- Check.That(subLevelTwoDirectory.RelativePathFromRoot).IsEqualTo(@"SubLevelOne\SubLevelTwo\");
+ Check.That(subLevelTwoDirectory.RelativePathFromRoot).IsEqualTo(FileSystem.Path.Combine("SubLevelOne","SubLevelTwo")+Path.DirectorySeparatorChar);
Check.That(subLevelTwoDirectory).IsInstanceOf();
INode levelOneSublevelOneSubLevelTwoDirectory = subLevelOneNode.ChildNodes[2].ChildNodes[0].Data;
Check.That(levelOneSublevelOneSubLevelTwoDirectory).IsNotNull();
Check.That(levelOneSublevelOneSubLevelTwoDirectory.Name).IsEqualTo("Addition");
- Check.That(levelOneSublevelOneSubLevelTwoDirectory.RelativePathFromRoot).IsEqualTo(@"SubLevelOne\SubLevelTwo\LevelOneSublevelOneSubLevelTwo.feature");
+ Check.That(levelOneSublevelOneSubLevelTwoDirectory.RelativePathFromRoot).IsEqualTo(FileSystem.Path.Combine("SubLevelOne","SubLevelTwo","LevelOneSublevelOneSubLevelTwo.feature"));
Check.That(levelOneSublevelOneSubLevelTwoDirectory).IsInstanceOf();
}
}
diff --git a/src/Pickles/Pickles.Test/WhenWorkingWithHtmlResources.cs b/src/Pickles/Pickles.Test/WhenWorkingWithHtmlResources.cs
index 174e4594f..19b66c424 100644
--- a/src/Pickles/Pickles.Test/WhenWorkingWithHtmlResources.cs
+++ b/src/Pickles/Pickles.Test/WhenWorkingWithHtmlResources.cs
@@ -100,20 +100,20 @@ public void ThenCanDetectAllStylesheetsSuccessfully()
[Test]
public void ThenSavesCssFilesToCorrectLocation()
{
- FileSystem.AddDirectory(@"c:\output\");
+ FileSystem.AddDirectory("output");
var htmlResourceWriter = new HtmlResourceWriter(FileSystem);
- htmlResourceWriter.WriteTo(@"c:\output\");
+ htmlResourceWriter.WriteTo("output");
var filesOnFileSystem = FileSystem.AllFiles.AsEnumerable().ToArray();
- Check.That(filesOnFileSystem).Contains(@"c:\output\css\master.css");
- Check.That(filesOnFileSystem).Contains(@"c:\output\css\reset.css");
- Check.That(filesOnFileSystem).Contains(@"c:\output\css\global.css");
- Check.That(filesOnFileSystem).Contains(@"c:\output\css\global.css");
- Check.That(filesOnFileSystem).Contains(@"c:\output\css\structure.css");
- Check.That(filesOnFileSystem).Contains(@"c:\output\css\print.css");
- Check.That(filesOnFileSystem).Contains(@"c:\output\css\font-awesome.css");
+ Check.That(filesOnFileSystem).Contains(FileSystem.Path.GetFullPath(FileSystem.Path.Combine("output","css","master.css")));
+ Check.That(filesOnFileSystem).Contains(FileSystem.Path.GetFullPath(FileSystem.Path.Combine("output","css","reset.css")));
+ Check.That(filesOnFileSystem).Contains(FileSystem.Path.GetFullPath(FileSystem.Path.Combine("output","css","global.css")));
+ Check.That(filesOnFileSystem).Contains(FileSystem.Path.GetFullPath(FileSystem.Path.Combine("output","css","global.css")));
+ Check.That(filesOnFileSystem).Contains(FileSystem.Path.GetFullPath(FileSystem.Path.Combine("output","css","structure.css")));
+ Check.That(filesOnFileSystem).Contains(FileSystem.Path.GetFullPath(FileSystem.Path.Combine("output","css","print.css")));
+ Check.That(filesOnFileSystem).Contains(FileSystem.Path.GetFullPath(FileSystem.Path.Combine("output","css","font-awesome.css")));
}
}
}
diff --git a/src/Pickles/Pickles.TestFrameworks/CucumberJson/CucumberJsonSingleResultLoader.cs b/src/Pickles/Pickles.TestFrameworks/CucumberJson/CucumberJsonSingleResultLoader.cs
index b91ba9404..9b51f5713 100644
--- a/src/Pickles/Pickles.TestFrameworks/CucumberJson/CucumberJsonSingleResultLoader.cs
+++ b/src/Pickles/Pickles.TestFrameworks/CucumberJson/CucumberJsonSingleResultLoader.cs
@@ -28,12 +28,12 @@ namespace PicklesDoc.Pickles.TestFrameworks.CucumberJson
{
public class CucumberJsonSingleResultLoader : ISingleResultLoader
{
- public SingleTestRunBase Load(FileInfoBase fileInfo)
+ public SingleTestRunBase Load(IFileInfo fileInfo)
{
return new CucumberJsonSingleResults(this.ReadResultsFile(fileInfo));
}
- private List ReadResultsFile(FileInfoBase testResultsFile)
+ private List ReadResultsFile(IFileInfo testResultsFile)
{
List result;
//using (var stream = testResultsFile.OpenRead())
diff --git a/src/Pickles/Pickles.TestFrameworks/ISingleResultLoader.cs b/src/Pickles/Pickles.TestFrameworks/ISingleResultLoader.cs
index 106051444..a3325fb90 100644
--- a/src/Pickles/Pickles.TestFrameworks/ISingleResultLoader.cs
+++ b/src/Pickles/Pickles.TestFrameworks/ISingleResultLoader.cs
@@ -6,6 +6,6 @@ namespace PicklesDoc.Pickles.TestFrameworks
{
public interface ISingleResultLoader
{
- SingleTestRunBase Load(FileInfoBase fileInfo);
+ SingleTestRunBase Load(IFileInfo fileInfo);
}
}
\ No newline at end of file
diff --git a/src/Pickles/Pickles.TestFrameworks/MsTest/MsTestSingleResultLoader.cs b/src/Pickles/Pickles.TestFrameworks/MsTest/MsTestSingleResultLoader.cs
index 50ebe5599..c0ad37002 100644
--- a/src/Pickles/Pickles.TestFrameworks/MsTest/MsTestSingleResultLoader.cs
+++ b/src/Pickles/Pickles.TestFrameworks/MsTest/MsTestSingleResultLoader.cs
@@ -27,7 +27,7 @@ public class MsTestSingleResultLoader : ISingleResultLoader
{
private readonly XDocumentLoader documentLoader = new XDocumentLoader();
- public SingleTestRunBase Load(FileInfoBase fileInfo)
+ public SingleTestRunBase Load(IFileInfo fileInfo)
{
return new MsTestSingleResults(this.documentLoader.Load(fileInfo));
}
diff --git a/src/Pickles/Pickles.TestFrameworks/MultipleTestRunsBase.cs b/src/Pickles/Pickles.TestFrameworks/MultipleTestRunsBase.cs
index 235026d63..aa29085b7 100644
--- a/src/Pickles/Pickles.TestFrameworks/MultipleTestRunsBase.cs
+++ b/src/Pickles/Pickles.TestFrameworks/MultipleTestRunsBase.cs
@@ -84,7 +84,7 @@ protected static TestResult EvaluateTestResults(TestResult[] results)
return results.Merge(true);
}
- protected SingleTestRunBase ConstructSingleTestResult(FileInfoBase fileInfo)
+ protected SingleTestRunBase ConstructSingleTestResult(IFileInfo fileInfo)
{
return this.singleResultLoader.Load(fileInfo);
}
diff --git a/src/Pickles/Pickles.TestFrameworks/NUnit/NUnit2/NUnit2SingleResultLoader.cs b/src/Pickles/Pickles.TestFrameworks/NUnit/NUnit2/NUnit2SingleResultLoader.cs
index 4eae740b3..718a269d0 100644
--- a/src/Pickles/Pickles.TestFrameworks/NUnit/NUnit2/NUnit2SingleResultLoader.cs
+++ b/src/Pickles/Pickles.TestFrameworks/NUnit/NUnit2/NUnit2SingleResultLoader.cs
@@ -27,7 +27,7 @@ public class NUnit2SingleResultLoader : ISingleResultLoader
{
private readonly XDocumentLoader documentLoader = new XDocumentLoader();
- public SingleTestRunBase Load(FileInfoBase fileInfo)
+ public SingleTestRunBase Load(IFileInfo fileInfo)
{
return new NUnit2SingleResults(this.documentLoader.Load(fileInfo));
}
diff --git a/src/Pickles/Pickles.TestFrameworks/NUnit/NUnit3/NUnit3SingleResultLoader.cs b/src/Pickles/Pickles.TestFrameworks/NUnit/NUnit3/NUnit3SingleResultLoader.cs
index 9f2fccd6c..84b1decbb 100644
--- a/src/Pickles/Pickles.TestFrameworks/NUnit/NUnit3/NUnit3SingleResultLoader.cs
+++ b/src/Pickles/Pickles.TestFrameworks/NUnit/NUnit3/NUnit3SingleResultLoader.cs
@@ -29,7 +29,7 @@ public class NUnit3SingleResultLoader : ISingleResultLoader
{
private readonly XDocumentLoader documentLoader = new XDocumentLoader();
- public SingleTestRunBase Load(FileInfoBase fileInfo)
+ public SingleTestRunBase Load(IFileInfo fileInfo)
{
return new NUnit3SingleResult(this.documentLoader.Load(fileInfo));
}
diff --git a/src/Pickles/Pickles.TestFrameworks/SpecRun/SpecRunSingleResultLoader.cs b/src/Pickles/Pickles.TestFrameworks/SpecRun/SpecRunSingleResultLoader.cs
index afc4ef905..295751e55 100644
--- a/src/Pickles/Pickles.TestFrameworks/SpecRun/SpecRunSingleResultLoader.cs
+++ b/src/Pickles/Pickles.TestFrameworks/SpecRun/SpecRunSingleResultLoader.cs
@@ -29,7 +29,7 @@ namespace PicklesDoc.Pickles.TestFrameworks.SpecRun
{
public class SpecRunSingleResultLoader : ISingleResultLoader
{
- public SingleTestRunBase Load(FileInfoBase fileInfo)
+ public SingleTestRunBase Load(IFileInfo fileInfo)
{
var document = this.ReadResultsFile(fileInfo);
var features = this.ToFeatures(document);
@@ -42,7 +42,7 @@ private List ToFeatures(XDocument readResultsFile)
return readResultsFile.Descendants("feature").Select(Factory.ToSpecRunFeature).ToList();
}
- private XDocument ReadResultsFile(FileInfoBase testResultsFile)
+ private XDocument ReadResultsFile(IFileInfo testResultsFile)
{
XDocument document;
//using (var stream = testResultsFile.OpenRead())
diff --git a/src/Pickles/Pickles.TestFrameworks/VsTest/VsTestSingleResultLoader.cs b/src/Pickles/Pickles.TestFrameworks/VsTest/VsTestSingleResultLoader.cs
index 82a29a51d..86acf1d8c 100644
--- a/src/Pickles/Pickles.TestFrameworks/VsTest/VsTestSingleResultLoader.cs
+++ b/src/Pickles/Pickles.TestFrameworks/VsTest/VsTestSingleResultLoader.cs
@@ -27,7 +27,7 @@ public class VsTestSingleResultLoader : ISingleResultLoader
{
private readonly XDocumentLoader documentLoader = new XDocumentLoader();
- public SingleTestRunBase Load(FileInfoBase fileInfo)
+ public SingleTestRunBase Load(IFileInfo fileInfo)
{
return new VsTestSingleResults(this.documentLoader.Load(fileInfo));
}
diff --git a/src/Pickles/Pickles.TestFrameworks/XDocumentLoader.cs b/src/Pickles/Pickles.TestFrameworks/XDocumentLoader.cs
index 0a6472bd6..d09ce0cf5 100644
--- a/src/Pickles/Pickles.TestFrameworks/XDocumentLoader.cs
+++ b/src/Pickles/Pickles.TestFrameworks/XDocumentLoader.cs
@@ -27,7 +27,7 @@ namespace PicklesDoc.Pickles.TestFrameworks
{
public class XDocumentLoader
{
- public XDocument Load(FileInfoBase fileInfo)
+ public XDocument Load(IFileInfo fileInfo)
{
XDocument document;
using (var stream = fileInfo.OpenRead())
diff --git a/src/Pickles/Pickles.TestFrameworks/XUnit/XUnit1/XUnit1SingleResultLoader.cs b/src/Pickles/Pickles.TestFrameworks/XUnit/XUnit1/XUnit1SingleResultLoader.cs
index 0c1191bf4..1ef266730 100644
--- a/src/Pickles/Pickles.TestFrameworks/XUnit/XUnit1/XUnit1SingleResultLoader.cs
+++ b/src/Pickles/Pickles.TestFrameworks/XUnit/XUnit1/XUnit1SingleResultLoader.cs
@@ -27,7 +27,7 @@ public class XUnit1SingleResultLoader : ISingleResultLoader
{
private readonly XDocumentLoader documentLoader = new XDocumentLoader();
- public SingleTestRunBase Load(FileInfoBase fileInfo)
+ public SingleTestRunBase Load(IFileInfo fileInfo)
{
return new XUnit1SingleResult(this.documentLoader.Load(fileInfo));
}
diff --git a/src/Pickles/Pickles.TestFrameworks/XUnit/XUnit2/XUnit2SingleResultLoader.cs b/src/Pickles/Pickles.TestFrameworks/XUnit/XUnit2/XUnit2SingleResultLoader.cs
index a530b5279..a6466be56 100644
--- a/src/Pickles/Pickles.TestFrameworks/XUnit/XUnit2/XUnit2SingleResultLoader.cs
+++ b/src/Pickles/Pickles.TestFrameworks/XUnit/XUnit2/XUnit2SingleResultLoader.cs
@@ -29,7 +29,7 @@ public class XUnit2SingleResultLoader : ISingleResultLoader
{
private readonly XmlDeserializer xmlDeserializer = new XmlDeserializer();
- public SingleTestRunBase Load(FileInfoBase fileInfo)
+ public SingleTestRunBase Load(IFileInfo fileInfo)
{
return new XUnit2SingleResults(this.xmlDeserializer.Load(fileInfo));
}
diff --git a/src/Pickles/Pickles.TestFrameworks/XmlDeserializer.cs b/src/Pickles/Pickles.TestFrameworks/XmlDeserializer.cs
index fc2180bd5..179b837f8 100644
--- a/src/Pickles/Pickles.TestFrameworks/XmlDeserializer.cs
+++ b/src/Pickles/Pickles.TestFrameworks/XmlDeserializer.cs
@@ -32,7 +32,7 @@ namespace PicklesDoc.Pickles.TestFrameworks
public class XmlDeserializer
where TItem : class
{
- public TItem Load(FileInfoBase fileInfo)
+ public TItem Load(IFileInfo fileInfo)
{
TItem document;
diff --git a/src/Pickles/Pickles/Configuration.cs b/src/Pickles/Pickles/Configuration.cs
index 3b1966a88..604137438 100644
--- a/src/Pickles/Pickles/Configuration.cs
+++ b/src/Pickles/Pickles/Configuration.cs
@@ -1,4 +1,4 @@
-// --------------------------------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------------------------------
//
// Copyright 2011 Jeffrey Cameron
// Copyright 2012-present PicklesDoc team and community contributors
@@ -31,7 +31,7 @@ namespace PicklesDoc.Pickles
public class Configuration : IConfiguration
{
private static readonly Logger Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.Name);
- private readonly List testResultsFiles;
+ private readonly List testResultsFiles;
public Configuration()
: this(new LanguageServicesRegistry())
@@ -40,13 +40,13 @@ public Configuration()
public Configuration(ILanguageServicesRegistry languageServicesRegistry)
{
- this.testResultsFiles = new List();
+ this.testResultsFiles = new List();
this.Language = languageServicesRegistry.DefaultLanguage;
}
- public DirectoryInfoBase FeatureFolder { get; set; }
+ public IDirectoryInfo FeatureFolder { get; set; }
- public DirectoryInfoBase OutputFolder { get; set; }
+ public IDirectoryInfo OutputFolder { get; set; }
public DocumentationFormat DocumentationFormat { get; set; }
@@ -59,12 +59,12 @@ public bool HasTestResults
get { return this.TestResultsFiles != null && this.testResultsFiles.Count > 0; }
}
- public FileInfoBase TestResultsFile
+ public IFileInfo TestResultsFile
{
get { return this.testResultsFiles[0]; }
}
- public IEnumerable TestResultsFiles
+ public IEnumerable TestResultsFiles
{
get { return this.testResultsFiles; }
}
@@ -100,15 +100,16 @@ public void DisableComments()
public bool ShouldIncludeExperimentalFeatures { get; private set; }
public void AddTestResultFile(FileInfoBase fileInfoBase)
+ public void AddTestResultFile(IFileInfo IFileInfo)
{
- this.AddTestResultFileIfItExists(fileInfoBase);
+ this.AddTestResultFileIfItExists(IFileInfo);
}
- public void AddTestResultFiles(IEnumerable fileInfoBases)
+ public void AddTestResultFiles(IEnumerable IFileInfos)
{
- foreach (var fileInfoBase in fileInfoBases ?? new FileInfoBase[0])
+ foreach (var IFileInfo in IFileInfos ?? new IFileInfo[0])
{
- this.AddTestResultFileIfItExists(fileInfoBase);
+ this.AddTestResultFileIfItExists(IFileInfo);
}
}
@@ -116,15 +117,15 @@ public void AddTestResultFiles(IEnumerable fileInfoBases)
public string HideTags { get; set; }
- private void AddTestResultFileIfItExists(FileInfoBase fileInfoBase)
+ private void AddTestResultFileIfItExists(IFileInfo IFileInfo)
{
- if (fileInfoBase.Exists)
+ if (IFileInfo.Exists)
{
- this.testResultsFiles.Add(fileInfoBase);
+ this.testResultsFiles.Add(IFileInfo);
}
else
{
- Log.Error("A test result file could not be found, it will be skipped: {0}", fileInfoBase.FullName);
+ Log.Error("A test result file could not be found, it will be skipped: {0}", IFileInfo.FullName);
}
}
}
diff --git a/src/Pickles/Pickles/DirectoryCrawler/DirectoryTreeCrawler.cs b/src/Pickles/Pickles/DirectoryCrawler/DirectoryTreeCrawler.cs
index dda7673c0..a63452c98 100644
--- a/src/Pickles/Pickles/DirectoryCrawler/DirectoryTreeCrawler.cs
+++ b/src/Pickles/Pickles/DirectoryCrawler/DirectoryTreeCrawler.cs
@@ -44,12 +44,12 @@ public DirectoryTreeCrawler(RelevantFileDetector relevantFileDetector, FeatureNo
this.fileSystem = fileSystem;
}
- public Tree Crawl(DirectoryInfoBase directory, ParsingReport parsingReport)
+ public Tree Crawl(IDirectoryInfo directory, ParsingReport parsingReport)
{
return this.Crawl(directory, null, parsingReport);
}
- private Tree Crawl(DirectoryInfoBase directory, INode rootNode, ParsingReport parsingReport)
+ private Tree Crawl(IDirectoryInfo directory, INode rootNode, ParsingReport parsingReport)
{
INode currentNode =
this.featureNodeFactory.Create(rootNode != null ? rootNode.OriginalLocation : null, directory, parsingReport);
@@ -73,11 +73,11 @@ private Tree Crawl(DirectoryInfoBase directory, INode rootNode, ParsingReport pa
return tree;
}
- private bool CollectDirectories(DirectoryInfoBase directory, INode rootNode, Tree tree, ParsingReport parsingReport)
+ private bool CollectDirectories(IDirectoryInfo directory, INode rootNode, Tree tree, ParsingReport parsingReport)
{
List collectedNodes = new List();
- foreach (DirectoryInfoBase subDirectory in directory.GetDirectories().OrderBy(di => di.Name))
+ foreach (IDirectoryInfo subDirectory in directory.GetDirectories().OrderBy(di => di.Name))
{
Tree subTree = this.Crawl(subDirectory, rootNode, parsingReport);
if (subTree != null)
@@ -94,11 +94,11 @@ private bool CollectDirectories(DirectoryInfoBase directory, INode rootNode, Tre
return collectedNodes.Count > 0;
}
- private bool CollectFiles(DirectoryInfoBase directory, INode rootNode, Tree tree, ParsingReport parsingReport)
+ private bool CollectFiles(IDirectoryInfo directory, INode rootNode, Tree tree, ParsingReport parsingReport)
{
List collectedNodes = new List();
- foreach (FileInfoBase file in directory.GetFiles().Where(file => this.relevantFileDetector.IsRelevant(file)))
+ foreach (IFileInfo file in directory.GetFiles().Where(file => this.relevantFileDetector.IsRelevant(file)))
{
INode node = this.featureNodeFactory.Create(rootNode.OriginalLocation, file, parsingReport);
if(node != null)
diff --git a/src/Pickles/Pickles/DirectoryCrawler/FeatureNodeFactory.cs b/src/Pickles/Pickles/DirectoryCrawler/FeatureNodeFactory.cs
index 3da6cea99..bb0ea9a0f 100644
--- a/src/Pickles/Pickles/DirectoryCrawler/FeatureNodeFactory.cs
+++ b/src/Pickles/Pickles/DirectoryCrawler/FeatureNodeFactory.cs
@@ -46,17 +46,17 @@ public FeatureNodeFactory(RelevantFileDetector relevantFileDetector, FileSystemB
this.fileSystem = fileSystem;
}
- public INode Create(FileSystemInfoBase root, FileSystemInfoBase location, ParsingReport report)
+ public INode Create(IFileSystemInfo root, IFileSystemInfo location, ParsingReport report)
{
string relativePathFromRoot = root == null ? @".\" : PathExtensions.MakeRelativePath(root, location, this.fileSystem);
- var directory = location as DirectoryInfoBase;
+ var directory = location as IDirectoryInfo;
if (directory != null)
{
return new FolderNode(directory, relativePathFromRoot);
}
- var file = location as FileInfoBase;
+ var file = location as IFileInfo;
if (file != null)
{
diff --git a/src/Pickles/Pickles/DirectoryCrawler/ImageFileDetector.cs b/src/Pickles/Pickles/DirectoryCrawler/ImageFileDetector.cs
index 76b9b1f5e..33ef51165 100644
--- a/src/Pickles/Pickles/DirectoryCrawler/ImageFileDetector.cs
+++ b/src/Pickles/Pickles/DirectoryCrawler/ImageFileDetector.cs
@@ -32,7 +32,7 @@ public ImageFileDetector()
this.validExtensions = new List { ".PNG", ".JPG", ".BMP", ".GIF" };
}
- public bool IsRelevant(FileInfoBase fileInfo)
+ public bool IsRelevant(IFileInfo fileInfo)
{
if (fileInfo == null)
{
diff --git a/src/Pickles/Pickles/DirectoryCrawler/RelevantFileDetector.cs b/src/Pickles/Pickles/DirectoryCrawler/RelevantFileDetector.cs
index 2d832e69c..ef00c9cd9 100644
--- a/src/Pickles/Pickles/DirectoryCrawler/RelevantFileDetector.cs
+++ b/src/Pickles/Pickles/DirectoryCrawler/RelevantFileDetector.cs
@@ -32,12 +32,12 @@ public RelevantFileDetector()
this.imageFileDetector = new ImageFileDetector();
}
- public bool IsFeatureFile(FileInfoBase file)
+ public bool IsFeatureFile(IFileInfo file)
{
return file.Extension.Equals(".feature", StringComparison.InvariantCultureIgnoreCase);
}
- public bool IsMarkdownFile(FileInfoBase file)
+ public bool IsMarkdownFile(IFileInfo file)
{
if (file.Name.EndsWith("csproj.FileListAbsolute.txt"))
{
@@ -61,12 +61,12 @@ public bool IsMarkdownFile(FileInfoBase file)
return false;
}
- public bool IsRelevant(FileInfoBase file)
+ public bool IsRelevant(IFileInfo file)
{
return this.IsFeatureFile(file) || this.IsMarkdownFile(file) || this.imageFileDetector.IsRelevant(file);
}
- public bool IsImageFile(FileInfoBase file)
+ public bool IsImageFile(IFileInfo file)
{
return this.imageFileDetector.IsRelevant(file);
}
diff --git a/src/Pickles/Pickles/Extensions/FileSystemExtensions.cs b/src/Pickles/Pickles/Extensions/FileSystemExtensions.cs
new file mode 100644
index 000000000..0c6566a86
--- /dev/null
+++ b/src/Pickles/Pickles/Extensions/FileSystemExtensions.cs
@@ -0,0 +1,35 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright 2011 Jeffrey Cameron
+// Copyright 2012-present PicklesDoc team and community contributors
+//
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+using System;
+using System.IO.Abstractions;
+
+namespace PicklesDoc.Pickles.Extensions
+{
+ public static class FileSystemExtensions
+ {
+ public static Uri GetUri(this IFileSystem fileSystem, string path)
+ {
+ if(fileSystem.Directory.Exists(path))
+ return fileSystem.DirectoryInfo.FromDirectoryName(path).FullName.ToFolderUri();
+ return fileSystem.FileInfo.FromFileName(path).FullName.ToFileUri();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Pickles/Pickles/Extensions/PathExtensions.cs b/src/Pickles/Pickles/Extensions/PathExtensions.cs
index ac10a5220..f6e71d534 100644
--- a/src/Pickles/Pickles/Extensions/PathExtensions.cs
+++ b/src/Pickles/Pickles/Extensions/PathExtensions.cs
@@ -1,4 +1,4 @@
-// --------------------------------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------------------------------
//
// Copyright 2011 Jeffrey Cameron
// Copyright 2012-present PicklesDoc team and community contributors
@@ -20,6 +20,7 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.IO.Abstractions;
using System.Linq;
@@ -39,33 +40,17 @@ public static string MakeRelativePath(string from, string to, IFileSystem fileSy
throw new ArgumentNullException("to");
}
- string fromString = AddTrailingSlashToDirectoriesForUriMethods(from, fileSystem);
- string toString = AddTrailingSlashToDirectoriesForUriMethods(to, fileSystem);
-
- var fromUri = new Uri(fromString);
- var toUri = new Uri(toString);
+ var fromUri = fileSystem.GetUri(from);
+ var toUri = fileSystem.GetUri(to);
Uri relativeUri = fromUri.MakeRelativeUri(toUri);
string relativePath = Uri.UnescapeDataString(relativeUri.ToString());
- return relativePath.Replace('/', fileSystem.Path.DirectorySeparatorChar);
+ return relativePath.Replace(Uri.SchemeDelimiter, fileSystem.Path.DirectorySeparatorChar.ToString());
}
- private static string AddTrailingSlashToDirectoriesForUriMethods(string path, IFileSystem fileSystem)
- {
- // Uri class treats paths that end in \ as directories, and without \ as files.
- // So if its a file then we need to append the \ to make the Uri class recognize it as a directory
- path = RemoveEndSlashSoWeDoNotHaveTwoIfThisIsADirectory(path);
-
- return fileSystem.Directory.Exists(path) ? path + @"\" : path;
- }
- private static string RemoveEndSlashSoWeDoNotHaveTwoIfThisIsADirectory(string path)
- {
- return path.TrimEnd('\\');
- }
-
- public static string MakeRelativePath(FileSystemInfoBase from, FileSystemInfoBase to, IFileSystem fileSystem)
+ public static string MakeRelativePath(IFileSystemInfo from, IFileSystemInfo to, IFileSystem fileSystem)
{
if (from == null)
{
@@ -80,21 +65,23 @@ public static string MakeRelativePath(FileSystemInfoBase from, FileSystemInfoBas
return MakeRelativePath(from.FullName, to.FullName, fileSystem);
}
- private static string[] GetAllFilesFromPathAndFileNameWithOptionalWildCards(string fileFullName, IFileSystem fileSystem)
+ private static string[] GetAllFilesFromPathAndFileNameWithOptionalWildCards(string fileFilePath, IFileSystem fileSystem)
{
- var path = fileSystem.Path.GetDirectoryName(fileFullName);
- var wildcardFileName = fileSystem.Path.GetFileName(fileFullName);
+ var path = fileSystem.Path.GetDirectoryName(fileFilePath);
+ var wildcardFileName = fileSystem.Path.GetFileName(fileFilePath);
+ if (string.IsNullOrWhiteSpace(path))
+ path = fileSystem.Directory.GetCurrentDirectory();
// GetFiles returns an array with 1 empty string when wildcard match is not found.
return fileSystem.Directory.GetFiles(path, wildcardFileName).Where(x => !string.IsNullOrEmpty(x)).ToArray();
}
- public static IEnumerable GetAllFilesFromPathAndFileNameWithOptionalSemicolonsAndWildCards(string fileFullName, IFileSystem fileSystem)
+ public static IEnumerable GetAllFilesFromPathAndFileNameWithOptionalSemicolonsAndWildCards(string fileFullName, IFileSystem fileSystem)
{
var files = fileFullName.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
return files.SelectMany(f => GetAllFilesFromPathAndFileNameWithOptionalWildCards(f, fileSystem))
.Distinct()
.Select(f => fileSystem.FileInfo.FromFileName(f));
}
-
+
}
}
diff --git a/src/Pickles/Pickles/Pickles.csproj b/src/Pickles/Pickles/Pickles.csproj
index bf533fe9a..46151d325 100644
--- a/src/Pickles/Pickles/Pickles.csproj
+++ b/src/Pickles/Pickles/Pickles.csproj
@@ -53,10 +53,10 @@
-
+
-
+