Ejemplo n.º 1
0
        public async Task <ActionResult <IEnumerable <ToDoRestModel> > > Get([FromQuery] int page)
        {
            string userId   = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var    pageSize = await Request.GetPageSizePagination(Response, () => _toDoService.CountAsync(userId));

            var todos = await _toDoService.GetPageAsync(userId, page, pageSize);

            return(Ok(_mapper.Map <IList <ToDoRestModel> >(todos)));
        }
Ejemplo n.º 2
0
        public async Task CountAsync_ShouldCallRepository()
        {
            var userId = "sadadasdad";
            var data   = new List <ToDo> {
                new ToDo {
                    UserId = userId
                },
                new ToDo {
                    UserId = userId
                },
                new ToDo(),
            }
            .AsQueryable()
            .BuildMock();

            _toDoRepositoryMock.Setup(x => x.GetQueryable()).Returns(data.Object);

            var result = await _toDoService.CountAsync(userId);

            _toDoRepositoryMock.Verify(x => x.GetQueryable(), Times.Once);
            Assert.Equal(2, result);
        }