Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9134043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:35:31+00:00 2026-06-17T08:35:31+00:00

I have this unit test in a Windows Store unit test project, using this

  • 0

I have this unit test in a Windows Store unit test project, using this overload of GetGeopositionAsync of the Geolocator:

[TestMethod]
public async Task TestFunc()
{
  var locator = new Windows.Devices.Geolocation.Geolocator();

  var l = await 
          locator.GetGeopositionAsync(TimeSpan.MaxValue, TimeSpan.FromSeconds(10));

  Assert.IsNotNull(l);
}

But not only does this test not pass, nor bunk out after 10 seconds – it never finishes (I waited for 10 minutes before killing it).

I should stress that this is a paired-down version of the test I actually wanted to run – I’m not trying to just unit-test Windows; equally as has been pointed out in John Deters’ answer I could use a fake instead.

I’ve also written another test that subscribed to a GeoLocator‘s StatusChanged and PositionChanged events (the latter should initialise the locator), and then waited for one minute. In the StatusChanged handler I trace out the current LocationStatus, in addition to tracing it out as soon as I’ve created the Geolocator.

The LocationStatus of the Geolocator in this test starts at NotInitialised, and never changes.

Now I’m thinking that this is a blocking issue to do with the fact that (quoting from the GetGeopositionAsync documentation in the link at the start):

The first use of the Geolocator object to call GetGeopositionAsync must be made on the UI thread so that the consent prompt can be shown to the user. For more information, see Guidelines for devices that access personal data.

So my guess is either:

  • a) The call is being made on a UI thread (unlikely) but because there’s no UI surface (apart from the strange black screen that occasionally appears when debugging a windows store unit test), the UI can’t be displayed and so the call never completes.
  • b) The call is not being made on the UI thread and because of that no UI can be shown, and so the call never completes.

Either way, I’m coming to the conclusion that it’s impossible to use Geolocator in a Windows Store unit test because it’s impossible for me to supply consent to my own unit test to access location services! Equally I’m dismayed that such a core component would allow itself to run indefinitely just because UI can’t be shown – that’s just poor.

Anyone had to face this? It really would be kinda good to be able to unit-test code that uses Geo-location!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:35:31+00:00Added an answer on June 17, 2026 at 8:35 am

    Here’s what I’ve discovered.

    On my desktop (behind a corporate proxy) the Geolocator never completes initialisation. As a result, no app can use my current location for anything – it’s not just limited to unit tests.

    As soon as I run the code in the simulator, however, it all works fine.

    I believe this is ultimately linked to the fact that my desktop has no location provider installed – since it doesn’t have a GPS receiver. What I find absolutely incredible is that there’s no fallback location provider for devices to use network location or, if there is, that it doesn’t work behind a corporate proxy.

    Either way, as it stands, it’s not possible to test/debug any code on my desktop (in a unit test or within the app itself) that requires location from the Geolocator class. Oh, apart from testing my handling for the situation where it never returns!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Unit test project for my Application using DUnit framework. This project
I have this code that works in a unit test but doesn't work when
I have a unit test that tests if an Exception is throw, but this
Following on from this question...I'm trying to unit test the following scenario: I have
I have troubles setting up unit test framework for windows phone sdk 7.1 there
I am new to MVC and Unit Test. I am using Visual Studio unit
I'm using Netbeans 7.0.1 in a PHP project. I've installed XAMPP 1.7 in Windows
I have a class called FooJob() which runs on a WCF windows service. This
I have a network C++ program in Windows that I'd like to test for
I have two strings that I am comparing in a unit test. When I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.