Example #1
0
        public void testBooksGetAuthorByBookId()
        {
            //Arrange
            var    BookRepoMockClass = new Mock <IBookRepo>();
            string expected          = "Huma";

            BookRepoMockClass.Setup(x => x.GetAuthorByBookId(2)).Returns(expected);
            var booksController = new BooksController(BookRepoMockClass.Object);

            //Act
            IHttpActionResult result = booksController.GetAuthorByBookId(2);
            var resultBook           = result as OkNegotiatedContentResult <string>;

            //Assert
            Assert.AreEqual(resultBook.Content, expected);
        }