示例#1
0
        public void Index_Get_ReturnsHomePageViewModel()
        {
            // Arrange
            const int homePageId = 1;

            var controller = new HomePageController
            {
                ApplicationService = ApplicationServiceMock.Object,
                MapModelService    = new MapModelService()
            };

            var homePage = new HomePage {
                Id = homePageId
            };

            ApplicationServiceMock.Setup(x => x.GetPageModel <HomePage>(DocTypeAliases.HomePage.Alias)).Returns(homePage);

            var homePageViewModel = controller.MapModelService.Map <HomePageViewModel>(homePage);

            // Act
            var result = controller.Index() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsAssignableFrom <HomePageViewModel>(result.Model);
            Assert.AreEqual(homePageViewModel.Id, ((HomePageViewModel)result.Model).Id);
        }
示例#2
0
        public void ShouldShowIndexView()
        {
            ViewResult result = controller.Index();

            Assert.That(result.ViewName, Is.EqualTo("Index"));
        }