Azure, Coding, How to

Integration testing azure storage – Fluent syntax


[Update 03/21: Azureite local emulator is a good one to look at in this space too. More details here.]

I recently set about writing a solution that’s heavily reliant on Azure Blob storage. I found my debugging cycle wasn’t nice, I’d spin up the code then spend ages in Azure Storage Explorer to work out what had happened. I also new I’d want some integration tests for the future.

So I did some research set about writing a quick set of helpers to allow me to write clean, quick and simple tests that worked in VS Test explorer.

The result is FluentAzureBlobTesting, this allows me to write lovely declarative statements like this:

                .AssertBlobContainsMetaData(expectedMetaDataKey, expectedMetaDataValue)
It also handles the starting, stopping and clearing of the storage emulator so all you have to do is click “Run All” and it handles the rest. *Dependency on Azure 2.3 SDK
        private static CloudStorageAccount account;
        private static CloudBlobClient blobClient;

        public static void StartAndCleanStorage(TestContext cont)
            account = CloudStorageAccount.DevelopmentStorageAccount;
            blobClient = account.CreateCloudBlobClient();

        public static void ShutdownStorage()

        public void CleanAndRestartStorage()
Should the test fail the extensions report back the reason for failures and log trace output on success.
FailedTest PassingTestWithTrace
Now my debugging cycle is nice a quick and I’m writing a good set of unit tests as I go.
The source is available on github here, hopefully useful to you!
Thanks to Rory for the starting point here:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s