public void GivenDelete_WhenDeleteBookIsNull_ShouldReturnException()
        {
            // Arrange
            var bookFileStorage = new BookFileStorage(_settings);

            //Act
            TestDelegate testAction = () => bookFileStorage.Delete(null);

            //Assert
            var ex = Assert.Throws <InvalidOperationException>(testAction);

            Assert.That(ex.Message, Is.EqualTo("Can not delete null object!"));
        }
        public void GivenDelete_WhenDeleteNonExistBook_ShouldReturnException()
        {
            // Arrange
            var book = new Book {
                Id = 5, Name = "Herbert Schildt C#", IsArchive = false
            };

            var bookFileStorage = new BookFileStorage(_settings);

            //Act
            TestDelegate testAction = () => bookFileStorage.Delete(book);

            //Assert
            var ex = Assert.Throws <InvalidOperationException>(testAction);

            Assert.That(ex.Message, Is.EqualTo("There is not this item in the Item Storage!"));
        }
        public void Delete_WhenDeleteExistBook_ShouldReturnBookListWithoutDeletedBook()
        {
            // Arrange
            Book bookToDelete = new Book {
                Id = 4, Name = "The Hobbit"
            };

            var bookFileStorage = new BookFileStorage(_settings);

            // Act
            var booksBeforeDelete = bookFileStorage.GetAll();

            bookFileStorage.Delete(bookToDelete);
            var booksAfterDelete = bookFileStorage.GetAll();

            // Assert
            booksBeforeDelete.Should().BeEquivalentTo(new List <Book>
            {
                new Book {
                    Id = 1, Name = "The Lord of the Rings"
                },
                new Book {
                    Id = 2, Name = "Le Petit Prince"
                },
                new Book {
                    Id = 3, Name = "Harry Potter and the Philosopher's Stone"
                },
                new Book {
                    Id = 4, Name = "The Hobbit"
                }
            });
            booksAfterDelete.Should().BeEquivalentTo(new List <Book>
            {
                new Book {
                    Id = 1, Name = "The Lord of the Rings"
                },
                new Book {
                    Id = 2, Name = "Le Petit Prince"
                },
                new Book {
                    Id = 3, Name = "Harry Potter and the Philosopher's Stone"
                },
            });
        }