public async Task UpdateBook_NullBook_RaiseArgumentNullException()
        {
            // Arrange
            var bookCommandService = new BookCommandService(_mockedBooksDbContext, _mockedMapper);

            // Act and Assert
            await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => bookCommandService.UpdateBook(ValidId, null));
        }
示例#2
0
 public ActionResult Edit(Book book)
 {
     if (book.Title == null || book.Author == null || book.Description == null || book.ISBN == null)
     {
         throw new Exception("书名|作者|描述|ISBN不能为空");
     }
     comnandService.UpdateBook(book.AggregateRootId, book.Title, book.Author, book.Description, book.ISBN, book.Pages, book.Inventory);
     return(RedirectToAction("List"));
 }
        public async Task UpdateBook_ValidBook_ReturnTrue()
        {
            // Arrange
            var bookCommandService = new BookCommandService(_mockedBooksDbContext, _mockedMapper);
            var bookDto            = new BookDto
            {
                Title       = "Advanced C#",
                Author      = "Guilherme Couto",
                Isbn        = "12345",
                Price       = 50,
                PublishDate = DateTime.Now
            };

            // Act
            var result = await bookCommandService.UpdateBook(ValidId, bookDto);

            // Assert
            Assert.IsTrue(result);
        }