public void Action_Returns_Correct_Result() { var mockStartPage = new Mock <StartPage>(); var content = new Mock <IContent>(); var displayOptions = new DisplayOptions { new DisplayOption { Id = "Full", Name = "Full", Tag = "Full" } }; var mockTemplateModel = new Mock <TemplateModel>(); _templateResolverMock.Setup(x => x.Resolve(It.IsAny <HttpContextBase>(), It.IsAny <Type>(), It.IsAny <object>(), It.IsAny <TemplateTypeCategories>(), It.IsAny <string>())).Returns(mockTemplateModel.Object); _pageTypeServicesMock.Setup(x => x.StartPageService.Homepage).Returns(mockStartPage.Object); _websiteDependenciesMock.Setup(x => x.ContextResolver.AddContentAreaItem(It.IsAny <ContentArea>(), It.IsAny <ContentAreaItem>())).Returns(new ContentArea()); var test = new PreviewController( displayOptions, _templateResolverMock.Object, _websiteDependenciesMock.Object, _pageTypeServicesMock.Object); var actionResult = test.Index(content.Object); var viewModel = ((ViewResult)actionResult).ViewData.Model; ((PreviewViewModel <StartPage, StartPageAdditionalProperties>)viewModel).Areas.Count().Should().BeGreaterThan(0); }
public void Action_Returns_Correct_Result(IContent content) { var mockStartPage = new Mock <StartPage>(); _pageTypeServicesMock.Setup(x => x.StartPageService.Homepage).Returns(mockStartPage.Object); var test = new PreviewController( _displayOptionsMock.Object, _templateResolverMock.Object, _websiteDependenciesMock.Object, _pageTypeServicesMock.Object); test.Index(content).Should().NotBeNull(); }