public void EditAssessmentQuestion_Get() { // Arrange var controller = new AssessmentController(_ITrainingService, _IAssessmentService); // Act int assessmentPaperId = 1; int assessmentQuestionID = 1; var result = (ActionResult)controller.EditAssessmentQuestion(assessmentQuestionID, assessmentPaperId); // Assert Assert.IsInstanceOfType(result, typeof(ViewResult)); Assert.AreEqual("EditAssessmentQuestion", (result as ViewResult).ViewName); }
public void EditAssessmentQuestion_PostError() { // Arrange var controller = new AssessmentController(_ITrainingService, _IAssessmentService); // Act AssessmentViewModel assessmentViewModel = new AssessmentViewModel(); assessmentViewModel.AssessmentPaper = new AssessmentPaperViewModel(); assessmentViewModel.AssessmentPaper.AssessmentPaperId = 1; assessmentViewModel.AssessmentQuestions = null; var result = (ActionResult)controller.EditAssessmentQuestion(assessmentViewModel); // Assert Assert.IsInstanceOfType(result, typeof(ViewResult)); Assert.AreEqual("Error", (result as ViewResult).ViewName); }
public void EditAssessmentQuestion_PostValid() { // Arrange var controller = new AssessmentController(_ITrainingService, _IAssessmentService); // Act AssessmentViewModel assessmentViewModel = new AssessmentViewModel(); assessmentViewModel.AssessmentPaper = new AssessmentPaperViewModel(); assessmentViewModel.AssessmentPaper.AssessmentPaperId = 1; assessmentViewModel.AssessmentQuestions = new List <AssessmentQuestionsViewModel>(); AssessmentQuestionsViewModel assessmentQuestionsViewModel = new AssessmentQuestionsViewModel(); assessmentQuestionsViewModel.QuestionId = 1; assessmentViewModel.AssessmentQuestions.Add(assessmentQuestionsViewModel); var result = (ActionResult)controller.EditAssessmentQuestion(assessmentViewModel); // Assert Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); RedirectToRouteResult routeResult = result as RedirectToRouteResult; Assert.AreEqual(routeResult.RouteValues["action"], "ShowAssessmentPaperDetails"); }