public void Get_GivenBookIdOutOfRange_ThrowError() { // Arrange var bookLibrary = new BookLibrary(); bookLibrary.Add("A Tale of Two Cities"); bookLibrary.Add("Fellowship of the Ring"); bookLibrary.Add("Pride and Prejudice and Zombies"); // Act Assert.Throws <KeyNotFoundException>(() => bookLibrary.Get(5)); }
public void Delete_GivenBookId_RemovesBookFromLibrary() { // Arrange var bookLibrary = new BookLibrary(); bookLibrary.Add("A Tale of Two Cities"); bookLibrary.Add("Fellowship of the Ring"); bookLibrary.Add("Pride and Prejudice and Zombies"); // Act bookLibrary.Delete(1); // Assert Assert.Throws <KeyNotFoundException>(() => bookLibrary.Get(1)); }
public void Get_GivenBookId_ReturnSpecifiedBook() { // Arrange var bookLibrary = new BookLibrary(); var expectedBookTitle = "Fellowship of the Ring"; bookLibrary.Add("A Tale of Two Cities"); bookLibrary.Add(expectedBookTitle); bookLibrary.Add("Pride and Prejudice and Zombies"); // Act var actual = bookLibrary.Get(1); // Assert actual.Title.Should().Be(expectedBookTitle); }
public void AddRating_GivenValidBookIdAndRating_AddsRatingToBook() { // Arrange var expectedRating = 5; var bookLibrary = new BookLibrary(); bookLibrary.Add("A Tale of Two Cities"); bookLibrary.Add("Fellowship of the Ring"); bookLibrary.Add("Pride and Prejudice and Zombies"); // Act bookLibrary.AddRating(1, expectedRating); // Assert var actual = bookLibrary.Get(1); actual.Rating.Should().Be(expectedRating); }
public void Edit_GivenBookIdAndNewTitle_ChangesBookId() { // Arrange var bookLibrary = new BookLibrary(); var expectedBookTitle = "War and Peace"; bookLibrary.Add("A Tale of Two Cities"); bookLibrary.Add("Fellowship of the Ring"); bookLibrary.Add("Pride and Prejudice and Zombies"); // Act bookLibrary.Edit(1, expectedBookTitle); // Assert var actual = bookLibrary.Get(1); actual.Title.Should().Be(expectedBookTitle); }
public Book GetById(int id) { return(_memoryBookLibrary.Get(id)); }