Ejemplo n.º 1
0
        public void All_ShouldReturnView()
        {
            // Arrange
            Mock <IPublicationService> publicationService = new Mock <IPublicationService>();
            ListPublicationsViewModel  listModel          = this.GetListPublicationsViewModel();

            publicationService
            .Setup(p => p.Total())
            .Returns(20);

            publicationService
            .Setup(p => p.All(It.IsAny <int>(), It.IsAny <int>()))
            .Returns(this.GetPublications());

            PublicationsController publicationsController =
                new PublicationsController(null, null, null, publicationService.Object, null);

            // Act
            IActionResult result = publicationsController.All(2);

            // Assert
            Assert.IsType <ViewResult>(result);
            object model = (result as ViewResult).Model;

            Assert.IsType <ListPublicationsViewModel>(model);
            ListPublicationsViewModel returnModel = model as ListPublicationsViewModel;

            this.AssertPages(listModel, returnModel);
            this.AssertListPublicationsViewModel(listModel, returnModel);
        }