Ejemplo n.º 1
0
        public async Task GetAll_ReturnsAllItemsByCategory()
        {
            // Arrange

            int countItemsByCategoryPerPage = 1;
            var mock = new Mock <INewsService>();

            mock.Setup(repo => repo.GetAll()).Returns(GetPosts());

            NewsController controller = new NewsController(mock.Object);

            // Act
            var okResult = (await controller.GetAll(new Pagination()
            {
                QuantityPerPage = 1, Page = 1
            }, CategoryMode.Repair))
                           .Result as OkObjectResult;

            // Assert
            var items = Assert.IsType <List <NewsPost> >(okResult.Value);

            Assert.Equal(countItemsByCategoryPerPage, items.Count);
        }