Writing unit test cases that target Azure Dev Fabric

We are currently building an application that writes to Azure blob-storage as part of its business process.  As I was writing test cases for it, my Blob-storage operations were failing because that code is now running under the context of the test case instead of my web role.  So I needed a way to make sure that:

  1. DevFabric is running when my test cases start
  2. The DataConnectionString string is setup to hit DevFabric (I don’t really want to hit the “real” cloud for these test cases)

So I added a method marked with the “AssemblyInitialize” attribute in my Unit test project.  In that method, I check to see if DevFabric has started, if it is not started, i kick it off and wait for it to run.  Once that is going, I need to get the Data Connection String from my test project’s app.config file.  And now, when the code to access Blob storage gets called, it will have all the information it needs in order to successfully complete the operation. 

I have a lot of test cases that hit Azure, so that’s why I used AssemblyInitialize…this code could’ve been placed inside one test case or in a “ClassInitialize” method.

        public static void AzureInitialize(TestContext testContext)
            if( System.Diagnostics.Process.GetProcessesByName("DSService").Length == 0)
                System.Diagnostics.ProcessStartInfo start = new System.Diagnostics.ProcessStartInfo();
                start.Arguments = "/devstore:start";
                start.FileName = @"C:\Program Files\Windows Azure SDK\v1.2\bin\csrun.exe";
                var proc = new System.Diagnostics.Process();
                proc.StartInfo = start;
            CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) => configSetter(ConfigurationManager.AppSettings[configName]));
            var azureAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

This is what I added in app.config:

    "DataConnectionString" value="UseDevelopmentStorage=true" />

13 thoughts on “Writing unit test cases that target Azure Dev Fabric

  1. andy

    I always enjoy learning how other people employ Microsoft Azure. I am wondering if you can check out my very own tool CloudBerry Explorer that helps manage Azure Blob Storage . It is a freeware.

  2. Kathie Granger


    Thank you for the fast delivery to my place.
    When I received the product. I immediately saw that something was wrong with it, and when I opened it, the product was unfortunately damaged.
    I made a photo so that you can see what I mean. https://imgurpicture.com/uplode

    I am a regular customer, and I order a lot from your webshop.
    Hope we can solve this small problem in a good way.

    Kathie Granger

    “Sent from my AndroidPhone

  3. Manual Thurgood

    Give your new site a boost, submit your site now to our free directory and start getting more clients https://bit.ly/add-your-website

  4. Roland Imler

    Give your new site a boost, submit your site now to our free directory and start getting more clients https://1mdr.short.gy/submityoursite

  5. Gwen Mussen

    Give your new site a boost, submit your site now to our free directory and start getting more clients https://bit.ly/submityoursite1000

  6. Filomena Audet

    Good job on the new site! Now go ahead and submit it to our free directory here https://bit.ly/submit-your-site-now

  7. Thurman Durden

    Add your site to 1000 business directories with one click here-> https://1mdr.short.gy/submit-your-site

  8. Kai Ritter

    You can submit your site to over 1000 different business/advertising directories for free with one click https://1mdr.short.gy/submit-your-site

  9. Steffen Stanton

    Free submission of your new website to over 1000 business directories here https://1mdr.short.gy/submit-your-site

  10. Francisca Mcclung

    Congrats on your new site, get it listed here for free and we’ll start sending people to your site https://bit.ly/addyoursitehere

  11. April Oberg

    I was wondering if you wanted to submit your new site to our free business directory? https://bit.ly/addyoursitehere

  12. Ingeborg Suffolk

    Submit your site to our 30 directories all with one click here> https://bit.ly/addyoursitehere

  13. Carmella Brewis

    Add your site to all 35 of our business directories with one click here-> https://bit.ly/addyoursitehere

Leave a Reply

Your email address will not be published. Required fields are marked *