public RouteInfoVM ExtractRouteInfo(SearchRouteParameters parameters) { var result = new RouteInfoVM { Routes = new List <RouteInfo> { new RouteInfo(), new RouteInfo() } }; var htmlSummoryDoc = new HtmlDocument(); var htmlDetailsDoc = new HtmlDocument(); var url = $"https://www.skyscanner.ru/transport/flights/{parameters.Source.ToLower()}/{parameters.Destination.ToLower()}/{parameters.DateSource}/{parameters.DateDestination}#results"; loadPageForGetRouteHtmlElementsService.WaitLoadPage(url); htmlSummoryDoc.LoadHtml(loadPageForGetRouteHtmlElementsService.GetSummoryInnerHtml()); htmlDetailsDoc.LoadHtml(loadPageForGetRouteHtmlElementsService.GetDetailsInnerHtml()); loadPageForGetRouteHtmlElementsService.Dispose(); //начинаем парсить и заполнять вьюмодель данными fillVmService.FillVM(result, htmlSummoryDoc.DocumentNode, htmlDetailsDoc.DocumentNode); return(result); }
public void FillVM_FillVmWithSampleData_ThrowExceptionIfSomeHtmlMissed() { // Arrange htmlSummoryDoc.Load(Path.Combine(Directory.GetParent(Directory.GetParent(Environment.CurrentDirectory).ToString()).ToString(), "DataSamples\\summoryInfoNotExpectedChangesInHtml.html")); htmlDetailsDoc.Load(Path.Combine(Directory.GetParent(Directory.GetParent(Environment.CurrentDirectory).ToString()).ToString(), "DataSamples\\detailsInfo.html")); // Act fillVmService.FillVM(routeInfoVm, htmlSummoryDoc.DocumentNode, htmlDetailsDoc.DocumentNode); }