public void RenameMethodOverwritesFilesSuccesfully() { CurrentUser.user.username = "******"; RenameFileBindingModel bindingModel = new RenameFileBindingModel(); bindingModel.FileName = @"C:\Users\Nikih\Desktop\Resources\banan.docx"; bindingModel.NewName = "banan"; RenamerFileService renameFileService = new RenamerFileService(); renameFileService.Rename(bindingModel); FileAssert.Exists(@"C:\Users\Nikih\Desktop\Resources\Overwrite -banan.docx"); }
public void RenameMethodRenamesFilesCorrectlly() { CurrentUser.user.username = "******"; RenameFileBindingModel bindingModel = new RenameFileBindingModel(); bindingModel.FileName = @"C:\Users\Nikih\Desktop\Resources\banan.docx"; bindingModel.NewName = "izrod"; RenamerFileService renameFileService = new RenamerFileService(); renameFileService.Rename(bindingModel); FileAssert.Exists(@"C:\Users\Nikih\Desktop\Resources\izrod.docx"); }
public void RenameMethodFailed() { CurrentUser.user.username = "******"; RenameFileBindingModel bindingModel = new RenameFileBindingModel(); bindingModel.FileName = @"C:\Users\Nikih\Desktop\Resources\banan.docx"; bindingModel.NewName = "ggg"; RenamerFileService renameFileService = new RenamerFileService(); FieldInfo[] fields = typeof(RenamerFileService).GetFields(BindingFlags.Instance | BindingFlags.NonPublic).ToArray(); FieldInfo isRenamed = fields.FirstOrDefault(x => x.Name == "isRenamed"); isRenamed.SetValue(renameFileService, false); renameFileService.Rename(bindingModel); Assert.IsFalse((bool)isRenamed.GetValue(renameFileService)); }