Esempio n. 1
0
        public void TestDetailNotFound()
        {
            // Arrange
            BookController controller = new BookController();

            // Act
            ViewResult result = controller.Details(-15) as ViewResult;

            // Assert
            Assert.IsNull(result);
        }
Esempio n. 2
0
        public void TestDetailView()
        {
            // Arrange
            BookController controller = new BookController();

            // Act
            ViewResult result = controller.Details(1) as ViewResult;

            // Assert
            Assert.AreEqual("Details", result.ViewName);
        }
Esempio n. 3
0
        public void TestDetailsViewData()
        {
            // Arrange
            BookController controller = new BookController();

            // Act
            ViewResult result  = controller.Details(1) as ViewResult;
            BookTbl    product = (BookTbl)result.ViewData.Model;

            // Assert
            Assert.AreEqual(1, product.Id);
        }
Esempio n. 4
0
        public void Details_ModelIsABookObject()
        {
            // arrange
            var bookRep = new Mock <IRepository <Book> >();

            bookRep.Setup(m => m.Get(It.IsAny <QueryOptions <Book> >()))
            .Returns(new Book {
                BookAuthors = new List <BookAuthor>()
            });

            var unit = new Mock <IBookstoreUnitOfWork>();

            unit.Setup(m => m.Books).Returns(bookRep.Object);

            var controller = new BookController(unit.Object);

            // act
            var model = controller.Details(1).ViewData.Model as Book;

            // assert
            Assert.IsType <Book>(model);
        }