Exemple #1
0
        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));
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }