public void TestAddSubTask() { YouCompleteMe.Models.Subtask subtask = new YouCompleteMe.Models.Subtask(); subtask.taskID = 33; subtask.st_CreatedDate = DateTime.Now; subtask.st_Deadline = DateTime.Now; subtask.st_CompleteDate = DateTime.Now; subtask.st_Priority = 2; subtask.st_Description = "use for test unit test"; subtask.note = "this use only for unit test"; int subtaskID = SubtaskController.AddSubTask(subtask); YouCompleteMe.Models.Subtask result = SubtaskController.getASubTask(subtaskID); Assert.AreEqual(subtaskID, result.subtaskID); }
//handle the btn submit click private void btnSubmit_Click(object sender, EventArgs e) { try { if (!isUpdate)//add subtask { if (validData()) { Models.Subtask subtask = new Models.Subtask(); this.PutSubTask(subtask); int subtaskID = 0; //DialogResult result = MessageBox.Show("Do you want to add this subtask to the following task:\n" + taskTitle, "Create new subtask", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); //if (result.Equals(DialogResult.OK)) //{ subtaskID = SubtaskController.AddSubTask(subtask); //if (subtaskID == 0) // MessageBox.Show("Subtask was not ablet o be added. Please try again."); if (dateForm != null) { this.dateForm.dateForm_Load(sender, e); } if (childTasksForm != null) { this.childTasksForm.refreshChildList(); } this.Close(); //} } } else //update subtask { } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } }