public void BookControllerTest() { var repository = new Mock <IBookRepository>(); var controller = new BookController(repository.Object); controller.Book(); repository.Verify(repo => repo.GetAll(), Times.Once); var result = controller.Book(); // Assert var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <IEnumerable <BookVM> >(viewResult.ViewData.Model); }