private void setupTestQuiz() { testQuiz = new Quiz(); testQuiz.Id = "Quiz/1"; var question = new Question { QuestionText = "Test question", Id = "Question/1", AnswerOptions = new List<Tuple<int, string, bool>> { new Tuple<int, string, bool>(0, "test1", false), new Tuple<int, string, bool>(1, "test1", true) } }; var question2 = new Question { QuestionText = "Test question", Id = "Question/2", AnswerOptions = new List<Tuple<int, string, bool>> { new Tuple<int, string, bool>(0, "test1", false), new Tuple<int, string, bool>(1, "test1", true) } }; testQuiz.Questions.Add(question); testQuiz.Questions.Add(question2); }
public void InsertTest() { setupDb(); var questionStr = @"This is a test"; var answer1 = new Tuple<int, string, bool>(1, "Replace the GridView control with a ListView control.", false); var answer2 = new Tuple<int, string, bool>(2, "Set the ClientIDMode attribute to Predictable in the web.config file.", false); var answer3 = new Tuple<int, string, bool>(3, "Set the ClientIDRowSuffix attribute of each unique GridView control to a different value.", false); var answer4 = new Tuple<int, string, bool>(4, "Set the @ OutputCache directive's VaryByControl attribute to the ID of the GridView control.", true); Question entity = new Question() { QuestionAnswerType = Question.AnswerType.MultipleChoice, QuestionText = "TestQuestion", AnswerOptions = new List<Tuple<int, string, bool>>() { answer1, answer2, answer3, answer4 } }; QuestionManager.Insert(entity); UnitOfWork.Commit(); }
private Question CreateQuestionFromViewModel(QuestionEditViewModel vm) { Question q = new Question() {QuestionText = vm.QuestionText, Id = vm.Id, QuestionAnswerType = vm.AnswerType}; int id = 1; q.AnswerOptions = new List<Tuple<int, string, bool>>(); foreach (AnswerOptionViewModel answerOptionViewModel in vm.AnswerOptions) { q.AnswerOptions.Add(new Tuple<int, string, bool>(id,answerOptionViewModel.AnswerText,answerOptionViewModel.Correct)); id++; } return q; }
public static void Insert(Question entity) { // Add the new entity to the repository. _repository.Add(entity); }
public static void Delete(Question entity) { // Add any custom business rules. _repository.Delete(entity); }