public async Task UploadBlob_UrlReturnedFromBroker_IsUsedToUploadToStorage()
        {
            var mobileServiceHandler = new TestHttpHandler(HttpStatusCode.OK);
            var sasToken             = "http://the.sas.token.com/url?query=string";
            var sasTokenNoQuery      = "http://the.sas.token.com/url";

            mobileServiceHandler.SetResponse("{\"uri\":\"" + sasToken + "\"}", "application/json");
            var client = new MobileServiceClient(
                AppUrl,
                AppKey,
                mobileServiceHandler);

            var storageHandler = new TestHttpHandler(HttpStatusCode.Created);

            ResourceBrokerStorageClient.HttpClientCreator = () => new HttpClient(storageHandler);

            var ms  = GetBlobContent();
            var url = await client.UploadFileToBlobStorage("container", "file", "text/plain", ms);

            Assert.AreEqual(AppUrl + "api/resources/blob", mobileServiceHandler.RequestUrl);
            Assert.AreEqual(sasTokenNoQuery, url.ToString());
            Assert.AreEqual(sasToken, storageHandler.RequestUrl);
            Assert.AreEqual(testBlobContent, storageHandler.RequestContent);
        }
        public async Task UploadBlob_BrokerReturnsInvalidResponse_ExpectedExceptionIsCaught()
        {
            var mobileServiceHandler = new TestHttpHandler(HttpStatusCode.OK);

            mobileServiceHandler.SetResponse("{\"other\":\"value\"}", "application/json");
            var client = new MobileServiceClient(
                AppUrl,
                AppKey,
                mobileServiceHandler);

            var storageHandler = new TestHttpHandler(HttpStatusCode.Created);

            ResourceBrokerStorageClient.HttpClientCreator = () => new HttpClient(storageHandler);

            var ms = GetBlobContent();

            try
            {
                var url = await client.UploadFileToBlobStorage("container", "file", "text/plain", ms);

                Assert.Fail("Upload call should have thrown an exception");
            }
            catch (InvalidOperationException) { }
        }