private catalogDto.Product AddProduct(catalogDto.Catalog catalog, string productId, params string[] slugs) { var result = new catalogDto.Product { Id = productId, CatalogId = catalog.Id, Outlines = new List <catalogDto.Outline>() }; _products.Add(result); _catalogSeoRecords.AddRange(slugs.Select(s => CreateSeoInfo("CatalogProduct", productId, s))); return(result); }
private catalogDto.Category AddCategory(catalogDto.Catalog catalog, string categoryId, params string[] slugs) { var result = new catalogDto.Category { Id = categoryId, CatalogId = catalog.Id, Outlines = new List <catalogDto.Outline>() }; _categories.Add(result); _catalogSeoRecords.AddRange(slugs.Select(s => CreateSeoInfo("Category", categoryId, s))); return(result); }
private catalogDto.Outline CreateOutline(catalogDto.Catalog catalog, catalogDto.Category[] categories, catalogDto.Product product = null) { var result = new catalogDto.Outline { Items = new List <catalogDto.OutlineItem> { CreateOutlineItem("Catalog", catalog.Id) } }; result.Items.AddRange(categories.Select(c => CreateOutlineItem("Category", c.Id, c.CatalogId != catalog.Id))); if (product != null) { result.Items.Add(CreateOutlineItem("CatalogProduct", product.Id)); } return(result); }
// Catalog structure // // Slug letters: // a = active // i = inactive // c = category // p = product // v = vendor // g = page // d = duplicate // // cc // c // L- c1 ac1, ic1 // |- c2 ac2 // L- c3 acd, ic3 // |- c4 acd, ic4 // |- p1 ap1, ipd, ip1 // L- p2 ap2, ipd // // v1 // |- v11 -> c2 ac2 // L- v12 -> c3 acd // // v2 // |- v21 -> c2 ac2 // |- v22 -> c3 acd public SeoRouteTests() { _categories = new List <catalogDto.Category>(); _products = new List <catalogDto.Product>(); _pages = new List <ContentPage>(); _catalogSeoRecords = new List <catalogDto.SeoInfo> { new catalogDto.SeoInfo { ObjectType = "Vendor", ObjectId = "v1", SemanticUrl = "av1", IsActive = true }, new catalogDto.SeoInfo { ObjectType = "Vendor", ObjectId = "v1", SemanticUrl = "iv1", IsActive = false }, }; var c = new catalogDto.Catalog { Id = "c" }; var v1 = new catalogDto.Catalog { Id = "v1", IsVirtual = true }; var v2 = new catalogDto.Catalog { Id = "v2", IsVirtual = true }; var c1 = AddCategory(c, "c1", "ac1", "ic1"); var c2 = AddCategory(c, "c2", "ac2"); var c3 = AddCategory(c, "c3", "acd", "ic3"); var c4 = AddCategory(c, "c4", "acd", "ic4"); var v11 = AddCategory(v1, "v11", "ac2"); var v12 = AddCategory(v1, "v12", "acd"); var v21 = AddCategory(v2, "v21", "ac2"); var v22 = AddCategory(v2, "v22", "acd"); var p1 = AddProduct(c, "p1", "ap1", "ipd", "ip1"); var p2 = AddProduct(c, "p2", "ap2", "ipd"); c1.Outlines.Add(CreateOutline(c, new[] { c1 })); c2.Outlines.Add(CreateOutline(c, new[] { c1, c2 })); c3.Outlines.Add(CreateOutline(c, new[] { c1, c3 })); c4.Outlines.Add(CreateOutline(c, new[] { c1, c3, c4 })); v11.Outlines.Add(CreateOutline(v1, new[] { v11 })); v12.Outlines.Add(CreateOutline(v1, new[] { v12 })); c2.Outlines.Add(CreateOutline(v1, new[] { v11, c2 })); c3.Outlines.Add(CreateOutline(v1, new[] { v12, c3 })); v21.Outlines.Add(CreateOutline(v2, new[] { v21 })); v22.Outlines.Add(CreateOutline(v2, new[] { v22 })); c2.Outlines.Add(CreateOutline(v2, new[] { v21, c2 })); c3.Outlines.Add(CreateOutline(v2, new[] { v22, c3 })); p1.Outlines.Add(CreateOutline(c, new[] { c1, c3 }, p1)); p2.Outlines.Add(CreateOutline(c, new[] { c1, c3 }, p2)); AddPage("en-US", "ag1", "ig1"); _coreSeoRecords = _catalogSeoRecords.Select(s => s.JsonConvert <coreDto.SeoInfo>()).ToList(); // Create duplicates _coreSeoRecords.AddRange(_coreSeoRecords); }