public void Can_Show_Book_Details()
        {
            BookController bookCtrl = new BookController(bookRepo);
            Book           book1    = (Book)bookCtrl.Detail(3).Model;
            Book           book2    = (Book)bookCtrl.Detail(5).Model;
            Book           book3    = (Book)bookCtrl.Detail(9).Model;

            Assert.AreEqual("America History", book1.Name);
            Assert.AreEqual("Iron Man", book2.Name);
            Assert.AreEqual("Web API", book3.Name);
        }
        public void Can_Generate_Error_For_Book_Details()
        {
            BookController bookCtrl = new BookController(bookRepo);
            var            model    = bookCtrl.Detail(12);

            Error error = model.ViewData.Model as Error;

            Assert.IsNotNull(error);
            Assert.AreEqual("Can't Find the Book", error.Message);
        }
Esempio n. 3
0
        public void Invoke_BookServiceMethod_GetById_WhenPassedId_IsNotNull()
        {
            // Arrange
            var bookServiceMock = new Mock <IBookServices>();
            var sut             = new BookController(bookServiceMock.Object);

            // Act
            sut.Detail(Guid.NewGuid());

            // Assert
            bookServiceMock.Verify(b => b.GetById(It.IsAny <Guid>()), Times.Once);
        }