8

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.

Ryan Hayes
  • 5,290
  • 4
  • 42
  • 52

4 Answers4

6

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.

Matt Lacey
  • 65,560
  • 11
  • 91
  • 143
3

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.

Derek Lakin
  • 16,179
  • 36
  • 51
1

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

Florent
  • 12,310
  • 10
  • 49
  • 58
ITmindCo
  • 73
  • 6
1

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)

Greg Woods
  • 2,697
  • 2
  • 26
  • 18