public async Task CannotGetStorageObjectWithEmptyObjectName()
 {
     var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator);
     await client.GetStorageObject("container", string.Empty);
 }
 public async Task CannotGetStorageObjectWithNullContainerName()
 {
     var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator);
     await client.GetStorageObject(null,"object");
 }
        public async Task CanGetStorageObjectWithHeaders()
        {
            var containerName = "TestContainer";
            var objectName = "TestObject";

            var headers = new HttpHeadersAbstraction()
            {
                {"Content-Length", "1234"},
                {"Content-Type", "application/octet-stream"},
                {"Last-Modified", "Wed, 12 Mar 2014 23:42:23 GMT"},
                {"ETag", "d41d8cd98f00b204e9800998ecf8427e"},
                {"X-Object-Meta-Test1","Test1"}
            };

            var restResp = new HttpResponseAbstraction(new MemoryStream(), headers, HttpStatusCode.NoContent);
            this.StorageServiceRestClient.Responses.Enqueue(restResp);

            var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator);
            var result = await client.GetStorageObject(containerName, objectName);

            Assert.IsNotNull(result);
            Assert.AreEqual(objectName, result.Name);
            Assert.AreEqual(containerName, result.ContainerName);
            Assert.AreEqual(1234, result.Length);
            Assert.AreEqual("application/octet-stream", result.ContentType);
            Assert.AreEqual("d41d8cd98f00b204e9800998ecf8427e", result.ETag);
            Assert.AreEqual(DateTime.Parse("Wed, 12 Mar 2014 23:42:23 GMT"), result.LastModified);
            Assert.AreEqual(1, result.Metadata.Count());
            Assert.IsTrue(result.Metadata.ContainsKey("Test1"));
            Assert.AreEqual("Test1", result.Metadata["Test1"]);
        }
        public async Task ExceptionthrownWhenGettingAStorageObjectAndServerError()
        {
            var containerName = "TestContainer";
            var objectName = "TestObject";

            var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.InternalServerError);
            this.StorageServiceRestClient.Responses.Enqueue(restResp);

            var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator);
            await client.GetStorageObject(containerName, objectName);
        }
        public async Task CanGetStorageObjectWithOkResponseThatIsAManifest()
        {
            var containerName = "TestContainer";
            var objectName = "TestObject";

            var headers = new HttpHeadersAbstraction()
            {
                {"Content-Length", "1234"},
                {"Content-Type", "application/octet-stream"},
                {"Last-Modified", "Wed, 12 Mar 2014 23:42:23 GMT"},
                {"ETag", "d41d8cd98f00b204e9800998ecf8427e"},
                {"X-Object-Meta-Test1","Test1"},
                {"X-Static-Large-Object","True"}
            };

            var payload = @"[
                                {
                                    ""hash"": ""d41d8cd98f00b204e9800998ecf8427e"",
                                    ""last_modified"": ""2014-03-07T21:31:31.588170"",
                                    ""bytes"": 54321,
                                    ""name"": ""a/b/c/BLAH"",
                                    ""content_type"": ""application/octet-stream""
                                }]";

            var content = TestHelper.CreateStream(payload);

            var restResp = new HttpResponseAbstraction(content, headers, HttpStatusCode.OK);
            this.StorageServiceRestClient.Responses.Enqueue(restResp);
            this.StorageServiceRestClient.Responses.Enqueue(restResp);

            var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator);
            var result = await client.GetStorageObject(containerName, objectName);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(StaticLargeObjectManifest));
            Assert.AreEqual(objectName, result.Name);
            Assert.AreEqual(containerName, result.ContainerName);
            Assert.AreEqual(1234, result.Length);
            Assert.AreEqual("application/octet-stream", result.ContentType);
            Assert.AreEqual("d41d8cd98f00b204e9800998ecf8427e", result.ETag);
            Assert.AreEqual(DateTime.Parse("Wed, 12 Mar 2014 23:42:23 GMT"), result.LastModified);
        }