public void GivenUpdate_WhenUpdateExistBook_ShouldReturnBookListWithUpdatedBook() { // Arrange Book bookToDelete = new Book { Id = 1, Name = "The Lord of the Rings" }; var bookFileStorage = new BookFileStorage(_settings); // Act bookFileStorage.Update(bookToDelete); var books = bookFileStorage.GetAll(); // Assert books.Should().BeEquivalentTo(new List <Book> { 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" }, new Book { Id = 1, Name = "The Lord of the Rings" } }); }
public void GivenUpdate_WhenUpdateBookIsNull_ShouldReturnException() { // Arrange var bookFileStorage = new BookFileStorage(_settings); //Act TestDelegate testAction = () => bookFileStorage.Update(null); //Assert var ex = Assert.Throws <InvalidOperationException>(testAction); Assert.That(ex.Message, Is.EqualTo("Can not update null object!")); }
public void GivenUpdate_WhenUpdateNonExistBook_ShouldReturnException() { // Arrange var book = new Book { Id = 5, Name = "Herbert Schildt C#", IsArchive = false }; var bookFileStorage = new BookFileStorage(_settings); //Act TestDelegate testAction = () => bookFileStorage.Update(book); //Assert var ex = Assert.Throws <InvalidOperationException>(testAction); Assert.That(ex.Message, Is.EqualTo("There is not this item in the Item Storage!")); }