Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mock File IO static class in c#

I am new to Unit Testing, and I need to mock the File static class in System.IO namespace. I am using Rhinomock, what is the best way to accomplish this,

Lets say I need to mock the File.Exists,File.Delete ...

like image 756
David MZ Avatar asked Jun 27 '11 22:06

David MZ


1 Answers

You can't mock static methods with Rhino mock. See this question for more info. You could create a facade class to wrap the file system calls you will use and then create a mock version of that.

like image 165
Don Kirkby Avatar answered Sep 19 '22 10:09

Don Kirkby