public async Task Test_GetAllAuthors() { // Arrange var author = new Author { Id = Guid.NewGuid(), Name = "Author Test 1", Email = "*****@*****.**", BirthPlace = "Beijing" }; var authorDto = new AuthorDto() { Id = author.Id, Name = author.Name, BirthPlace = author.BirthPlace, Email = author.Email }; var authorList = new List <Author> { author }; var authorDtoList = new List <AuthorDto> { authorDto }; var parameters = new AuthorResourceParameters(); var authors = new PagedList <Author>(authorList, totalCount: authorList.Count, pageNumber: parameters.PageNumber, pageSize: parameters.PageSize); _mockRepositoryWrapper.Setup(m => m.Author.GetAllAsync(It.IsAny <AuthorResourceParameters>())) .Returns(Task.FromResult(authors)); _mockMapper.Setup(m => m.Map <IEnumerable <AuthorDto> >(It.IsAny <IEnumerable <Author> >())) .Returns(authorDtoList); _mockUrlHelper.Setup(m => m.Link(It.IsAny <string>(), It.IsAny <object>())) .Returns("demo url"); _authorController.Url = _mockUrlHelper.Object; // Act var actionResult = await _authorController.GetAuthorsAsync(parameters); // Assert ResourceCollection <AuthorDto> resourceCollection = actionResult.Value; Assert.True(1 == resourceCollection.Items.Count); Assert.Equal(authorDto, resourceCollection.Items[0]); Assert.True(_authorController.Response.Headers.ContainsKey("X-Pagination")); }