public void CreateBook_Maps_All_Properties_ToEntity_Object() { var libraryDbContext = Substitute.For<ILibraryDbContext>(); libraryDbContext.Books = Substitute.For<IDbSet<Book>>(); var library = new LibraryService(libraryDbContext); string expectedTitle = "book title"; BookSubmitModel bookSubmitModel = new BookSubmitModel() { Title = expectedTitle }; library.CreateBook(bookSubmitModel); libraryDbContext.Books.Received().Add(Arg.Is<Book>(b => b.Title == expectedTitle)); }
public void CreateBook(BookSubmitModel bookSubmitModel) { _libraryDbContext.Books.Add(new Book() {Title = bookSubmitModel.Title}); _libraryDbContext.SaveChanges(); }
public JsonResult Save(BookSubmitModel model) { _libraryService.CreateBook(model); return new JsonResult(){Data = ""}; }