开发者

Testing network unavailability on Windows Phone 7

开发者 https://www.devze.com 2023-02-11 19:48 出处:网络
I developing an 开发者_如何学编程app which connects to my webserver.During development I have the webserver and phone emulator on the same machine.

I developing an 开发者_如何学编程app which connects to my webserver. During development I have the webserver and phone emulator on the same machine.

How can I test how my app behaves when there's no network connectivity? Are there test hooks on the emulator? Should I use Fiddler to fake timeouts? I don't see any test hooks on the GetIsNetworkAvailable() call...

Thanks,


The approach I've used is to wrap the appropriate methods in my own NetworkService class, this lets me switch out the code with a Stub version during unit tests and integration tests on the emulator.


The NetworkInterface.NetworkInterfaceType offers a enumeration that contains the network currently servicing internet requests. It will return 'none' if there isn't a internet connection available. (unfortunately it doesn't provide health information on the nature of the connection available, so if you have poor coverage it will still return MobileBroadbandGSM)

You can find the full information on the NetworkInterfaceType enumeration here

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号