public void when_adding_storage_object() { var createContainer = new PutStorageDirectory("http://storageurl", "containername", "objname"); var mock = new Mock<ICloudFilesRequest>(); createContainer.Apply(mock.Object); should("append container and object name to storage url", () => createContainer.CreateUri().ToString().Is("http://storageurl/containername/objname")); should("use PUT method", () => mock.VerifySet(x => x.Method = "PUT") ); should("have content type of application/directory", () => mock.VerifySet(x => x.ContentType = "application/directory") ); should("set content with basic empty object", () => mock.Verify(x => x.SetContent(It.IsAny<MemoryStream>(), It.IsAny<Connection.ProgressCallback>())) ); }
private void MakeStorageDirectory(string containerName, string remoteobjname) { if (string.IsNullOrEmpty(containerName) || string.IsNullOrEmpty(remoteobjname)) throw new ArgumentNullException(); Log.Info(this, "Putting storage item " + remoteobjname + " with metadata into container '" + containerName + "' for user " + _usercreds.Username); try { var makedirectory = new PutStorageDirectory(StorageUrl, containerName, remoteobjname); _requestfactory.Submit(makedirectory, AuthToken, _usercreds.ProxyCredentials); } catch (WebException webException) { Log.Error(this, "Error putting storage item " + remoteobjname + " with metadata into container '" + containerName + "' for user " + _usercreds.Username, webException); var webResponse = (HttpWebResponse)webException.Response; if (webResponse == null) throw; if (webResponse.StatusCode == HttpStatusCode.BadRequest) throw new ContainerNotFoundException("The requested container does not exist"); if (webResponse.StatusCode == HttpStatusCode.PreconditionFailed) throw new PreconditionFailedException(webException.Message); throw; } }
public void when_creating_uri_and_storage_item_has_forward_slashes_at_the_beginning() { var item = new PutStorageDirectory("http://storeme", "itemcont", "/dir1/dir2"); Uri url = item.CreateUri(); should("remove all forward slashes", () => url.EndsWith("dir1/dir2")); }
public void SetUp() { item = new PutStorageDirectory("http://storeme", "itemcont", "/dir1/dir2"); url = item.CreateUri(); }
public void SetUp() { createContainer = new PutStorageDirectory("http://storageurl", "containername", "objname"); mock = new Mock<ICloudFilesRequest>(); createContainer.Apply(mock.Object); }