Skip to content

WickedFlame/Abstract.FileSystem

Repository files navigation

Abstract.FileSystem

Abstraction for the .Net Filesystem classes

Build status Build status

Wrappers for some common classes from System.IO Namespace to create a layer of abstraction

Current abstractions of System.IO

  • Directory
  • File
  • Path

Usage in code

Instead of using the Namespace System.IO include the Namespace Abstract.FileSystem to use Directory or File.

Usage in Tests

Abstract.FileSystem.Directory and Abstract.FileSystem.File both have a Factory Property. This can be set through the static method Setup(Func<IFileService> service) or Setup(Func<IDirectoryService> service). The Interface IFileService and IDirectoryService both provide the abstraction layers.

_service = new Mock<IDirectoryService>();
Directory.Setup(() => _service.Object);

Now all Access to Abstract.FileSystem.Directory use the Mock of IDirectoryServerice

SystemPath

Path behaviour on Linux differs from Windows. For this reason there is a class for SystemPath that manages paths depending on the system that is run on.

var path = (SystemPath)"Test" / "Path";
path.ToString();

On a Windows this results in

Test\Path

while on a Unix system the result looks different

Test/Path

About

Abstraction for the .Net Filesystem classes

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages