I would create three types:
An interface containing all the methods you want to test, etc., for example
public interface IFileSystem { Stream OpenWrite(string filename); TextReader OpenText(string filename);
The implementation that delegates the implementation of the system:
public class FrameworkFileSystem : IFileSystem { public Stream OpenWrite(string filename) { return File.OpenWrite(filename); }
Fake implementation for testing:
public class FakeFileSystem : IFileSystem {
You may not want to insert everything from File there, because many of the operations can be made up of "core" ones. Of course, this will mean re-executing operations, which may be undesirable ...
Jon skeet
source share