public void AddAswerToQuestionTest() { QuestionManagement _QuestionManagement = new QuestionManagement(); IAnswerManagement _AnswerManagement = AnswerManagement.Instance(); DAO.Question _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q1); _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A1)); _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A2)); _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A3)); _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q2); _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A4)); _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A5)); _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A6)); _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q3); _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A7)); _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A8)); _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A9)); _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q4); _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A10)); _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A11)); _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A12)); _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q5); _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A13)); _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A14)); _QuestionManagement.AddAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A15)); _DbContext.SaveChanges(); Assert.True(_Question.Answers.Count() == 3); Assert.True(_Question.Answers.Where(x => x.AnswerId == _AnswerManagement.GetAnswer(StaticAnswers.A14).Id).Count() == 1); }
public void CreateQuestionTest() { QuestionManagement _QuestionManagement = new QuestionManagement(); _QuestionManagement.CreateQuestion(new DAO.Question() { Text = StaticQuestions.Q1 }); _QuestionManagement.CreateQuestion(new DAO.Question() { Text = StaticQuestions.Q2 }); _QuestionManagement.CreateQuestion(new DAO.Question() { Text = StaticQuestions.Q3 }); _QuestionManagement.CreateQuestion(new DAO.Question() { Text = StaticQuestions.Q4 }); _QuestionManagement.CreateQuestion(new DAO.Question() { Text = StaticQuestions.Q5 }); _DbContext.SaveChanges(); var _Result = _QuestionManagement.GetQuestion(StaticQuestions.Q4); Assert.True(_Result != null & _Result.Id > 0); }
public void SetCorrectAnswerToQuestionTest() { QuestionManagement _QuestionManagement = new QuestionManagement(); AnswerManagement _AnswerManagement = new AnswerManagement(); DAO.Question _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q1); _QuestionManagement.SetCorrectAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A1)); _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q2); _QuestionManagement.SetCorrectAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A6)); _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q3); _QuestionManagement.SetCorrectAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A7)); _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q4); _QuestionManagement.SetCorrectAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A11)); _Question = _QuestionManagement.GetQuestion(StaticQuestions.Q5); _QuestionManagement.SetCorrectAnswer(_Question, _AnswerManagement.GetAnswer(StaticAnswers.A13)); _DbContext.SaveChanges(); Assert.True(_Question.Answers.Where(x => x.AnswerId == _AnswerManagement.GetAnswer(StaticAnswers.A13).Id & x.IsCorrect).Count() == 1); }
public void AddQuestionToTest() { TestManagement _TestManagement = new TestManagement(); QuestionManagement _QuestionManagement = new QuestionManagement(); DAO.Test _Test = _TestManagement.GetTest(StaticTests.T1); _TestManagement.AddQuestion(_Test, _QuestionManagement.GetQuestion(StaticQuestions.Q1)); _TestManagement.AddQuestion(_Test, _QuestionManagement.GetQuestion(StaticQuestions.Q2)); _TestManagement.AddQuestion(_Test, _QuestionManagement.GetQuestion(StaticQuestions.Q3)); _TestManagement.AddQuestion(_Test, _QuestionManagement.GetQuestion(StaticQuestions.Q4)); _TestManagement.AddQuestion(_Test, _QuestionManagement.GetQuestion(StaticQuestions.Q5)); _DbContext.SaveChanges(); Assert.True(_Test.Questions.Where(x => x.QuestionId == _QuestionManagement.GetQuestion(StaticQuestions.Q3).Id).Count() == 1); }