Ejemplo n.º 1
0
         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));
         }
Ejemplo n.º 2
0
 public void CreateBook(BookSubmitModel bookSubmitModel)
 {
     _libraryDbContext.Books.Add(new Book() {Title = bookSubmitModel.Title});
     _libraryDbContext.SaveChanges();
 }
Ejemplo n.º 3
0
 public JsonResult Save(BookSubmitModel model)
 {
     _libraryService.CreateBook(model);
     return new JsonResult(){Data = ""};
 }