Code-Driven Location Simulation

The Windows Phone emulator’s location simulator is useful for testing your app while it is executing within the emulator. To test the geo location features of your app on a physical device or within a unit test requires a different code-driven approach.

This section demonstrates how to abstract the use of the Geolocator class so that it can be replaced by a testable mock class.

On first glance you might think that mocking the SDK’s geo location API should be a simple affair. Many of the classes in the API are, however, sealed—including the Geolocator class. This makes mocking them awkward because they must be wrapped or accessed via custom proxy classes.

The Geolocator class implements an internal IGeolocator ...

Get Windows® Phone 8 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.