public void Execute_DeleteBlob_ResponseParsesHeadersCorrectly()
        {
            var expectedContainer = "test-container";
            var expectedBlob = "test-blob";
            var expectedUri = String.Format("{0}/{1}/{2}", _settings.BlobEndpoint, expectedContainer, expectedBlob);
            var expectedRawRequest = new TestableWebRequest(new Uri(expectedUri))
                                            .EnqueueResponse(new HttpResponseSettings((HttpStatusCode)202, "Accepted", "", false, new Dictionary<string, string>(){
                                                {"Date", DateTime.UtcNow.ToString() }
                                            }));
            TestableWebRequestCreateFactory.GetFactory().AddRequest(expectedRawRequest);
            var expectedDate = DateTime.UtcNow;
            var request = new DeleteBlobRequest(_settings, expectedContainer, expectedBlob);

            var response = request.Execute();

            Assert.AreEqual(response.HttpStatus, HttpStatusCode.Accepted);
            Assert.IsTrue(Math.Abs(expectedDate.Subtract(response.Payload.Date).TotalMinutes) < 1);
        }
예제 #2
0
        public void Execute_DeleteBlob_ResponseParsesHeadersCorrectly()
        {
            var expectedContainer  = "test-container";
            var expectedBlob       = "test-blob";
            var expectedUri        = String.Format("{0}/{1}/{2}", _settings.BlobEndpoint, expectedContainer, expectedBlob);
            var expectedRawRequest = new TestableWebRequest(new Uri(expectedUri))
                                     .EnqueueResponse(new HttpResponseSettings((HttpStatusCode)202, "Accepted", "", false, new Dictionary <string, string>()
            {
                { "Date", DateTime.UtcNow.ToString() }
            }));

            TestableWebRequestCreateFactory.GetFactory().AddRequest(expectedRawRequest);
            var expectedDate = DateTime.UtcNow;
            var request      = new DeleteBlobRequest(_settings, expectedContainer, expectedBlob);

            var response = request.Execute();

            Assert.AreEqual(response.HttpStatus, HttpStatusCode.Accepted);
            Assert.IsTrue(Math.Abs(expectedDate.Subtract(response.Payload.Date).TotalMinutes) < 1);
        }
        public void DeleteBlob(string containerName, string blobName, string leaseId = null)
        {
            var request = new DeleteBlobRequest(_account, containerName, blobName, leaseId);

            request.Execute();
        }