public void Can_Fetch_All_Books() { var books = BooksApi.GetAll(); books.ShouldNotBeNull(); books.Any().ShouldBeTrue(); books.Where(b => string.IsNullOrEmpty(b.Title)).Any().ShouldBeFalse(); }
public async void GetBooks(string SearchString) { StringValidationMessage validated = ValidationHelper.ValidateSearchString(SearchText); List <Book> result = new List <Book>(); switch (validated) { case StringValidationMessage.StringIsGood: ErrorMessage = ""; string searchByType = SearchByTitle ? "title" : SearchByAuthor ? "author" : "title"; var retVal = await BooksApi.Search(this.SearchText, searchByType); bool ConnectionSuccesful = retVal.Item1; result = retVal.Item2; if (ConnectionSuccesful) { if (result.Count == 0) { ErrorMessage = "Your search query resulted 0 records"; } } else { ErrorMessage = retVal.Item3; } break; case StringValidationMessage.StringIsEmpty: ErrorMessage = "* Search text should not be empty"; break; case StringValidationMessage.StringLengthGreaterThanLimit: ErrorMessage = "* Search text should not be more than 50 characters (spaces not included)"; break; case StringValidationMessage.StringHasOnlyDigits: ErrorMessage = "* Search text should be alphnumeric"; break; case StringValidationMessage.StringHasDigitsAndSpaces: ErrorMessage = "* Search text should be alphanumeric (numbers with spaces not allowed)"; break; } BookList = new ObservableCollection <Book>(result); }
static void Main(string[] args) { var booksApi = new BooksApi(); var usersApi = new UsersApi(); try { foreach (var user in usersApi.GetUsers()) { Console.WriteLine(user); } foreach (var book in booksApi.GetBooks()) { Console.WriteLine(book); } } catch (Exception e) { Console.WriteLine("Exception when calling api: " + e.Message); } }
public void Init() { instance = new BooksApi(); }
public void Can_Fetch_All_Books() { var books = BooksApi.GetAll(); BooksValidator.AreValid(books).Valid.ShouldBeTrue(); }
public static List <Book> ParaViewModels(this BooksApi api) { var teste = api.Items.Select(x => Conversor(x)).ToList(); return(teste); }