public void DeleteDirectory_PathIsValid_ExpectedPositiveTest() { //Arrange IDirectoryService directoryService = mockDirectory.Object; //Act directoryService.DeleteDirectory(@"D:\New Folder"); //Assert mockDirectory.Verify(ds => ds.DeleteDirectory(It.IsAny <string>())); }
public ActionResult DeleteDirectory(string path = "") { List <ExplorerViewModel> explorerObjects; string newPath; if (path == "") { return(Redirect("/Drive/GetDrives/")); } path = PathValidation(path); try { directoryService.DeleteDirectory(path); newPath = directoryService.GetParrent(path); var dirListModel = directoryService.GetAllDirectories(newPath).Select(d => d.ToExplorerObject()); var fileListModel = fileService.GetAllFiles(newPath).Select(f => f.ToExplorerObject()); explorerObjects = new List <ExplorerViewModel>(); foreach (var obj in dirListModel) { explorerObjects.Add(obj); } foreach (var obj in fileListModel) { explorerObjects.Add(obj); } } catch (UnauthorizedAccessException) { return(Json(new { Status = "NotAcceptable" }, JsonRequestBehavior.AllowGet)); } newPath = newPath.Remove(1, 1); if (newPath.Last() != '\\') { newPath = newPath + "\\"; } newPath = newPath.Replace("\\", "\\\\"); ViewBag.LastPath = newPath; if (Request.IsAjaxRequest()) { return(PartialView("GetAllDirectory", explorerObjects)); } return(View("GetAllDirectory", explorerObjects)); }
public async Task <ActionResponse> ExecuteAsync(CreateSolutionModel model, Action <CreateSolutionModel, string> notifyAction) { // Clean working directory _directoryService.DeleteDirectory(_configuration.WorkingDirectory); var directory = _directoryService.CreateDirectory(_configuration.DownloadDirectory); // Clone template repository await _cloneSolutionTemplateCommand.ExecuteAsync(model, notifyAction); _directoryService.CopyDirectory(directory.FullName, _configuration.WorkingDirectory); await _updateSolutionFileNamespacesCommand.ExecuteAsync(model, notifyAction); // download template and unzip into location return(await _cloneSolutionTemplateCommand.ExecuteAsync(model, notifyAction)); }
public async Task <IActionResult> DeleteDirectory(int id, string username, CancellationToken cancellationToken) { try { int result = await _dirService.DeleteDirectory(id, username, cancellationToken).ConfigureAwait(false); if (result == 0) { return(BadRequest("Category not found!!!")); } else { return(Ok("Category Deleted Successfully")); } } catch (Exception ex) { await _errorlogService.InsertError(Request.GetDisplayUrl(), ControllerContext.ActionDescriptor.ActionName.ToString(), ex.Message, ex.ToString()).ConfigureAwait(false); return(StatusCode(500, ex.InnerException)); } }
public ActionResult DeleteFile(DeleteViewModel jsonObject) { var name = jsonObject.Name; var type = jsonObject.Type; var driveName = jsonObject.DriveName ?? ""; var path = jsonObject.Path ?? ""; var uri = new Uri(driveName + ":/" + path); var realPath = uri.LocalPath; if (type.ToLower().Contains("folder")) { directoryService.DeleteDirectory(realPath + name); } else { fileService.DeleteFile(realPath + name); } var explorerModel = GetExplorerModel(realPath); return(PartialView("_GetDirectories", explorerModel)); }
public void CleanUp() { Sut.DeleteDirectory(_destinationDirectory); Sut.DeleteDirectory(_sourceDirectory); }