public void DeleteAnswer_Not_Found() { var c = ControllerProvider.CreateQuizzesController(); var result = c.DeleteAnswer(-1) as HttpStatusCodeResult; Assert.AreEqual(result.StatusCode, new HttpStatusCodeResult(HttpStatusCode.NotFound).StatusCode); }
public void DeleteAnswer_Bad_Request() { var c = ControllerProvider.CreateQuizzesController(); var result = c.DeleteAnswer(null) as HttpStatusCodeResult; Assert.AreEqual(result.StatusCode, new HttpStatusCodeResult(HttpStatusCode.BadRequest).StatusCode); }
public void DeleteAnswer() { var c = ControllerProvider.CreateQuizzesController(); var result = c.DeleteAnswer(1) as PartialViewResult; var model = result.Model as EditQuestionViewModel; Assert.IsNotNull(model); }
public void CreateAnswer_Get() { var c = ControllerProvider.CreateQuizzesController(); var result = c.CreateAnswer(1) as RedirectToRouteResult; Assert.AreEqual(result.RouteValues["action"], "EditQuestion"); Assert.AreEqual(result.RouteValues["id"], 1); }
public void Delete() { var c = ControllerProvider.CreateQuizzesController(); var result = c.Delete(1) as ViewResult; var model = result.Model as QuizViewModel; Assert.IsNotNull(model); }
public void Edit_Not_Found() { var c = ControllerProvider.CreateQuizzesController(); HttpStatusCodeResult result; result = c.Edit(-1) as HttpStatusCodeResult; Assert.AreEqual(result.StatusCode, new HttpStatusCodeResult(HttpStatusCode.NotFound).StatusCode); }
public void Edit_Bad_Request() { var c = ControllerProvider.CreateQuizzesController(); HttpStatusCodeResult result; result = c.Edit((int?)null) as HttpStatusCodeResult; Assert.AreEqual(result.StatusCode, new HttpStatusCodeResult(HttpStatusCode.BadRequest).StatusCode); }
public void Edit_Get() { var c = ControllerProvider.CreateQuizzesController(); var result = c.Edit(1) as ViewResult; var model = result.Model as EditQuizViewModel; Assert.IsNotNull(model); Assert.AreEqual(1, model.Quiz.QuizId); }
public void EditAnswer_Get() { var c = ControllerProvider.CreateQuizzesController(); var result = c.EditAnswer(1) as PartialViewResult; var model = result.Model as EditAnswerViewModel; Assert.IsNotNull(model); Assert.AreEqual(1, model.Answer.AnswerId); }
public void EditAnswer_Post() { var c = ControllerProvider.CreateQuizzesController(); Answer model = Mocks.AnswerRepo.Get(1); var result = c.EditAnswer(Mocks.ModelConverter.ToEditAnswerViewModel(model)) as RedirectToRouteResult; Assert.AreEqual(result.RouteValues["action"], "EditQuestion"); }
public void EditQuestion_Post() { var c = ControllerProvider.CreateQuizzesController(); EditQuestionViewModel model = Mocks.ModelConverter.ToEditQuestionViewModel(Mocks.QuestionRepo.Get(1)); model.Question.Text = "text"; var result = c.EditQuestion(model) as PartialViewResult; model = result.Model as EditQuestionViewModel; Assert.IsNotNull(model); Assert.AreEqual("text", model.Question.Text); }
public void Edit_Post() { var c = ControllerProvider.CreateQuizzesController(); EditQuizViewModel model = Mocks.ModelConverter.ToEditQuizViewModel(Mocks.QuizService.Get(1)); model.Quiz.Name = "test"; var result = c.Edit(model) as PartialViewResult; model = result.Model as EditQuizViewModel; Assert.IsNotNull(model); Assert.AreEqual("test", model.Quiz.Name); }
public void Index() { var c = ControllerProvider.CreateQuizzesController(); QuizzesViewModel model; ViewResult result; result = c.Index("", null, null) as ViewResult; model = result.Model as QuizzesViewModel; Assert.IsNotNull(model); Assert.AreEqual(2, model.Quizzes.Count()); Assert.AreEqual(3, model.QuizCategories.Count()); result = c.Index("***", null, null) as ViewResult; model = result.Model as QuizzesViewModel; Assert.AreEqual(0, model.Quizzes.Count()); result = c.Index("q", null, null) as ViewResult; model = result.Model as QuizzesViewModel; Assert.AreEqual(2, model.Quizzes.Count()); }