If you are working with .Net and you need to read/write files you may be familiar with the System.IO.File class which provides many methods to manipulate files. But there is an issue with that class: its methods are static and because of that you won’t be able to mock it*.
After dealing with this situation for several years and using always a very similar strategy, I finally decided to create a reusable component to encapsulate the System.IO.File class.
The component I created is called System.IO.Utilities, its code is available on Github and it is also published on NuGet, ready for you to use it. At this moment it just provides an interface with one implementation that wraps the System.IO.File class.
Here you can see how to use it.
Contributions are welcome 😉
(*to be more precise: you won’t be able to mock that class with proxy-based mocking tool like Moq, but you can still mock it with «lower-level» tool like TypeMock)