public void should_remove_all_slashes_when_creating_uri_and_storage_item_has_forward_slashes_at_the_beginning() { var memstream = new MemoryStream(); PutStorageItem item = new PutStorageItem("http://storeme", "itemcont", "/stuffhacks.txt", memstream); Uri url = item.CreateUri(); url.EndsWith("stuffhacks.txt"); }
public void Should_return_created_when_content_length_is_not_supplied_because_it_is_optional() { using (var testHelper = new TestHelper(authToken, storageUrl)) { var putStorageItem = new PutStorageItem(storageUrl, Constants.CONTAINER_NAME, Constants.StorageItemName, Constants.StorageItemName); var uri = putStorageItem.CreateUri(); var request = new CloudFilesRequest(uri); putStorageItem.Apply(request); // request.ContentLength = 0; request.Headers.Add("X-Auth-Token", HttpUtility.UrlEncode(authToken)); var response= request.GetResponse(); Assert.That(response.Status, Is.EqualTo(HttpStatusCode.Created)); Assert.That(response.Headers[Constants.ETAG], Is.EqualTo(request.ETag)); testHelper.DeleteItemFromContainer(); } }
public void Should_throw_a_WebException_with_status_code_422_when_the_ETag_passed_does_not_match_MD5_of_the_file() { using (new TestHelper(authToken, storageUrl)) { var putStorageItem = new PutStorageItem(storageUrl, Constants.CONTAINER_NAME, Constants.StorageItemName, Constants.StorageItemName); try { var uri = putStorageItem.CreateUri(); var response = new CloudFilesRequest(uri); putStorageItem.Apply(response); response.Headers.Remove("ETag"); response.Headers.Add("ETag", new string('A', 32)); response.Headers.Add("X-Auth-Token", HttpUtility.UrlEncode(authToken)); response.GetResponse(); // new GenerateRequestByType().Submit(putStorageItem, authToken); } catch (Exception ex) { Assert.That(ex, Is.TypeOf(typeof (WebException))); } } }