I've written adapters for the static System.IO.File
and Directory
methods. Then in my classes I do the following:
public class MyService {
public IFile File {private get;set;}
public MyService() {
File = new FileImpl();
}
public void DoSomething() {
File.ReadAllText("somefile");
}
}
Then you can inject a mock as IFile for testing.