public void addBookToUser_valid() { /// Arrange var userModel = new Friend { ID = 1, FirstName = "Sigga", LastName = "Jóns", Email = "*****@*****.**", Address = "laugavegur 1" }; var bookModel = new Book { ID = 2, Title = "Harry Potter and the chamber of secrets", FirstName = "J K", LastName = "Rowling", DatePublished = Convert.ToDateTime("02-07-1998"), ISBN = "234567890" }; /// Act _repo.AddBookToUser(1, 2); var book = _userService.GetBooksByUserId(1).Last(); /// Assert Assert.AreEqual(bookModel.Title, book.Title); Assert.AreEqual(bookModel.FirstName + " " + bookModel.LastName, book.Author); }
public Book AddBookToUser(int userId, int bookId) { var book = _repo.AddBookToUser(userId, bookId); if (book != null) { return(book); } else { return(null); } }