public async Task CanGetStorageAccontWithNoContent() { var accountName = "1234567890"; var headers = new HttpHeadersAbstraction() { {"X-Account-Bytes-Used", "1234"}, {"X-Account-Object-Count", "1"}, {"X-Account-Container-Count", "1"} }; 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.GetStorageAccount(); Assert.IsNotNull(result); Assert.AreEqual(accountName, result.Name); Assert.AreEqual(1234, result.TotalBytesUsed); Assert.AreEqual(1, result.TotalObjectCount); Assert.AreEqual(1, result.TotalContainerCount); Assert.IsNotNull(result.Containers); Assert.AreEqual(0, result.Containers.Count()); }
public async Task ExceptionthrownWhenGettingAStoragManifestAndNotAuthed() { var containerName = "TestContainer"; var manifestName = "a/b/b/manifest"; var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.Unauthorized); this.StorageServiceRestClient.Responses.Enqueue(restResp); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.GetStorageManifest(containerName, manifestName); }
public async Task ExceptionThrownWhenCreatingaStorageObjectHasInternalServerError() { var containerName = "TestContainer"; var objectName = "TestObject"; var objRequest = new StorageObject(objectName, containerName); var content = TestHelper.CreateStream("Some Content"); var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.InternalServerError); this.StorageServiceRestClient.Responses.Enqueue(restResp); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.CreateStorageObject(objRequest, content); }
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 CannotGetStorageObjectWithNullContainerName() { var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.GetStorageObject(null,"object"); }
public async Task CannotDownloadStorageObjectWithNullContainerName() { var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.DownloadStorageObject(null, "object", new MemoryStream()); }
public async Task CannotDownloadStorageObjectWithnullOutputStream() { var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.DownloadStorageObject("container", "object", null); }
public async Task CanCreateStorageContainerWithNoContentResponse() { var containerName = "TestContainer"; var headers = new HttpHeadersAbstraction { {"X-Container-Bytes-Used", "12345"}, {"X-Container-Object-Count", "1"} }; var restResp = new HttpResponseAbstraction(new MemoryStream(), headers, HttpStatusCode.NoContent); this.StorageServiceRestClient.Responses.Enqueue(restResp); var containerReq = new StorageContainer(containerName, new Dictionary<string, string>()); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.CreateStorageContainer(containerReq); //Assert.IsNotNull(container); //Assert.AreEqual(containerName, container.Name); //Assert.AreEqual(12345, container.TotalBytesUsed); }
public async Task CanGetStorageAccountWithOkResponse() { var accountName = "1234567890"; var headers = new HttpHeadersAbstraction() { {"X-Account-Bytes-Used", "1234"}, {"X-Account-Object-Count", "1"}, {"X-Account-Container-Count", "1"} }; var payload = @"[ { ""count"": 1, ""bytes"": 7, ""name"": ""TestContainer"" }]"; var content = TestHelper.CreateStream(payload); var restResp = new HttpResponseAbstraction(content, headers, HttpStatusCode.OK); this.StorageServiceRestClient.Responses.Enqueue(restResp); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); var result = await client.GetStorageAccount(); Assert.IsNotNull(result); Assert.AreEqual(accountName, result.Name); Assert.AreEqual(1234, result.TotalBytesUsed); Assert.AreEqual(1, result.TotalObjectCount); Assert.AreEqual(1, result.TotalContainerCount); Assert.IsNotNull(result.Containers); Assert.AreEqual(1, result.Containers.Count()); }
public async Task ExceptionThrownWhenCreatingaStorageFolderTimesOut() { var containerName = "TestContainer"; var folderName = "a/b/b/"; var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.RequestTimeout); this.StorageServiceRestClient.Responses.Enqueue(restResp); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.CreateStorageFolder(containerName, folderName); }
public async Task CannotGetStorageContainerWithNullName() { var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.GetStorageContainer(null); }
public async Task ExceptionThrownWhenCreatingaStorageFolderMissingLength() { var containerName = "TestContainer"; var folderName = "a/b/b/"; var headers = new HttpHeadersAbstraction() { {"Content-Length", "1234"}, {"Content-Type", "application/octet-stream"}, {"Last-Modified", "Wed, 12 Mar 2014 23:42:23 GMT"}, {"ETag", "d41d8cd98f00b204e9800998ecf8427e"} }; var restResp = new HttpResponseAbstraction(new MemoryStream(), headers, HttpStatusCode.LengthRequired); this.StorageServiceRestClient.Responses.Enqueue(restResp); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.CreateStorageFolder(containerName, folderName); }
public async Task ExceptionThrownWhenCopyingaStorageObjectTimesOut() { var containerName = "TestContainer"; var objectName = "TestObject"; var targetContainerName = "TargetTestContainer"; var objRequest = new StorageObject(objectName, containerName); var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.RequestTimeout); this.StorageServiceRestClient.Responses.Enqueue(restResp); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.CopyStorageObject(objRequest, targetContainerName); }
public async Task CanCopyStorageObjectWithFoldersAndCreatedResponse() { var containerName = "TestContainer"; var objectName = "a/b/TestObject"; var targetContainerName = "TargetTestContainer"; var headers = new HttpHeadersAbstraction() { {"Content-Length", "0"}, {"Content-Type", "application/octet-stream"}, {"X-Copied-From-Last-Modified","Wed, 12 Mar 2014 22:42:23 GMT"}, {"X-Copied-From" , "TestContainer/a/b/TestObject"}, {"Last-Modified", "Wed, 12 Mar 2014 23:42:23 GMT"}, {"ETag", "d41d8cd98f00b204e9800998ecf8427e"} }; var objRequest = new StorageObject(objectName, containerName); var restResp = new HttpResponseAbstraction(new MemoryStream(), headers, HttpStatusCode.Created); this.StorageServiceRestClient.Responses.Enqueue(restResp); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); var result = await client.CopyStorageObject(objRequest, targetContainerName); Assert.IsNotNull(result); Assert.AreEqual(objectName, result.FullName); Assert.AreEqual(containerName, result.ContainerName); Assert.AreEqual(0, 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); }
public async Task CanDownloadStorageObjectWithOkResponse() { 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"} }; var data = "some data"; var content = TestHelper.CreateStream(data); var restResp = new HttpResponseAbstraction(content, headers, HttpStatusCode.OK); this.StorageServiceRestClient.Responses.Enqueue(restResp); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); var respContent = new MemoryStream(); var result = await client.DownloadStorageObject(containerName, objectName, respContent); 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(data,TestHelper.GetStringFromStream(respContent)); }
public async Task CanDeleteStorageObjectWithOkResponse() { var containerName = "TestContainer"; var objectName = "TestObject"; var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.OK); this.StorageServiceRestClient.Responses.Enqueue(restResp); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.DeleteStorageObject(containerName, objectName); }
public async Task ExceptionthrownWhenDownloadingAStorageObjectAndServerError() { 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.DownloadStorageObject(containerName, objectName, new MemoryStream()); }
public async Task CanDeleteStorageFolderWithNoContentResponse() { var containerName = "TestContainer"; var folderName = "a/b/c/"; var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.NoContent); this.StorageServiceRestClient.Responses.Enqueue(restResp); this.StorageServiceRestClient.Responses.Enqueue(restResp); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.DeleteStorageFolder(containerName, folderName); }
public async Task CannotDownloadStorageObjectWithEmptyObjectName() { var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.DownloadStorageObject("container", string.Empty, new MemoryStream()); }
public async Task ExceptionThrownWhenDeletingAStorageFolderThatHasChildren() { var containerName = "TestContainer"; var folderName = "a/b/c/"; var headers = new HttpHeadersAbstraction() { {"X-Container-Bytes-Used", "1234"}, {"X-Container-Object-Count", "1"} }; var payload = @"[ { ""hash"": ""d41d8cd98f00b204e9800998ecf8427e"", ""last_modified"": ""2014-03-07T21:31:31.588170"", ""bytes"": 0, ""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); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.DeleteStorageFolder(containerName, folderName); }
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); }
public async Task ExceptionThrownWhenDeletingAStorageFolderWithBadAuth() { var containerName = "TestContainer"; var folderName = "a/b/c/"; var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.Unauthorized); this.StorageServiceRestClient.Responses.Enqueue(restResp); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.DeleteStorageFolder(containerName, folderName); }
public async Task ExceptionthrownWhenGettingAStorageObjectThatDoesNotExist() { var containerName = "TestContainer"; var objectName = "TestObject"; var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.NotFound); this.StorageServiceRestClient.Responses.Enqueue(restResp); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.GetStorageObject(containerName, objectName); }
public async Task ExceptionThrownWhenUpdatingAStorageContainerWithInternalServerError() { var containerName = "TestContainer"; var containerReq = new StorageContainer(containerName, new Dictionary<string, string>()); var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.InternalServerError); this.StorageServiceRestClient.Responses.Enqueue(restResp); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.UpdateStorageContainer(containerReq); }
public async Task CannotGetStorageObjectWithEmptyObjectName() { var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.GetStorageObject("container", string.Empty); }
public async Task ExceptionThrownWhenUpdatingAStorageObjectWithBadAuth() { var containerName = "TestContainer"; var objectName = "TestObject"; var objectReq = new StorageObject(containerName, objectName); var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.Unauthorized); this.StorageServiceRestClient.Responses.Enqueue(restResp); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.UpdateStorageObject(objectReq); }
public async Task ExceptionthrownWhenGettingAStorageFolderAndServerError() { var containerName = "TestContainer"; var fodlerName = "a/b/b/"; var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.InternalServerError); this.StorageServiceRestClient.Responses.Enqueue(restResp); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.GetStorageFolder(containerName, fodlerName); }
public async Task ExceptionThrownWhenCreatingaStorageManifestHasInternalServerError() { var containerName = "TestContainer"; var manifestName = "a/b/c/manifest"; var segPath = "TestContainer/a/b/c"; var manifest = new DynamicLargeObjectManifest(containerName, manifestName, segPath); var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.InternalServerError); this.StorageServiceRestClient.Responses.Enqueue(restResp); var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator); await client.CreateStorageManifest(manifest); }