C# In-Memory File System

Unit testing code that reads or writes to the filesystem can be difficult. One thing that can help is an in-memory file system that lets you emulate the actual file system just for testing purposes.

This morning I stumbled across a blog post by Jason Roberts, a five time Microsoft MVP, freelance developer, writer, and Pluralsight course author, where he describes how to use System.IO.Abstractions and System.IO.Abstractions.TestingHelpers (available through Nuget) to set up an in-memory file system that you can use when you want to unit test your file system dependent classes.

Check out his blog at http://dontcodetired.com/blog/post/Unit-Testing-C-File-Access-Code-with-SystemIOAbstractions

Rulla till toppen