public async void CreateInLibraryRelationship_Test() { // Arrange var newBook = CreateBook(); await _bookRepository.AddOrUpdateAsync(newBook); var newPerson = CreatePerson(); await _personRepository.AddPersonAsync(newPerson); var inLibrary = new Relationships.InLibrary(); // Act await _bookRepository.CreateInLibraryRelationshipAsync(newBook, newPerson, inLibrary); var returnedPerson = (await _bookRepository.GetInLibraryPersonRelationshipAsync(newBook, inLibrary)) .ToList().FirstOrDefault(); // Assert Assert.True(newPerson.Name == returnedPerson.Name); // Clean up await _bookRepository.DeleteInLibraryRelationshipAsync(newBook, newPerson, inLibrary); await _bookRepository.DeleteBookAsync(newBook); await _personRepository.DeletePersonAsync(newPerson); }
public async void JaccardLibraryRecommendation_Test() { //Arrange var newPerson = CreatePerson(); await _personRepository.AddPersonAsync(newPerson); var newPerson2 = CreatePerson(); await _personRepository.AddPersonAsync(newPerson2); 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, newPerson2, inLibrary); await _bookRepository.CreateInLibraryRelationshipAsync(newBook2, newPerson2, inLibrary); await _bookRepository.CreateInLibraryRelationshipAsync(newBook3, newPerson2, inLibrary); await _bookRepository.CreateInLibraryRelationshipAsync(newBook, newPerson, inLibrary); var wishList = new Relationships.WishList(); await _bookRepository.CreateWishlistRelationshipAsync(newBook2, newPerson, wishList); //Act var returnedBook = (await _recommendationRepository.GetJaccardLibrary(p => p.Name == newPerson.Name)); //Assert Assert.NotNull(returnedBook); //Cleanup await _bookRepository.DeleteInLibraryRelationshipAsync(newBook, newPerson2, inLibrary); await _bookRepository.DeleteInLibraryRelationshipAsync(newBook2, newPerson2, inLibrary); await _bookRepository.DeleteInLibraryRelationshipAsync(newBook3, newPerson2, inLibrary); await _bookRepository.DeleteInLibraryRelationshipAsync(newBook, newPerson, inLibrary); await _bookRepository.DeleteWishListRelationshipAsync(newBook2, newPerson, wishList); await _bookRepository.DeleteBookAsync(newBook); await _bookRepository.DeleteBookAsync(newBook2); await _bookRepository.DeleteBookAsync(newBook3); await _personRepository.DeletePersonAsync(newPerson); await _personRepository.DeletePersonAsync(newPerson2); }
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); }