public void AddMetadataToItem(string storageItemName) { var metadata = new Dictionary<string, string> {{"Test", "test"}, {"Test2", "test2"}}; var setStorageItemMetaInformation = new SetStorageItemMetaInformation(storageUrl, containerName, storageItemName, metadata); var postStorageItemResponse = new GenerateRequestByType().Submit(setStorageItemMetaInformation, authToken); Assert.That(postStorageItemResponse.Status, Is.EqualTo(HttpStatusCode.Accepted)); Assert.That(Regex.Match(postStorageItemResponse.Headers["Content-Type"], "text/(plain|html)").Success, Is.True); var contentLength = postStorageItemResponse.Headers["Content-Length"]; Assert.That(contentLength == "58" || contentLength == "0", Is.True); }
public void Should_return_404_not_found_when_requested_object_does_not_exist() { using (new TestHelper(authToken, storageUrl)) { try { Dictionary<string, string> metadata = new Dictionary<string, string>(); SetStorageItemMetaInformation setStorageItemMetaInformation = new SetStorageItemMetaInformation(storageUrl, Constants.CONTAINER_NAME, Guid.NewGuid().ToString(), metadata); new GenerateRequestByType().Submit(setStorageItemMetaInformation, authToken); } catch (Exception ex) { Assert.That(ex, Is.TypeOf(typeof (WebException))); } } }
public void Should_return_accepted_when_meta_information_is_supplied() { using (TestHelper testHelper = new TestHelper(authToken, storageUrl)) { testHelper.PutItemInContainer(); Dictionary<string, string> metadata = new Dictionary<string, string>(); metadata.Add("Test", "test"); metadata.Add("Test2", "test2"); SetStorageItemMetaInformation setStorageItemMetaInformation = new SetStorageItemMetaInformation(storageUrl, Constants.CONTAINER_NAME, Constants.StorageItemName, metadata); var metaInformationResponse = new GenerateRequestByType().Submit(setStorageItemMetaInformation, authToken); Assert.That(metaInformationResponse.Status, Is.EqualTo(HttpStatusCode.Accepted)); testHelper.DeleteItemFromContainer(); } }
private void setStorageItemMetaInformation(string containerName, string storageItemName, Dictionary<string, string> metadata) { var setStorageItemInformation = new SetStorageItemMetaInformation(StorageUrl, containerName, storageItemName, metadata); _requestfactory.Submit(setStorageItemInformation, AuthToken, _usercreds.ProxyCredentials); }
public void Should_throw_exception_when_meta_key_exceeds_128_characters() { using (new TestHelper(authToken, storageUrl)) { try { Dictionary<string, string> metadata = new Dictionary<string, string> {{new string('a', 129), "test"}}; SetStorageItemMetaInformation setStorageItemMetaInformation = new SetStorageItemMetaInformation(storageUrl, Constants.CONTAINER_NAME, Guid.NewGuid().ToString(), metadata); new GenerateRequestByType().Submit(setStorageItemMetaInformation, authToken); } catch (Exception ex) { Assert.That(ex, Is.TypeOf(typeof (MetaKeyLengthException))); } } }
public void setup() { var metadata = new Dictionary<string, string>{{"key1", "value1"},{"key2", "value2"}}; setStorageItemInformation = new SetStorageItemMetaInformation("http://storageurl", "containername", "storageitemname", metadata); }