示例#1
0
        public async Task GetAuthorBookItems_EnterSearchTerm_ShouldReturnListOfBookItems()
        {
            _bookAPIService = new Mock <IBookAPIService>();
            var searchTerm = "Test";

            _bookAPIService.Setup(service => service.GetAuthorBooksAsync(searchTerm))
            .ReturnsAsync(GetTestBookItemList());
            var authorController = new AuthorController(_bookAPIService.Object, _mapper);

            var result = await authorController.GetAuthorBookItems(searchTerm);

            var okResult    = result.Result.Should().BeOfType <OkObjectResult>();
            var returnValue = result.Should().BeOfType <ActionResult <IEnumerable <Book> > >();
            var books       = (IEnumerable <Book>)((ObjectResult)returnValue.Subject.Result).Value;

            books.FirstOrDefault().Id.Should().Be("GSLCDwAAQBAJ");
        }