public void GetQuestionByIdTest() { var dbQuestion = DbContext.Questions.FirstOrDefault(); var dbQuestionId = dbQuestion.Id; Assert.IsTrue(dbQuestionId > 0); Question q = QRep.getQuestionById(dbQuestionId); Assert.AreEqual(dbQuestion.Id, q.Id); Assert.AreEqual(dbQuestion.QuestionText, q.QuestionText); }
public void GetCategoryTextByCategoryIdTest() { var dbQuestion = DbContext.Questions.FirstOrDefault(); var dbQuestionCategoryId = dbQuestion.CategoryId; Assert.IsTrue(dbQuestionCategoryId > 0); Category dbC = DbContext.Categories.Find(dbQuestionCategoryId); Assert.IsTrue(dbC != null); var dbCText = dbC.CategoryText; var cText = QRep.getCategoryTextByCategoryId(dbQuestionCategoryId); Assert.AreEqual(dbCText, cText); }
public void SetQuestionStatisticsOneUpTest() { var dbQuestion = DbContext.Questions.FirstOrDefault(); Assert.IsTrue(dbQuestion != null); var questionCorectness = dbQuestion.CorrectCount; var questionAnswered = dbQuestion.AnsweredCount; var questionTrueOrFalse = true; QRep.SetQuestionStatisticsOneUp(questionTrueOrFalse, dbQuestion.Id); var question = QRep.getQuestionById(dbQuestion.Id); Assert.AreNotEqual(questionCorectness, question.CorrectCount); dbQuestion.CorrectCount = questionCorectness; }
public void SaveQuestion() { User admin = URep.GetUserByUserName("Admin"); var question = new Question(); Answer a1_3 = new Answer() { AnswerText = "Bambi", UserId = admin.Id, Correctness = false }; Answer a2_3 = new Answer() { AnswerText = "Höhle", UserId = admin.Id, Correctness = false }; Answer a3_3 = new Answer() { AnswerText = "Einhorn", UserId = admin.Id, Correctness = true }; Answer a4_3 = new Answer() { AnswerText = "Elch", UserId = admin.Id, Correctness = false }; question.CategoryId = CatRep.GetAllCategoriesFromUserId(admin.Id).FirstOrDefault().Id; question.UserId = admin.Id; question.QuestionText = "Passwort zum Schulzimmer?"; question.Answers.AddRange(new List <Answer>() { a1_3, a2_3, a3_3, a4_3 }); QRep.Save(question); int id = question.Id; Assert.IsTrue(id > 0); Question dbQuestion = DbContext.Questions.FirstOrDefault(x => x.QuestionText == question.QuestionText && x.Id == question.Id); Assert.IsTrue(dbQuestion != null); QRep.Delete(question.Id); dbQuestion = DbContext.Questions.FirstOrDefault(x => x.QuestionText == question.QuestionText && x.Id == question.Id); Assert.IsTrue(dbQuestion == null); }