public void FixtureSetup()
        {
            Results = new CustomValidatorMockConfiguration();
            var initialState = Results.GetState();

            OwnerOfAB = new TwoItemListsVM(Results);
            OwnerOfC  = new ItemListVM(Results);

            ItemA   = new ItemVM(Results, "ItemA");
            ItemAB  = new ItemVM(Results, "ItemAB");
            ItemABC = new ItemVM(Results, "ItemABC");
            ItemC   = new ItemVM(Results, "ItemC");

            OwnerOfAB.CollectionA.Add(ItemA);
            OwnerOfAB.CollectionA.Add(ItemAB);
            OwnerOfAB.CollectionA.Add(ItemABC);

            OwnerOfAB.CollectionB.Add(ItemAB);
            OwnerOfAB.CollectionB.Add(ItemABC);

            OwnerOfC.CollectionC.Add(ItemABC);
            OwnerOfC.CollectionC.Add(ItemC);

            initialState.RestoreToState();
        }
예제 #2
0
        private void HPProcessSearchPage(ref HtmlAgilityPack.HtmlDocument doc, ref List <ItemListVM> itemList, ref int webSiteId)
        {
            var ads = doc.DocumentNode.Descendants("li").Where(d => d.Attributes.Count > 0 &&
                                                               d.Attributes["class"] != null &&
                                                               d.Attributes["class"].Value.Contains("search-item")).ToList();

            foreach (HtmlNode product in ads)
            {
                var productDetail = product.Descendants("div").Where(d => d.Attributes.Count > 0 &&
                                                                     d.Attributes["class"] != null &&
                                                                     d.Attributes["class"].Value.Contains("product-detail")).FirstOrDefault();

                string name = productDetail.SelectSingleNode("//h3/div/p/span").InnerText;
                var    url  = product.Descendants("a").FirstOrDefault().Attributes.Where(a => a.Name == "href").Select(s => s.Value).FirstOrDefault();

                var priceValue = productDetail.Descendants("div").Where(d => d.Attributes.Count > 0 &&
                                                                        d.Attributes["class"] != null &&
                                                                        d.Attributes["class"].Value.Contains("price-value")).Select(a => a.InnerText).FirstOrDefault();

                var productPrice = productDetail.Descendants("span").Where(d => d.Attributes.Count > 0 &&
                                                                           d.Attributes["class"] != null &&
                                                                           d.Attributes["class"].Value.Contains("price product-price")).Select(a => a.InnerText).FirstOrDefault();

                double price = 0;
                if (priceValue != null)
                {
                    var priceStr = priceValue.Replace(" ", "").Replace("\r", "").Replace("\n", "").Replace("TL", "").Replace(".", "").Replace(",", ".");
                    price = Double.Parse(priceStr);
                }
                else if (productPrice != null)
                {
                    var priceStr = productPrice.Replace(" ", "").Replace("\r", "").Replace("\n", "").Replace(".", "").Replace(",", ".").Replace("TL", "");
                    price = Double.Parse(priceStr);
                }

                var rec = new ItemListVM()
                {
                    Id = Guid.NewGuid(), WebSiteId = webSiteId, Name = name, Price = price, URL = url
                };
                itemList.Add(rec);
            }
        }