Esempio n. 1
0
        public void BorrowBookAction_BookBALIsCalled()
        {
            // Arrange
            var bookBALMoq = new Mock <IBookService>();

            bookBALMoq.Setup(x => x.BorrowBook(It.IsAny <int>(), fakeUser.Id)).Returns(() => true);

            BooksController bookController = CreateControllerWithFakeUser(bookBALMoq.Object);

            // Act
            var result = bookController.BorrowBook(1) as RedirectToRouteResult;

            // Assert
            bookBALMoq.Verify(x => x.BorrowBook(It.IsAny <int>(), fakeUser.Id), Times.Once);
            Assert.IsTrue(result != null);
        }