Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a program that compares two files to see if they are changed. One file is in the form of a FileInfo and the other is a custom struct.

The problem is that I can't fake FileInfo, the only solution I can come up with is converting the FileInfo to something other (the struct I made). But this introduces more complexity that i potentially want to test as well, leading back to the original problem: I can't fake FileInfo. And what if I want to test something using other built in classes, should I convert everything that can't be faked to my own equivalents?

I feel like I'm missing something obvious here (other than test driven development)
Posted
Comments
Sergey Alexandrovich Kryukov 7-Jul-15 11:43am    
First of all, it's all quite unclear, but the question is: if you convert something to you "own equivalents", untested, what would your testing really test? All you are talking about is just files. Why not testing everything together in native forms of things?
—SA
virusstorm 7-Jul-15 11:59am    
I'm assuming you want to perform a unit test and need to be able to simulate a FileInfo class. To do this, you need use a mocking framework. I personally like to use Moq (available on NuGet). Take a look at this thread:

http://stackoverflow.com/questions/10177363/mock-concrete-fileinfo-object

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900