public void GetByTitle_WithValidTitle_ReturnsOneBook()
        {
            detailsMock.Setup(d => d.FindBooksByTitle(bookTest.VolumeInfo.Title, 0, 10)).Returns(new BooksData { TotalItems = 1, Items = new List<BookData>() { bookTest } });

            BookController sut = new BookController(detailsMock.Object);
            List<BookData> actual = sut.GetByTitle(bookTest.VolumeInfo.Title);

            Assert.AreEqual(1, actual.Count);
            Assert.AreSame(bookTest, actual[0]);
        }
        public void GetByTitle_WithEmptyTitle_ThrowBadRequest()
        {
            HttpResponseException exception = null;

            try
            {
                BookController sut = new BookController(detailsMock.Object);
                List<BookData> actual = sut.GetByTitle(null);
            }
            catch (HttpResponseException ex)
            {
                exception = ex;
            }
            Assert.IsNotNull(exception);
            Assert.AreEqual(HttpStatusCode.BadRequest, exception.Response.StatusCode);
        }
        public void GetByTitle_WithNonExistingTitle_ThrowNotFound()
        {
            string nonExistingTitle = "What is this";
            detailsMock.Setup(d => d.FindBooksByTitle(nonExistingTitle, 0, 10)).Returns(new BooksData());
            HttpResponseException exception = null;

            try
            {
                BookController sut = new BookController(detailsMock.Object);
                var actual = sut.GetByTitle(nonExistingTitle);
            }
            catch (HttpResponseException ex)
            {
                exception = ex;
            }
            Assert.IsNotNull(exception);
            Assert.AreEqual(HttpStatusCode.NotFound, exception.Response.StatusCode);
        }
        public void GetByTitle_WithValidTitle_ReturnsTwoBooks()
        {
            BookData bookTest2 = bookTest;
            bookTest2.VolumeInfo.Title += " Version1";
            List<BookData> expected = new List<BookData>() { bookTest, bookTest2 };
            detailsMock.Setup(d => d.FindBooksByTitle(bookTest.VolumeInfo.Title, 0, 10)).Returns(new BooksData { TotalItems = 2, Items = expected });

            BookController sut = new BookController(detailsMock.Object);
            List<BookData> actual = sut.GetByTitle(bookTest.VolumeInfo.Title);

            Assert.AreEqual(2, actual.Count);
            Assert.AreSame(expected, actual);
        }