Query to Azure Storage Emulator works in the App on an Android Simulator, but does not work in the unit tests


I have a Xamarin Forms app that queries an Azure Storage Emulator Table.

The query works fine in the application on the Android Emulator. The query returns a List with the requested properties.

I've written an XUnit unit test to run the same query on the same Azure Storage Emulator, but the query in the XUnit unit test fails.

I've set a breakpoint in the method to examine the query result when debugging the unit test.

When I drill down into the IQueryable result, the IEnumerable, I get the following error: The function evaluation requires all threads to run. Unable to evaluate the expression. Operation not supported. Unknown error: 0x80070057.

The code snippet for the data access in the application is below, along with the code for the XUnit test. I had to use a Storage URL proxy for the Android Emulator.

public class AzureCardsDataAccess : ICardsDataAccess
    public List<Card> GetCardsImages(string connectionString, string Parameters)
        CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);

        CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

        var table = tableClient.GetTableReference("cardimages");

        IQueryable<CardEntity> result;

        if (Parameters == null)
            result = table.CreateQuery<CardEntity>();
            result = table.CreateQuery<CardEntity>().Where(x => x.PartitionKey == Parameters);

        List<Card> _cards = new List<Card>();

        foreach (CardEntity e in result)
            _cards.Add(new Card(e.PartitionKey, e.ImageURI));

        return _cards;

Application code:

    public void OnNavigatedTo(INavigationParameters parameters)
        Recipient = parameters.GetValue<Contact>("SelectedContact");
        List<Card> cards = new AzureCardsDataAccess().GetCardsImages(@"UseDevelopmentStorage=true;DevelopmentStorageProxyUri=", null);

Unit Test code:

    public void GetCardsImagesCreatesReturnsAListofCards()

        var actual = new AzureCardsDataAccess().GetCardsImages(@"UseDevelopmentStorage=true;", null);


The implementation works, but the test doesn't.

asked on Stack Overflow May 11, 2020 by Newbee

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0