public void Should_return_no_content_when_the_container_exists()
 {
     PutContainer(storageUrl, Constants.CONTAINER_NAME);
     var deleteContainer = new DeleteContainer(storageUrl, authToken, Constants.CONTAINER_NAME);
     var response = new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(deleteContainer));
     Assert.That(response.Status, Is.EqualTo(HttpStatusCode.NoContent));
 }
 public void Should_return_no_content_when_the_container_exists()
 {
     PutContainer(storageUrl, Constants.CONTAINER_NAME);
     var deleteContainer = new DeleteContainer(storageUrl, Constants.CONTAINER_NAME);
     var response = new GenerateRequestByType().Submit(deleteContainer, authToken);
     Assert.That(response.Status, Is.EqualTo(HttpStatusCode.NoContent));
 }
        public void Should_return_404_when_container_does_not_exist()
        {
            var deleteContainer = new DeleteContainer(storageUrl, authToken, Guid.NewGuid().ToString());

            new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(deleteContainer));
            Assert.Fail("404 Not found exception expected");
        }
        private void DeleteContainer(string storageUri, string containerName)
        {
            DeleteContainer deleteContainer = new DeleteContainer(storageUri,  containerName);

            IResponse response = new GenerateRequestByType().Submit(deleteContainer, authToken);
            Assert.That(response.Status, Is.EqualTo(HttpStatusCode.NoContent));
        }
        public void Should_return_404_when_container_does_not_exist()
        {
            var deleteContainer = new DeleteContainer(storageUrl,  Guid.NewGuid().ToString());

             new GenerateRequestByType().Submit(deleteContainer, authToken);
            Assert.Fail("404 Not found exception expected");
        }
 public void when_deleting_a_container()
 {
     var deleteContainer = new DeleteContainer("http://storageurl", "containername");
     var mockrequest = new Mock<ICloudFilesRequest>();
     deleteContainer.Apply(mockrequest.Object);
     should("have url made of storage url and container name",
         ()=>deleteContainer.CreateUri().ToString().Is("http://storageurl/containername"));
     should("have http delete method", ()=>
         mockrequest.VerifySet(x => x.Method = "DELETE")
         );
 }
        public void when_purging_a_public_container_wit_multiple_purge_email_addresses()
        {
            var deleteContainer = new DeleteContainer("http://cdnmanagementurl", "containername", new[] { "*****@*****.**", "*****@*****.**" });
            var mockrequest = new Mock<ICloudFilesRequest>();
            var webheaders = new WebHeaderCollection();
            mockrequest.SetupGet(x => x.Headers).Returns(webheaders);

            Assert.That(deleteContainer.CreateUri().ToString(), Is.EqualTo("http://cdnmanagementurl/containername"));

            deleteContainer.Apply(mockrequest.Object);

            mockrequest.VerifySet(x => x.Method = "DELETE");
            webheaders.KeyValueFor(Constants.X_PURGE_EMAIL).HasValueOf("[email protected],[email protected]");
        }
        private void DeleteContainer(string storageUri, string containerName)
        {
            DeleteContainer deleteContainer = new DeleteContainer(storageUri, authToken, containerName);

            IResponse response = new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(deleteContainer));
            Assert.That(response.Status, Is.EqualTo(HttpStatusCode.NoContent));
        }
 void deletecontainer(string containerName)
 {
     var deleteContainer = new DeleteContainer(StorageUrl, containerName);
     _requestfactory.Submit(deleteContainer, AuthToken, _usercreds.ProxyCredentials);
 }
 protected override void SetUp()
 {
     deleteContainer = new DeleteContainer("http://storageurl", "containername");
     mockrequest = new Mock<ICloudFilesRequest>();
     deleteContainer.Apply(mockrequest.Object);
 }
 public void setup()
 {
     deleteContainer = new DeleteContainer("http://storageurl", "authtoken", "containername");
 }
        /// <summary>
        /// This method is used to delete a container on cloudfiles
        /// </summary>
        /// <example>
        /// <code>
        /// UserCredentials userCredentials = new UserCredentials("username", "api key");
        /// IConnection connection = new Connection(userCredentials);
        /// connection.DeleteContainer("container name");
        /// </code>
        /// </example>
        /// <param name="containerName">The name of the container to delete</param>
        /// <exception cref="ArgumentNullException">Thrown when any of the reference parameters are null</exception>
        public void DeleteContainer(string containerName)
        {
            if (string.IsNullOrEmpty(containerName))
                throw new ArgumentNullException();

            Log.Info(this, "Deleting container '" + containerName + "' for user " + UserCredentials.Username);

            try
            {
                var deleteContainer = new DeleteContainer(StorageUrl, AuthToken, containerName);
                new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(deleteContainer, UserCredentials.ProxyCredentials));
            }
            catch (WebException ex)
            {
                Log.Error(this, "Error deleting container '"
                    + containerName + "' for user "
                    + UserCredentials.Username, ex);

                var response = ((HttpWebResponse)ex.Response);
                if (response != null && response.StatusCode == HttpStatusCode.NotFound)
                    throw new ContainerNotFoundException("The requested container " + containerName + " does not exist");
                if (response != null && response.StatusCode == HttpStatusCode.Conflict)
                    throw new ContainerNotEmptyException("The container you are trying to delete " + containerName +"is not empty");
                throw;
            }
        }
 private void purgePublicContainer(string url, string containerName, string[] emailAddresses)
 {
     var deleteContainer = new DeleteContainer(url, containerName, emailAddresses);
     _requestfactory.Submit(deleteContainer, AuthToken, _usercreds.ProxyCredentials);
 }
 private void deleteContainer(string url, string containerName)
 {
     var deleteContainer = new DeleteContainer(url, containerName, null);
     _requestfactory.Submit(deleteContainer, AuthToken, _usercreds.ProxyCredentials);
 }