public void TestDeleteList_ShouldRemoveFromList() { ViewDeleteQuestionList view = new ViewDeleteQuestionList(); ListQuestionListController controller = new ListQuestionListController(); controller.SetBaseFactory(new TestQuestionListFactory()); controller.SetView(view); Model.QuestionList testList = new Model.QuestionList(); testList.Name = "Test List"; //list have 1 items view.AddItem(testList); controller.DeleteQuestionList(testList); //list is empty Assert.AreEqual(view.QuestionList.Count, 0); }
public void TestSaveQuestion_shouldAddQuestionToList() { TestAddQuestionView view = new TestAddQuestionView(); AddQuestionController controller = new AddQuestionController(); controller.SetBaseFactory(new TestQuestionFactory()); controller.SetView(view); Model.QuestionList list = new Model.QuestionList(); list.Id = 1; controller.SetQuestionList(list); Dictionary<string, object> data = new Dictionary<string, object>(); data["Points"] = 2; data["Time"] = 5; data["Text"] = "Test Vraag"; data["PredefinedAnswerCount"] = 0; controller.SaveQuestion(data); Assert.AreEqual(view.CountAddQuestionList(), 1); }
public void TestUpdateQuestion_ShouldReturnTrue() { TestUpdateQuestionView view = new TestUpdateQuestionView(); AddQuestionController controller = new AddQuestionController(); controller.SetBaseFactory(new TestQuestionFactory()); controller.SetView(view); Model.QuestionList list = new Model.QuestionList(); list.Id = 1; controller.SetQuestionList(list); List<Model.PredefinedAnswer> answersNew = new List<Model.PredefinedAnswer>() { new Model.PredefinedAnswer() { Text = "test2" } }; Dictionary<string, object> dataNew = new Dictionary<string, object>(); dataNew["Points"] = 2; dataNew["Time"] = 2; dataNew["Text"] = "test2"; dataNew["PredefinedAnswerCount"] = answersNew.Count; dataNew["Id"] = 1; controller.UpdateQuestion(dataNew); Assert.AreEqual(true, view.questionIsUpdated); }
private void BtnSave_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(textBox.Text)) { DialogResult dr = new DialogResult(); ConfirmDialogView confirm = new ConfirmDialogView(); confirm.getLabelConfirm().Text = "Weet u zeker dat u de naam van de vragenlijst wilt wijzigen?"; dr = confirm.ShowDialog(); if (dr == DialogResult.Yes) { Model.QuestionList questionList = new Model.QuestionList(); questionList.Id = QuestionListId; questionList.Name = textBox.Text; Controller.UpdateQuestionList(questionList); this.QuestionListNameChanged = true; confirm.Close(); } } else { MessageBox.Show("U heeft niks ingevuld, vul alstublieft de nieuwe naam in"); } }