I have a method I want to unittest that has filesystem calls in it and am wondering how to go about it. I have looked at http://stackoverflow.com/questions/129036/unit-testing-code-with-a-file-system-dependency but it does not answer my question.
The method I am testing looks something like this (c#)
public void Process(string input)
{
string outputFile = "output.txt";
this.Transform(input, Resources.XsltFile, outputFile);
if ((new FileInfo(outputFile)).Length == 0)
{
File.Delete(outputFile);
}
}
I am mocking the Transform(..) method to not output anything to a file as I am unittesting the Process method and not the Transform(..) method and therefore no output.txt file exists. Therefore the if check fails.
How should I do this properly? Should I create some sort of wrapper around the file io methods that i would mock out as well?