public void ValidateSeoRouteResponse(string catalogId, SeoLinksType linksType, string seoPath, string expectedRedirectLocation, string expectedController, string expectedAction, string expectedObjectIdName, string expectedObjectId) { // Don't use catalog API client for non-SEO links var shortLinks = linksType == SeoLinksType.None; var catalogApi = shortLinks ? null : CreateCatalogApiClient(); var service = CreateSeoRouteService(catalogApi); var workContext = CreateWorkContext(catalogId, linksType); var response = service.HandleSeoRequest(seoPath, workContext); Assert.NotNull(response); Assert.Equal(expectedRedirectLocation, response.RedirectLocation); if (expectedRedirectLocation != null) { Assert.True(response.Redirect); } else { Assert.False(response.Redirect); Assert.NotNull(response.RouteData); Assert.Equal(expectedController, response.RouteData["controller"]); Assert.Equal(expectedAction, response.RouteData["action"]); if (expectedObjectIdName != null) { Assert.Equal(expectedObjectId, response.RouteData[expectedObjectIdName]); } if (expectedController == "StaticContent") { Assert.NotNull(response.RouteData["page"]); } } }
private WorkContext CreateWorkContext(string catalogId, SeoLinksType linksType) { var store = CreateStore("s", catalogId, linksType, "en-US", "ru-RU"); return(new WorkContext { CurrentStore = store, CurrentLanguage = store.DefaultLanguage, Pages = new MutablePagedList <ContentItem>(_pages), }); }
private static Store CreateStore(string storeId, string catalogId, SeoLinksType linksType, params string[] cultureNames) { var result = new Store { Id = storeId, Catalog = catalogId, SeoLinksType = linksType, Languages = cultureNames.Select(n => new Language(n)).ToList(), }; result.DefaultLanguage = result.Languages.FirstOrDefault(); return(result); }
public static toolsDto.SeoLinksType ToToolsSeoLinksType(this SeoLinksType seoLinksType) { return(EnumUtility.SafeParse(seoLinksType.ToString(), toolsDto.SeoLinksType.None)); }