Testing connectivity issues in Windows Phone 7 (us

2020-04-03 02:29发布

问题:

Is there a way in the Windows Phone 7 emulator to turn off the network connection (without yanking the cable and turning wi-fi off on my laptop)? I want to test the dropping of network connectivity without having a physical device or doing anything physical outside the emulator or the Windows Phone 7 SDK/Tools.

回答1:

As an alternative to physically disabling the network connection I also, sometimes, find it useful to redirect the network connections through Fiddler2. It's then possible to use breakpoints to intercept some connections. You can then use this add a delay before the server can respond. Or you can force a timeout.
I find this a useful approach when you want to test some connections failing but not others.



回答2:

No, not really. I find it useful to check network connectivity and assign the result to a boolean value so that I can then modify the result to test scenarios where there's no network connection.



回答3:

Сreate a firewall rule for the application C:\Program Files\Microsoft XDE\1.0\XDE.exe and then enable/disable this rule.



回答4:

You can do this using a custom rule in Fiddler.

Rules -> Customize Rules...

Find the code which adds the "Simulate &Modem Speeds" menu option, and add your new option

//Add a menu option under Rules -> Performance
public static RulesOption("Simulate Flight Mode", "Per&formance")
var bFlightMode: boolean = false;   

Now, at the top of the OnBeforeRequest function, add the following code

// Cause Fiddler to respond to all requests with a 502 (Bad Gateway) - the same error you get when you remove all networks
if (bFlightMode){
    oSession.oRequest.pipeClient.End();
    oSession.utilCreateResponseAndBypassServer();
    oSession.oResponse.headers.HTTPResponseCode = 502;
    oSession.oResponse.headers.HTTPResponseStatus = "Fiddler Simulating Flight Mode";
    oSession.state = SessionStates.Aborted;
    return;
}   

Now, under the 'Performance' menu, you can select 'Flight Mode' - or whatever you want to call it.

(Based on an @EricLaw Google Groups post)