public void Setup() { this.controller = new SitemapController(this.ArticleServiceMock.Object, this.RubricServiceMock.Object) { Cache = this.CacheServiceMock.Object }; }
public SitemapControllerTests() { defaultPathDataService = A.Fake <IPathDataService>(); defaultLogger = A.Fake <ILogger <SitemapController> >(); defaultBaseUrlService = A.Fake <IBaseUrlService>(); var pathModels = new List <PathModel> { new PathModel { SitemapURL = "http://SomeSitemapUrl.xyz", IsOnline = true, }, }; A.CallTo(() => defaultPathDataService.GetPaths()).Returns(pathModels); var user = A.Fake <ClaimsPrincipal>(); A.CallTo(() => user.Identity.IsAuthenticated).Returns(true); defaultHttpContext = A.Fake <HttpContext>(); defaultHttpContext.Request.Scheme = DummyScheme; defaultHttpContext.Request.Host = new HostString(DummyHost); var fakeIdentity = new GenericIdentity("User"); var principal = new GenericPrincipal(fakeIdentity, null); A.CallTo(() => defaultHttpContext.User).Returns(principal); defaultUrlHelper = A.Fake <IUrlHelper>(); A.CallTo(() => defaultUrlHelper.Action(A <UrlActionContext> .Ignored)).Returns(DummyHomeIndex); defaultTokenRetriever = A.Fake <IBearerTokenRetriever>(); A.CallTo(() => defaultTokenRetriever.GetToken(A <HttpContext> .Ignored)).Returns("SomeToken"); A.CallTo(() => defaultBaseUrlService.GetBaseUrl(A <HttpRequest> .Ignored, A <IUrlHelper> .Ignored)) .Returns("http://SomeBaseUrl"); defaultSitemapService = A.Fake <IApplicationSitemapService>(); A.CallTo(() => defaultSitemapService.GetAsync(A <ApplicationSitemapModel> .Ignored)) .Returns(Task.FromResult <IEnumerable <SitemapLocation> >(new List <SitemapLocation>() { new SitemapLocation { Url = "http://Sitemap.xml", Priority = 1, }, })); defaultController = new SitemapController(defaultPathDataService, defaultLogger, defaultTokenRetriever, defaultBaseUrlService, defaultSitemapService) { ControllerContext = new ControllerContext { HttpContext = defaultHttpContext, }, Url = defaultUrlHelper, }; }
public void TestSitemapController() { var sitemapController = new SitemapController(); var result = (ActionResult)sitemapController.Index(); Assert.NotNull(sitemapController); }
protected SitemapController BuildSitemapController() { var controller = new SitemapController(FakeLogger) { ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext(), }, }; return(controller); }
protected SitemapController BuildSitemapController() { var controller = new SitemapController(FakeLogger, FakeJobGroupDocumentService) { ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext(), }, }; return(controller); }
public async Task SitemapControllerReplacesApplicationBaseUrlWithShellUrl() { const string appBaseUrl = "http://appBaseUrl"; var appRegistrationModels = new List <AppRegistrationModel> { new AppRegistrationModel { SitemapURL = new Uri(appBaseUrl, UriKind.Absolute), IsOnline = true, }, }; var shellAppRegistryDataService = A.Fake <IAppRegistryDataService>(); A.CallTo(() => shellAppRegistryDataService.GetAppRegistrationModels()).Returns(appRegistrationModels); var applicationSitemapService = A.Fake <IApplicationSitemapService>(); A.CallTo(() => applicationSitemapService.GetAsync(A <ApplicationSitemapModel> .Ignored)) .Returns(Task.FromResult <IEnumerable <SitemapLocation> >(new List <SitemapLocation>() { new SitemapLocation { Url = $"{appBaseUrl}/test", Priority = 1, }, })); var fakeBaseUrlService = A.Fake <IBaseUrlService>(); A.CallTo(() => fakeBaseUrlService.GetBaseUrl(A <HttpRequest> .Ignored, A <IUrlHelper> .Ignored)) .Returns("http://SomeBaseUrl"); var sitemapController = new SitemapController(shellAppRegistryDataService, defaultLogger, defaultTokenRetriever, fakeBaseUrlService, applicationSitemapService) { ControllerContext = new ControllerContext { HttpContext = defaultHttpContext, }, Url = defaultUrlHelper, }; var result = await sitemapController.Sitemap().ConfigureAwait(false); Assert.DoesNotContain(appBaseUrl, result.Content, StringComparison.OrdinalIgnoreCase); Assert.Contains("http://SomeBaseUrl", result.Content, StringComparison.OrdinalIgnoreCase); sitemapController.Dispose(); }
public void SitemapController_Index() { var controller = new SitemapController(_topicRepository); var result = controller.Index() as ViewResult; var model = result.Model as TopicEntityViewModel; controller.Dispose(); Assert.IsNotNull(model); Assert.AreEqual<ITopicRepository>(_topicRepository, model.TopicRepository); Assert.AreEqual<string>("Root", model.RootTopic.Key); Assert.AreEqual<string>("Root", model.Topic.Key); }