public void should_return_401_unauthorized() { bool exceptionThrown = false; try { GetAccountInformation getAccountInformation = new GetAccountInformation(storageUrl.Replace("_", "FAIL"), authToken); new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(getAccountInformation)); } catch (WebException we) { exceptionThrown = true; HttpWebResponse response = (HttpWebResponse)we.Response; if (response.StatusCode != HttpStatusCode.Unauthorized) Assert.Fail("Should be a 401 error"); } Assert.That(exceptionThrown, Is.True); }
public void should_return_401_unauthorized() { var exceptionThrown = false; try { var lastGroup = storageUrl.Substring(storageUrl.LastIndexOf('-')+1); var badStorageUrl = storageUrl.Replace(lastGroup, new string('f', lastGroup.Length)); var getAccountInformation = new GetAccountInformation(badStorageUrl); new GenerateRequestByType().Submit(getAccountInformation, authToken); } catch (WebException we) { exceptionThrown = true; var response = (HttpWebResponse)we.Response; if (response.StatusCode != HttpStatusCode.Unauthorized) Assert.Fail("Should be a 401 error"); } Assert.That(exceptionThrown, Is.True); }
public void should_return_number_of_containers_and_bytes_used() { try { connection.CreateContainer(Constants.CONTAINER_NAME); connection.PutStorageItem(Constants.CONTAINER_NAME, Constants.StorageItemName); } finally { connection.DeleteStorageItem(Constants.CONTAINER_NAME, Constants.StorageItemName); connection.DeleteContainer(Constants.CONTAINER_NAME); } using (TestHelper testHelper = new TestHelper(authToken, storageUrl)) { testHelper.PutItemInContainer(Constants.StorageItemName, Constants.StorageItemName); GetAccountInformation getAccountInformation = new GetAccountInformation(storageUrl, authToken); var response = new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(getAccountInformation)); Assert.That(response.Headers[Constants.XAccountBytesUsed], Is.Not.Null); Assert.That(response.Headers[Constants.XAccountContainerCount], Is.Not.Null); testHelper.DeleteItemFromContainer(Constants.StorageItemName); } }
public void should_return_204_no_content_when_the_account_has_no_containers() { GetAccountInformation getAccountInformation = new GetAccountInformation(storageUrl, authToken); var response = new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(getAccountInformation)); Assert.That(response.Status, Is.EqualTo(HttpStatusCode.NoContent)); }
public void should_return_204_no_content_when_the_account_has_no_containers() { GetAccountInformation getAccountInformation = new GetAccountInformation(storageUrl); var response = new GenerateRequestByType().Submit(getAccountInformation, authToken); Assert.That(response.Status, Is.EqualTo(HttpStatusCode.NoContent)); }
AccountInformation buildaccount() { var getAccountInformation = new GetAccountInformation(StorageUrl); var getAccountInformationResponse = _requestfactory.Submit(getAccountInformation, AuthToken); return new AccountInformation(getAccountInformationResponse.Headers[Constants.X_ACCOUNT_CONTAINER_COUNT], getAccountInformationResponse.Headers[Constants.X_ACCOUNT_BYTES_USED]); }
public void setup() { getAccountInformation = new GetAccountInformation("http://storageurl"); _mockrequest = new Mock<ICloudFilesRequest>(); }
/// <summary> /// This method returns the number of containers and the size, in bytes, of the specified account /// </summary> /// <example> /// <code> /// UserCredentials userCredentials = new UserCredentials("username", "api key"); /// IConnection connection = new Connection(userCredentials); /// AccountInformation accountInformation = connection.GetAccountInformation(); /// </code> /// </example> /// <returns>An instance of AccountInformation, containing the byte size and number of containers associated with this account</returns> public AccountInformation GetAccountInformation() { Log.Info(this, "Getting account information for user " + UserCredentials.Username); try { var getAccountInformation = new GetAccountInformation(StorageUrl, AuthToken); var getAccountInformationResponse = new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(getAccountInformation)); return new AccountInformation(getAccountInformationResponse.Headers[Constants.X_ACCOUNT_CONTAINER_COUNT], getAccountInformationResponse.Headers[Constants.X_ACCOUNT_BYTES_USED]); } catch (Exception ex) { Log.Error(this, "Error getting account information for user " + UserCredentials.Username, ex); throw; } }
public void setup() { getAccountInformation = new GetAccountInformation("http://storageurl", "authtoken"); }