public async Task CreateBook_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 try { var id = await bookCommandService.CreateBook(bookDto); // Assert Assert.IsTrue(id > 0); } catch (Exception error) { Console.WriteLine(error.Message); } }
public async Task UpdateBook_NullBook_RaiseArgumentNullException() { // Arrange var bookCommandService = new BookCommandService(_mockedBooksDbContext, _mockedMapper); // Act and Assert await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => bookCommandService.UpdateBook(ValidId, null)); }
public async Task DeleteBook_InvalidId_RaiseArgumentException(int id) { // Arrange var bookCommandService = new BookCommandService(_mockedBooksDbContext, _mockedMapper); // Act and Assert await Assert.ThrowsExceptionAsync <ArgumentException>(() => bookCommandService.DeleteBook(id)); }
public async Task UnpublishBook_InvalidId_RaiseArgumentException(int id) { // Arrange var bookCommandService = new BookCommandService(_mockedBooksDbContext, _mockedMapper); // Act var result = await bookCommandService.UnpublishBook(InvalidId); // Assert Assert.IsFalse(result); }
public async Task UnpublishBook_ValidId_ReturnTrue() { // Arrange var bookCommandService = new BookCommandService(_mockedBooksDbContext, _mockedMapper); // Act var result = await bookCommandService.UnpublishBook(ValidId); // Assert Assert.IsTrue(result); }
public async Task DeleteBook_InvalidId_ReturnFalse(int id) { // Arrange var bookCommandService = new BookCommandService(_mockedBooksDbContext, _mockedMapper); // Act var sucess = await bookCommandService.DeleteBook(id); // Assert Assert.IsFalse(sucess); }
public async Task DeleteBook_ValidId_ReturnTrue() { // Arrange var bookCommandService = new BookCommandService(_mockedBooksDbContext, _mockedMapper); // Act var sucess = await bookCommandService.DeleteBook(ValidId); // Assert Assert.IsTrue(sucess); }
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); }
public ActionResult Index() { UserComnandService userService = new UserComnandService(); //userService.RegisterUser("taylorchen", "123456", "赎罪", "*****@*****.**", "15099907289", "中国", "State", "Street", "ShenZhen", "518000"); //userService.UpdateUser(new Guid("42991D99-CDAA-45EA-9C9C-C101DCEA3051"), "赎罪_test", "*****@*****.**", "15099907289", "中国", "State", "Street", "ShenZhen", "518000"); BookCommandService bookService = new BookCommandService(); //bookService.AddBook("人类简史", "无", "无", "无", 150, 10); //bookService.UpdateBook(new Guid("F6151D14-3EF4-497A-8EBF-6D3856604E1B"), "测试书籍", "无", "无", "无", 150, 10); //userService.BorrowBookToUser(new Guid("42991D99-CDAA-45EA-9C9C-C101DCEA3051"), new Guid("F6151D14-3EF4-497A-8EBF-6D3856604E1B")); //userService.ReturnBookFromUser(new Guid("42991D99-CDAA-45EA-9C9C-C101DCEA3051"), new Guid("F6151D14-3EF4-497A-8EBF-6D3856604E1B")); return(View()); }