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