public void GivenValidToReadDetails_WhenAddBookToBookShelf_ReturnToBookProfile()
        {
            using (var scope = Container.BeginLifetimeScope())
            {
                // Arrange
                _bookController = scope.Resolve <BooksController>();
                BookService bookService = scope.Resolve <BookService>();

                ToRead toRead = new ToRead();
                toRead.UserId = 289;
                toRead.BookId = 11;


                // Act
                var result = _bookController.AddBookToBookShelf(toRead) as RedirectToRouteResult;

                // Assert
                Assert.IsNotNull(result);
                var values = result.RouteValues.Values;

                Assert.IsTrue(values.Contains(11));
                Assert.IsTrue(values.Contains(controllerName));
                Assert.IsTrue(values.Contains("BookProfile"));

                Assert.IsTrue(bookService.RemoveBookFromToRead(toRead)); // undo creation addition to database
            }
        }
        public void GivenValidToReadDetails_WhenDeleteBookFromBookShelf_ReturnToBookProfile()
        {
            using (var scope = Container.BeginLifetimeScope())
            {
                // Arrange
                _bookController = scope.Resolve <BooksController>();
                BookService bookService = scope.Resolve <BookService>();

                ToRead toRead = new ToRead();
                toRead.UserId = 289;
                toRead.BookId = 11;

                _bookController.AddBookToBookShelf(toRead);

                // Act
                var result = _bookController.DeleteBookFromBookShelf(toRead) as RedirectToRouteResult;

                // Assert
                Assert.IsNotNull(result);
                var values = result.RouteValues.Values;

                Assert.IsTrue(values.Contains(11));
                Assert.IsTrue(values.Contains(controllerName));
                Assert.IsTrue(values.Contains("BookProfile"));
                Assert.IsNull(bookService.GetABookReview(289, 11)); // cleanup, assert it's been successful
            }
        }
        public void GivenInvalidToReadDetails_WhenAddToBookShelfCalled_ReturnToBookProfile()
        {
            // Arrange
            var fakeBookToRead = A.Fake <ToRead>();

            fakeBookToRead.BookId = -1;
            fakeBookToRead.UserId = -10;

            A.CallTo(() => _fakeBookService.AddBookToReadShelf(fakeBookToRead)).Returns(false);

            // Act
            var result = _bookController.AddBookToBookShelf(fakeBookToRead) as RedirectToRouteResult;

            // Assert
            Assert.IsNotNull(result);
            var values = result.RouteValues.Values;
            var bookId = values.ElementAt(0);

            Assert.AreEqual(bookId, fakeBookToRead.BookId);
            Assert.IsTrue(values.Contains(controllerName));
            Assert.IsTrue(values.Contains(actionCalledBookProfile));

            A.CallTo(() => _fakeBookService.AddBookToReadShelf(fakeBookToRead)).MustHaveHappened(Repeated.Exactly.Once);
        }