public void Throw_When_Passed_Book_Is_Null() { // Arrange IBookServices sut = new BookServices(repository, saveChanges); Book nullBook = null; // Act & Assert Assert.Throws <ArgumentNullException>(() => sut.DeleteBookById(nullBook)); }
public void Remove_Book_With_Exact_Id() { // Arrange IBookServices sut = new BookServices(repository, saveChanges); sut.AddBook(book); // Act sut.DeleteBookById(book.Id); // Assert CollectionAssert.DoesNotContain(dbContext.Books, book); }
public void BeCalledOnce_IfPassedBookIsValid() { // Arrange var dbSetMock = new Mock <ILibrarySystemEfWrapper <Book> >(); var saveChangesMock = new Mock <ILibrarySystemEfDbContextSaveChanges>(); var bookServices = new BookServices(dbSetMock.Object, saveChangesMock.Object); var bookToDeleteMock = new Mock <Book>(); // Act bookServices.AddBook(bookToDeleteMock.Object); bookServices.DeleteBookById(bookToDeleteMock.Object.Id); // Assert dbSetMock.Verify(r => r.Delete(bookToDeleteMock.Object.Id), Times.Once); }