Skip to content

Commit c67f492

Browse files
committed
Added CurrentDirectory extension
1 parent 7b1beb2 commit c67f492

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace System.IO.Abstractions.Extensions
2+
{
3+
public static class IFileSystemExtensions
4+
{
5+
/// <summary>
6+
/// Get the current directory for the specified <paramref name="fileSystem"/>
7+
/// </summary>
8+
/// <param name="fileSystem">FileSystem in use</param>
9+
/// <returns>An <see cref="IDirectoryInfo"/> for the current directory</returns>
10+
public static IDirectoryInfo CurrentDirectory(this FileSystem fileSystem)
11+
{
12+
return fileSystem.DirectoryInfo.FromDirectoryName(fileSystem.Directory.GetCurrentDirectory());
13+
}
14+
}
15+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using NUnit.Framework;
2+
3+
namespace System.IO.Abstractions.Extensions.Tests
4+
{
5+
[TestFixture]
6+
public class FileSystemExtensionsTests
7+
{
8+
[Test]
9+
public void CurrentDirectoryTest()
10+
{
11+
var fs = new FileSystem();
12+
var fullName = fs.CurrentDirectory().FullName;
13+
14+
Assert.IsFalse(String.IsNullOrWhiteSpace(fullName));
15+
Assert.AreEqual(Environment.CurrentDirectory, fullName);
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)