public async void CreateInGenreRelationship_Test() { // Arrange var newBook = CreateBook(); await _bookRepository.AddOrUpdateAsync(newBook); var newGenre = CreateGenre(); await _genreRepository.AddOrUpdateGenreAsync(newGenre); var inGenre = new Relationships.InGenre(); // Act await _genreRepository.CreateInGenreRelationshipAsync(newGenre, newBook, inGenre); var returnedBook = (await _genreRepository.GetInGenreBookRelationshipAsync(newGenre, inGenre)) .ToList().FirstOrDefault(); // Assert Assert.True(newBook.Title == returnedBook.Title); // Clean up await _genreRepository.DeleteInGenreRelationshipAsync(newGenre, newBook, inGenre); await _bookRepository.DeleteBookAsync(newBook); await _genreRepository.DeleteGenreAsync(newGenre); }
public async Task <IActionResult> AddUpdateBookAsync(Book book) { await _bookRepository.AddOrUpdateAsync(book); foreach (var genre in book.Genres) { await _genreRepository.CreateInGenreRelationshipAsync(genre, book, new Relationships.InGenre()); } return(Ok()); }
public async void PopularLibrary_Test() { //Arrange var newPerson = CreatePerson(); await _personRepository.AddPersonAsync(newPerson); var newPerson2 = CreatePerson(); await _personRepository.AddPersonAsync(newPerson2); var newPerson3 = CreatePerson(); await _personRepository.AddPersonAsync(newPerson3); var newBook = CreateBook(); await _bookRepository.AddOrUpdateAsync(newBook); var newBook2 = CreateBook(); await _bookRepository.AddOrUpdateAsync(newBook2); var newBook3 = CreateBook(); await _bookRepository.AddOrUpdateAsync(newBook3); var inLibrary = new Relationships.InLibrary(); await _bookRepository.CreateInLibraryRelationshipAsync(newBook, newPerson, inLibrary); await _bookRepository.CreateInLibraryRelationshipAsync(newBook2, newPerson, inLibrary); await _bookRepository.CreateInLibraryRelationshipAsync(newBook3, newPerson, inLibrary); await _bookRepository.CreateInLibraryRelationshipAsync(newBook2, newPerson2, inLibrary); await _bookRepository.CreateInLibraryRelationshipAsync(newBook3, newPerson2, inLibrary); await _bookRepository.CreateInLibraryRelationshipAsync(newBook3, newPerson3, inLibrary); //Act var query = (await _recommendationRepository.PopularLibrarys()); //Assert Assert.NotNull(query); //Cleanup await _bookRepository.DeleteInLibraryRelationshipAsync(newBook, newPerson, inLibrary); await _bookRepository.DeleteInLibraryRelationshipAsync(newBook2, newPerson, inLibrary); await _bookRepository.DeleteInLibraryRelationshipAsync(newBook3, newPerson, inLibrary); await _bookRepository.DeleteInLibraryRelationshipAsync(newBook2, newPerson2, inLibrary); await _bookRepository.DeleteInLibraryRelationshipAsync(newBook3, newPerson2, inLibrary); await _bookRepository.DeleteInLibraryRelationshipAsync(newBook3, newPerson3, inLibrary); await _bookRepository.DeleteBookAsync(newBook); await _bookRepository.DeleteBookAsync(newBook2); await _bookRepository.DeleteBookAsync(newBook3); await _personRepository.DeletePersonAsync(newPerson); await _personRepository.DeletePersonAsync(newPerson2); await _personRepository.DeletePersonAsync(newPerson3); }
public async void GetBookAsync_Test() { // Arrange var book1 = CreateBook(); var book2 = CreateBook(); await _bookRepository.AddOrUpdateAsync(book1); await _bookRepository.AddOrUpdateAsync(book2); // Act var books = await _bookRepository.GetAllBooksAsync(); // Assert Assert.True(books != null); // Clean up await _bookRepository.DeleteBookAsync(book1); await _bookRepository.DeleteBookAsync(book2); }