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); }