.NET How to kill localhost connection programmatically for some testing
I have some event that are triggered in my application when there are some connection problems (communicating with server), this feature should provide retry mechanism for my requests. Now I want to test this. It wou开发者_JAVA技巧ld be best solution if there were some C# library in which I can turn on and off my localhost connection at specific port. Is there a way to do this in .NET?
EDIT: I'm communicating with jetty server which is manually started at 8080 port.
this might not be the answer you want, but I try anyhow. If you want to (Unit-)Test things like networkconnection you should seperate the concerns and make the network-traffic it's own (or many) interfaces. This way you can easily mock every behavior you want. It will be quicker, cleaner and better design this way.
To answer your direct question: I don't think that you can do this in .NET. But here is a similar question.
精彩评论