public void IsGettingAllUsersBooks()
        {
            int result   = userBookServices.GetAllUsersBooks().Count;
            int expected = 4;

            Assert.That(result, Is.EqualTo(expected));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }