Ejemplo n.º 1
0
        public async Task GetNotEnrolledExamsForUserAsync_ValidRequest_ReturnsOkObjectResult()
        {
            var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
            {
                new Claim(ClaimTypes.NameIdentifier, "1"),
            }));
            var mapperMock     = new Mock <IMapper>();
            var repositoryMock = new Mock <IRepositoryWrapper>();


            repositoryMock.Setup(r => r.ExamRepository.GetNotEnrolledExamsForUserAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())).ReturnsAsync(new PagedList <Exam>(new List <Exam>(), 1, 1, 1));
            mapperMock.Setup(m => m.Map <IEnumerable <ExamForListDto> >(It.IsAny <PagedList <Exam> >())).Returns(new List <ExamForListDto>());



            var controllerMock = new ExamsController(repositoryMock.Object, mapperMock.Object);

            controllerMock.ControllerContext = new ControllerContext()
            {
                HttpContext = new DefaultHttpContext()
                {
                    User = user
                }
            };
            var result = await controllerMock.GetNotEnrolledExamsForUserAsync(1, 1);

            Assert.IsType <OkObjectResult>(result);
        }