public void DeleteRecord_DeleteExisting_IgnoreNonExisting(User user, int selectedDay, int selectedMonth, int selectedStart, int selectedEnd, bool exist) { var size = RecordModel.GetAllRecords().Count; var record = new Record(user, selectedDay, selectedMonth, selectedStart, selectedEnd); //Record is exist or not if (exist) { //Add record RecordModel.CreateRecord(user, selectedDay, selectedMonth, selectedStart, selectedEnd, true); Assert.AreEqual(size + 1, RecordModel.GetAllRecords().Count); //Select record from Record List var selectedRecord = RecordModel.FindRecordByUserInputString(record.FromTime.ToString("dd MMMM, HH:mm") + "—" + record.ToTime.Hour + ":00"); //Delete selected record RecordModel.DeleteRecord(selectedRecord, user.Id); Assert.AreEqual(size, RecordModel.GetAllRecords().Count); } else { //Select record from Record List var selectedRecord = RecordModel.FindRecordByUserInputString(record.FromTime.ToString("dd MMMM, HH:mm") + "—" + record.ToTime.Hour + ":00"); //Delete non-exist record RecordModel.DeleteRecord(selectedRecord, user.Id); Assert.AreEqual(size, RecordModel.GetAllRecords().Count); } }
private bool Operate(string text, int userID) { if (text.Equals("Delete")) { RecordModel.DeleteRecord(_record, userID); _state = 99; return(true); } if (text.Equals("Update")) { GetUpdatedTimes("Select the time when you want to start"); return(false); } return(false); }