public void IsGettingAllUsersBooks() { int result = userBookServices.GetAllUsersBooks().Count; int expected = 4; Assert.That(result, Is.EqualTo(expected)); }
public void IsAddingCorrectBookToUser() { Book book = db.Books.FirstOrDefault(b => b.Id == 4); User user = db.Users.FirstOrDefault(u => u.Id == 2); userBookServices.AddBookToUser(user, book); bool isRightBookAdded = userBookServices .GetAllUsersBooks() .Exists(ub => ub.UserId == user.Id && ub.BookId == book.Id); int a = userBookServices .GetAllUsersBooks().Count(); Assert.IsTrue(isRightBookAdded); }
public void IsRemovingBookFromUser() { User user = db.Users.FirstOrDefault(u => u.Id == 2); Book book = db.Books.FirstOrDefault(b => b.Id == 3); userBookServices.RemoveBookFromUser(user, book); bool doesExist = userBookServices .GetAllUsersBooks() .Exists(ub => ub.UserId == user.Id && ub.BookId == book.Id); Assert.IsFalse(doesExist); }