private void AddProductsToTree(AssortmentTree tree, Dictionary <int, List <int> > productsPerProductGroupMapping, Dictionary <int, List <int> > productMapping)
 {
     foreach (var mappingGroup in productsPerProductGroupMapping)
     {
         tree.AddProducts(mappingGroup.Value, mappingGroup.Key, productMapping, InsertProductsToAllGroups);
     }
 }
Exemplo n.º 2
0
        private void AddProductsToTree(AssortmentTree tree, Dictionary <int, List <int> > productsPerProductGroupMapping, List <Content> Contents, Dictionary <int, List <int> > MappingProductGroup)
        {
            var productMapping = (from c in Contents
                                  select new
            {
                c.ProductID,
                ProductGroupMappings = (from pg in c.ProductGroupVendors
                                        where MappingProductGroup.ContainsKey(pg)
                                        select MappingProductGroup[pg]).SelectMany(pg => pg).ToList()
            }).ToDictionary(c => c.ProductID, c => c.ProductGroupMappings);

            foreach (var mappingGroup in productsPerProductGroupMapping)
            {
                tree.AddProducts(mappingGroup.Value, mappingGroup.Key, productMapping, false);
            }
        }
        /// <summary>
        /// This is just a performance test
        /// </summary>
        //[TestMethod]
        public void Add_Product_To_Level_1_Should_Attach_The_Products_To_The_Right_Node_500000_Products()
        {
            Random r = new Random();

            _tree.AddToTree(1);
            _tree.AddToTree(2, 1);
            _tree.AddToTree(3, 1);
            _tree.AddToTree(4, 1);
            _tree.AddToTree(5, 1);

            for (int i = 6; i < 700; i++)
            {
                _tree.AddToTree(i, i % 2 == 0 ? 2 : 3);
                _tree.AddProducts(Enumerable.Range(0, r.Next(2000)).ToList(), i, _productProductGroupMapping, false);
            }
        }
Exemplo n.º 4
0
        public void Add_Product_To_Level_1_Should_Attach_The_Products_To_The_Right_Node()
        {
            _tree.AddToTree(1);
            _tree.AddToTree(2, 1);

            _tree.AddProducts(Enumerable.Range(1, 10000).ToList(), 2, _productProductGroupMapping, false);

            Assert.IsTrue(_tree.GetNode(2).Products.Count == 10000);
        }