Reputation: 3
I'm running some unit-tests, and I need to know how my program is going to respond without internet-connection. Is there a way to make Visual Studio belive, that there is no internet-connection? Fx. by using fakes, shims, mocks etc? I know, that I can just shut down the internet manually, but I would like to do it, by using code.
Any input would be gratefully appreciated! =)
Thanks!
Upvotes: 0
Views: 1464
Reputation: 18569
Instead of using the real code with an internet call, use an interface and inject that into the calling code.
You can use a framework like moq to simulate the internet call and test just the logic in the calling code.
Upvotes: 3