public void Should_get_404_when_item_does_not_existt() { using (new TestHelper(authToken, storageUrl)) { var getStorageItemInformation = new GetStorageItemInformation(storageUrl, Constants.CONTAINER_NAME, Constants.StorageItemName); try { new GenerateRequestByType().Submit(getStorageItemInformation, authToken); } catch (Exception ex) { Assert.That(ex, Is.TypeOf(typeof (WebException))); } } }
public void Should_get_404_when_item_does_not_existt() { using (new TestHelper(authToken, storageUrl)) { var getStorageItemInformation = new GetStorageItemInformation(storageUrl, authToken, Constants.CONTAINER_NAME, Constants.StorageItemName); try { new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(getStorageItemInformation)); } catch (Exception ex) { Assert.That(ex, Is.TypeOf(typeof (WebException))); } } }
public void Should_get_204_No_Content_when_item_exists() { using (TestHelper testHelper = new TestHelper(authToken, storageUrl)) { try { testHelper.PutItemInContainer(Constants.HeadStorageItemName); testHelper.AddMetadataToItem(Constants.HeadStorageItemName); var getStorageItemInformation = new GetStorageItemInformation(storageUrl, authToken, Constants.CONTAINER_NAME, Constants.HeadStorageItemName); var getStorageItemInformationResponse = new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(getStorageItemInformation)); Assert.That(getStorageItemInformationResponse.Status, Is.EqualTo(HttpStatusCode.NoContent)); var metadata = getStorageItemInformationResponse.Metadata; Assert.That(metadata["Test"], Is.EqualTo("test")); Assert.That(metadata["Test2"], Is.EqualTo("test2")); } finally { testHelper.DeleteItemFromContainer(Constants.HeadStorageItemName); } } }
public void Should_get_200_OK_or_204_No_Content_when_item_exists() { using (var testHelper = new TestHelper(authToken, storageUrl)) { try { testHelper.PutItemInContainer(Constants.HeadStorageItemName); testHelper.AddMetadataToItem(Constants.HeadStorageItemName); var getStorageItemInformation = new GetStorageItemInformation(storageUrl, Constants.CONTAINER_NAME, Constants.HeadStorageItemName); var getStorageItemInformationResponse = new GenerateRequestByType().Submit( getStorageItemInformation, authToken); Assert.That(getStorageItemInformationResponse.Status == HttpStatusCode.OK || getStorageItemInformationResponse.Status == HttpStatusCode.NoContent, Is.True); var metadata = getStorageItemInformationResponse.Metadata; Assert.That(metadata["Test"], Is.EqualTo("test")); Assert.That(metadata["Test2"], Is.EqualTo("test2")); } finally { testHelper.DeleteItemFromContainer(Constants.HeadStorageItemName); } } }
/// <summary> /// This method retrieves meta information and size, in bytes, of a requested storage object /// </summary> /// <example> /// <code> /// UserCredentials userCredentials = new UserCredentials("username", "api key"); /// IConnection connection = new Connection(userCredentials); /// StorageItem storageItem = connection.GetStorageItemInformation("container name", "RemoteStorageItem.txt"); /// </code> /// </example> /// <param name="containerName">The name of the container that contains the storage object</param> /// <param name="storageItemName">The name of the storage object</param> /// <returns>An instance of StorageItem containing the byte size and meta information associated with the container</returns> /// <exception cref="ArgumentNullException">Thrown when any of the reference parameters are null</exception> public StorageItemInformation GetStorageItemInformation(string containerName, string storageItemName) { if (string.IsNullOrEmpty(containerName) || string.IsNullOrEmpty(storageItemName)) throw new ArgumentNullException(); Log.Info(this, "Getting storage item " + storageItemName + " information in container '" + containerName + "' for user"); try { var getStorageItemInformation = new GetStorageItemInformation(StorageUrl, containerName, storageItemName); var getStorageItemInformationResponse = _requestfactory.Submit(getStorageItemInformation, AuthToken, _usercreds.ProxyCredentials); var storageItemInformation = new StorageItemInformation(storageItemName, getStorageItemInformationResponse); return storageItemInformation; } catch (WebException we) { Log.Error(this, "Error getting storage item " + storageItemName + " information in container '" + containerName + "' for user " + _usercreds.Username, we); var response = (HttpWebResponse)we.Response; if (response != null && response.StatusCode == HttpStatusCode.NotFound) throw new StorageItemNotFoundException("The requested storage object does not exist"); throw; } }
public void setup() { getStorageItemInformation = new GetStorageItemInformation("http://storageurl", "containername", "storageitemname"); }
private StorageItemInformation getStorageItemInformation(string containerName, string storageItemName) { var getStorageItemInformation = new GetStorageItemInformation(StorageUrl, containerName, storageItemName); var getStorageItemInformationResponse = _requestfactory.Submit(getStorageItemInformation, AuthToken, _usercreds.ProxyCredentials); var storageItemInformation = new StorageItemInformation(getStorageItemInformationResponse.Headers); return storageItemInformation; }