public void GetBooksServiceTest() { var result = _bookApi.Search(Arg.Any <string>(), Arg.Any <int>(), Arg.Any <int>()).Result; _bookService.Volumes.Received(1); _bookService.Volumes.List(Arg.Any <string>()).Received(1); _listRequest.Received(1).Execute(); Assert.Equal(Books[0].Authors, result.Item2[0].Authors); }
public async Task <IEnumerable <Book> > Search(string query, int offset = 0) { try { if (string.IsNullOrEmpty(query)) { return(null); } var result = await _bookApi.Search(query, offset); return(result.Item2); } catch (Exception ex) { // Todo: do some stuff to track the message in ELK or some other logging system.. throw new FriendlyUiException("Search Failed!"); } }
public BookControllerTests() { _bookapi = Substitute.For <IBookApi>(); _bookapi.Search(Arg.Any <string>(), Arg.Any <int>(), Arg.Any <int>()).ReturnsForAnyArgs(_bookList); _booksController = new BooksController(_bookapi); }