public void AddNewQuestion()
        {
            // Arrange
            var controller = new AssessmentController(_ITrainingService, _IAssessmentService);

            // Act
            int assessmentPaperId = 1;
            var result            = (ActionResult)controller.AddNewQuestion(assessmentPaperId);

            // Assert
            Assert.IsInstanceOfType(result, typeof(ViewResult));
            Assert.AreEqual("AddNewQuestion", ((ViewResult)result).ViewName);
        }
        public void AddNewQuestion_Post_NoQuestions()
        {
            // Arrange
            var controller = new AssessmentController(_ITrainingService, _IAssessmentService);

            //Initialize model
            AssessmentViewModel assessmentViewModel = new AssessmentViewModel();

            assessmentViewModel.AssessmentPaper = new AssessmentPaperViewModel();
            assessmentViewModel.AssessmentPaper.AssessmentPaperId = 1;

            //Act
            var result = (ActionResult)controller.AddNewQuestion(assessmentViewModel);

            //Assert
            Assert.IsInstanceOfType(result, typeof(ViewResult));
        }
        public void AddNewQuestion_Post_Valid()
        {
            // Arrange
            var controller = new AssessmentController(_ITrainingService, _IAssessmentService);

            //Initialize model
            AssessmentViewModel assessmentViewModel = new AssessmentViewModel();

            assessmentViewModel.AssessmentPaper = new AssessmentPaperViewModel();
            assessmentViewModel.AssessmentPaper.AssessmentPaperId = 1;
            assessmentViewModel.AssessmentQuestions = new List <AssessmentQuestionsViewModel>();
            AssessmentQuestionsViewModel assessmentQuestionsViewModel = new AssessmentQuestionsViewModel();

            assessmentQuestionsViewModel.QuestionId         = 0;
            assessmentQuestionsViewModel.Question           = "a";
            assessmentQuestionsViewModel.Option1Description = "a1";
            assessmentQuestionsViewModel.IsOption1Correct   = true;
            assessmentQuestionsViewModel.Option2Description = "a1";
            assessmentQuestionsViewModel.IsOption2Correct   = true;
            assessmentQuestionsViewModel.Option3Description = "a1";
            assessmentQuestionsViewModel.IsOption3Correct   = true;
            assessmentQuestionsViewModel.Option4Description = "a1";
            assessmentQuestionsViewModel.IsOption4Correct   = true;
            assessmentQuestionsViewModel.CreatedBy          = 1;
            assessmentQuestionsViewModel.CreatedOn          = DateTime.Now;
            assessmentQuestionsViewModel.LastEditedBy       = 1;
            assessmentQuestionsViewModel.LastEditedOn       = DateTime.Now;
            assessmentQuestionsViewModel.IsActive           = true;
            assessmentViewModel.AssessmentQuestions.Add(assessmentQuestionsViewModel);

            //Act
            var result = (ActionResult)controller.AddNewQuestion(assessmentViewModel);

            //Assert
            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
            RedirectToRouteResult routeResult = result as RedirectToRouteResult;

            Assert.AreEqual(routeResult.RouteValues["action"], "ShowAssessmentPaperDetails");
        }