I have a method that I want unittest in which there are file system calls, and I am wondering how to do this. I looked at unit test code with a file system dependency , but it does not answer my question.
The method I'm 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 the file, because I am removing the Process method and not the Transform (..) method, and therefore the output.txt file does not exist. Therefore, the if check is not performed.
How should I do it right? Should I create some kind of wrapper around io-method files that I would also mock?
source share