public void FetchAllPagesWithWrongFilter() { using IBaseOfferListController ctr = new HttpAllegroOfferListController(); OfferListControllerException ex = Assert.Throws <OfferListControllerException>(() => ctr.StartFetching(false, new OfferCategory(EOfferWebsite.Allegro, 1), new List <WebsiteCategoriesFilterSearch>() { new WebsiteCategoriesFilterSearch() { Argument = "offerTypeBuyNow", Value = "1", Id = 1, SearchNumber = 1, WebsiteCategoryId = (int)EOfferWebsite.Allegro }, new WebsiteCategoriesFilterSearch() { Argument = "price_to", Value = "500", SearchNumber = 1, Id = 2, WebsiteCategoryId = (int)EOfferWebsite.NoInfo } })); Assert.IsNotNull(ex); }
public void FetchAllPages() { using IBaseOfferListController ctr = new HttpAllegroOfferListController(); ctr.StartFetching(false, new OfferCategory(EOfferWebsite.Allegro, 1)); }
public void OpenNextPageWithoutStartFetching() { using IBaseOfferListController allegroOfferListController = new HttpAllegroOfferListController(); OfferListControllerException ex = Assert.Throws <OfferListControllerException>(() => allegroOfferListController.OpenNextPage()); Assert.That(ex, Is.Not.Null); allegroOfferListController.Dispose(); }
public void FetchFailAllegroLink() { using IBaseOfferListController ctr = new HttpAllegroOfferListController(); OfferListControllerException ex = Assert.Throws <OfferListControllerException>( () => ctr.StartFetching(false, new OfferCategory(EOfferWebsite.Allegro, "testfaillink"))); Assert.That(ex, Is.Not.Null); ctr.Dispose(); controller.Dispose(); }
public void IndexPageFailAllegroLinkNoCategoryWithPaginationLastIndex() { using IBaseOfferListController ctr = new HttpAllegroOfferListController(); Assert.Throws <OfferListControllerException>( () => ctr.StartFetching(false, new OfferCategory(EOfferWebsite.Allegro, "uzytkownik/KOLEKCJONER-PL--/oceny"))); OfferListControllerException ex = Assert.Throws <OfferListControllerException>(() => ctr.GetLastPageIndex()); Assert.That(ex, Is.Not.Null); ctr.Dispose(); controller.Dispose(); }
public void InvokeTask() { logger.Info("Invoke task - loop started"); KeyValuePair <KeyValuePair <int, int>, IEnumerable <WebsiteCategoriesFilterSearch> > task; using (IDal db = new Dal()) { logger.Info("Invoke task - attempt to get task"); task = GetOldestTask(db); } logger.Info("Fetched oldest task " + task.Key.Value); try { using (HttpAllegroOfferListController ctrl = new HttpAllegroOfferListController()) { logger.Info("Started task #" + task.Key.Value); ctrl.StartFetching(false, new OfferCategory(EOfferWebsite.Allegro, task.Key.Key), task.Value.ToList(), Program.UserId); using (IDal db = new Dal()) { PopTaskFromQueue(db, task.Key.Value); } } logger.Info("Finished task #" + task.Key.Value); } catch (Exception ex) { logger.Info(ex); logger.Info("Timeout task #" + task.Key.Value + " - BREAK"); if (ex.Message.ToLower().Contains("too many req")) { using (IDal db = new Dal()) { SetTaskAsNotProcessedQueue(db, task.Key.Value); } } } finally { CURRENT_TASK_COUNT++; } }
public void InvokeTaskTest(string host) { using (IBaseOfferListController ctrl = new HttpAllegroOfferListController()) { while (CURRENT_TASK_COUNT <= MAX_TASKS_PER_RUN) { KeyValuePair <KeyValuePair <int, int>, IEnumerable <WebsiteCategoriesFilterSearch> > task; using (IDal db = new Dal()) { task = GetOldestTask(db); } logger.Info("Fetched oldest task " + task.Key.Value); try { logger.Info("Started task #" + task.Key.Value); ctrl.StartFetching(false, new OfferCategory(EOfferWebsite.Allegro, task.Key.Key), task.Value.ToList()); logger.Info("Finished task #" + task.Key.Value); } catch (Exception ex) { logger.Info(ex); logger.Info("Timeout task #" + task.Key.Value + " - BREAK"); } finally { CURRENT_TASK_COUNT++; using (IDal db = new Dal()) { PopTaskFromQueue(db, task.Key.Value); } } } } }
public void FetchAllPagesWithFilter() { using IBaseOfferListController ctr = new HttpAllegroOfferListController(); ctr.StartFetching(false, new OfferCategory(EOfferWebsite.Allegro, 1), new List <WebsiteCategoriesFilterSearch>() { new WebsiteCategoriesFilterSearch() { Argument = "offerTypeBuyNow", Value = "1", Id = 1, SearchNumber = 1, WebsiteCategoryId = (int)EOfferWebsite.Allegro }, new WebsiteCategoriesFilterSearch() { Argument = "price_to", Value = "500", SearchNumber = 1, Id = 2, WebsiteCategoryId = (int)EOfferWebsite.Allegro } }); }