public void GivenAdd_WhenAddBook_ShouldReturnBooksListWithNewBook() { // Arrange Book bookToAdd = new Book { Name = "Herbert Schildt C#" }; var bookFileStorage = new BookFileStorage(_settings); // Act bookFileStorage.Add(bookToAdd); var books = bookFileStorage.GetAll(); // Assert books.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" }, new Book { Id = 5, Name = "Herbert Schildt C#" } }); }
public void GivenAdd_WhenBookIsNull_ShouldReturnException() { // Arrange var bookFileStorage = new BookFileStorage(_settings); //Act TestDelegate testAction = () => bookFileStorage.Add(null); //Assert var ex = Assert.Throws <InvalidOperationException>(testAction); Assert.That(ex.Message, Is.EqualTo("Can not add null object!")); }