File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
src/System.IO.Abstractions.Extensions
tests/System.IO.Abstractions.Extensions.Tests Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments