private void DeleteAllFiles() { //Uses the Delete method from the DeleterFile service deleteFiles.Delete(deleteFileBindingModel.AllFiles, deleteFileBindingModel); //Shows all the deleted files ShowAllDeletedFiles(); }
public void DeleteMethodDeletesFilesSuccesfully(string sourcePath) { CurrentUser.user.username = "******"; DeleteFileBindingModel bindingModel = new DeleteFileBindingModel(); bindingModel.FileSourcePath = sourcePath; DeleterFileService deleteFileService = new DeleterFileService(); string[] files = new string[] { sourcePath + "\\aaaa.pptx", sourcePath + "\\banan.docx" }; deleteFileService.Delete(files, bindingModel); FileAssert.DoesNotExist(sourcePath + @"\aaaa.pptx"); FileAssert.DoesNotExist(sourcePath + @"\banan.docx"); }
public void DeleteMethodFailed(string sourcePath) { CurrentUser.user.username = "******"; DeleteFileBindingModel bindingModel = new DeleteFileBindingModel(); bindingModel.FileSourcePath = sourcePath; DeleterFileService deleteFileService = new DeleterFileService(); FieldInfo[] fields = typeof(DeleterFileService).GetFields(BindingFlags.Instance | BindingFlags.NonPublic).ToArray(); FieldInfo isDeleted = fields.FirstOrDefault(x => x.Name == "isDeleted"); isDeleted.SetValue(deleteFileService, false); string[] files = new string[] { sourcePath + "\\aaaa.pptx", sourcePath + "\\banan.docx" }; deleteFileService.Delete(files, bindingModel); Assert.IsFalse((bool)isDeleted.GetValue(deleteFileService)); }