public void Test_Parser(int countProduct, string nameShope, string typeFile, string typeTest) { string sourse = null; try { managerShope = new ManagerShope(); shopeSetings = managerShope.GetShope(nameShope); connectorShope = new ConnectorShope(shopeSetings.urlShope, shopeSetings.prefPage, shopeSetings.typeReqvest); ManagerShope.listProduct = new List <Product>(); sourse = GetDocument(typeFile, typeTest); shopeSetings.Parser(sourse, ref countProduct); Assert.AreEqual(test_Products.Count, ManagerShope.listProduct.Count); for (int i = 0; i < test_Products.Count; i++) { Assert.AreEqual(test_Products[i].id, ManagerShope.listProduct[i].id); Assert.AreEqual(test_Products[i].nameProduct, ManagerShope.listProduct[i].nameProduct); Assert.AreEqual(test_Products[i].price, ManagerShope.listProduct[i].price); } } catch (InvalidDataException) { } catch (Exception) { Assert.Fail(); } }
public void GetProducts() { int countProduct = 0; int countPage = 1; string sourse = null; while (countProduct < 135) { try { if (shopeSetings.typeReqvest == "parse") { sourse = connectorShope.GetContent(countPage.ToString()).GetAwaiter().GetResult(); } shopeSetings.Parser(sourse, ref countProduct); countPage++; } catch (HttpRequestException e) { throw new HttpRequestException(e.Message); } } }