How to simulate network failure for test purposes (in C#)?

前端 未结 11 783
被撕碎了的回忆
被撕碎了的回忆 2020-12-29 04:25

I\'m building what could be called the DAL for a new app. Unfortunately, network connectivity to the database is a real problem.

I\'d like to be able to temporarily

11条回答
  •  温柔的废话
    2020-12-29 05:29

    Depends on what particular network problem you wish to simulate. For most folks, it's as simple as "server unreachable", in which case you'd just try to connect to a non existent server. Be careful, though, because you want something that is routable but does not answer. Trying to connect to dkjdsjk.com will fail immediately (DNS lookup), but trying to connect to www.google.com:1433 will (probably) time out due to a firewall - which is how your app will behave when your DB server is down.

提交回复
热议问题