public async Task Students_ShouldReturnRedirectToAction_GivenInvalidUser()
        {
            // Arrange
            var courseService = CourseServiceMock.GetMock;

            courseService.Exists(true);

            var userManager = UserManagerMock.GetMock;

            userManager.GetUserId(null);

            var controller = new TrainersController(
                userManager.Object,
                certificateService: null,
                courseService.Object,
                examService: null,
                trainerService: null)
            {
                TempData = TempDataMock.GetMock
            };

            // Act
            var result = await controller.Students(TestCourseId);

            // Assert
            controller.TempData.AssertErrorMsg(WebConstants.InvalidUserMsg);

            this.AssertRedirectToTrainersControllerIndex(result);

            courseService.Verify();
            userManager.Verify();
        }
        public async Task Students_ShouldReturnViewResultWithCorrectModel_GivenValidInput()
        {
            // Arrange
            var testCourse = Tests.GetCourseServiceModelCollection().FirstOrDefault();

            var courseService = CourseServiceMock.GetMock;

            courseService.Exists(true);

            var userManager = UserManagerMock.GetMock;

            userManager.GetUserId(TestUserId);

            var trainerService = TrainerServiceMock.GetMock;

            trainerService
            .IsTrainerForCourseAsync(true)
            .CourseByIdAsync(testCourse)
            .StudentsInCourseAsync(this.GetStudentInCourseServiceModelCollection());

            var controller = new TrainersController(
                userManager.Object,
                certificateService: null,
                courseService.Object,
                examService: null,
                trainerService.Object);

            // Act
            var result = await controller.Students(TestCourseId);

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsType <StudentCourseGradeViewModel>(viewResult.Model);

            Assert.NotNull(model);
            Tests.AssertCourseServiceModel(testCourse, model.Course);
            this.AssertStudentsInCourse(model.Students);

            courseService.Verify();
            trainerService.Verify();
            userManager.Verify();
        }