Thursday, March 10, 2011

Windows Phone 7 Testing a Date Change in the Emulator

imageI wrote a WP7 application that stores a bit of data based on today’s date. Tomorrow when the date changes, yesterday’s data gets cleared out to start fresh. Before submitting the app to the App Hub I needed to test whether it would work as expected when the date changes. At the time, I didn’t have an actual Windows Phone 7 for testing so I used the Emulator. The testing process didn’t work out quite as I expected.

Happy Path

  1. Load Emulator
  2. Deploy app to the emulator
  3. Run app
  4. Click some buttons that store today’s data
  5. Change the date on the development box (assuming that is where the emulator gets its current date)
  6. Click the windows key to unload the app
  7. Return to app (which should have a different date since I changed the date on the development box)
  8. The app data should be empty because it is a new day

Fail

There were a few misconception to the above.

  • It appears that the emulator loads today’s date when the emulator starts up, because it didn’t change when I changed the date in my development environment.
  • When you click the back button it unloads the application and you lose the data stored in Isolated Storage.

Fix

imageReplace steps 5 & 6 in the above “Happy Path” with the following steps to effectively test the date change:

  1. Click to the System Settings page in the Emulator
  2. Click “date & time”
  3. Toggle the “set automatically” slider to Off
  4. Click on the date in the date field
  5. Change the date to a different day
  6. Click the windows key and left arrow icon image to see the app in the menu.

No comments: