private void bTryParse_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(tbName.Text) && String.IsNullOrEmpty(tbURL.Text) && (String.IsNullOrEmpty(tbTag.Text) || String.IsNullOrEmpty(tbClass.Text))) { MessageBox.Show("Необходимо заполнить все обязательные поля!"); return; } if (checkBox.Checked) { if (String.IsNullOrEmpty(tbPage.Text) || numStartPage.Value < 0 || numEndPage.Value < 0 || numStartPage.Value > numEndPage.Value) { MessageBox.Show("Дополнительные настройки заполнены некорректно!"); } else { _settings = new WebSiteSettings(tbURL.Text, tbPage.Text, (int)numStartPage.Value, (int)numEndPage.Value); } } else { _settings = new WebSiteSettings(tbURL.Text); } string tagName = tbTag.Text, containerName = tbClass.Text; _parser = new WebSiteParser(tagName, containerName); _extractor = new ParseExtractor(_parser, _settings); _extractor.StartParsing(); _extractor.NewData += OutputData; }
public void Initialize() { var tree = new WorkUnitTree(new WuRoot()); var paths = tree.AddConditionalNodes(TestWorkUnit.PathSelector, new Dictionary <ExecutionPath, WorkUnitTree> { [ExecutionPath.Path1] = new WorkUnitTree(new Wu1()), [ExecutionPath.Path2] = new WorkUnitTree(new Wu2()), [ExecutionPath.Path3] = new WorkUnitTree(new Wu3()), }); paths[ExecutionPath.Path2].AddNextNode(new WorkUnitTree(new WuA())) .AddNextNode(new WorkUnitTree(new WuB())); parser = new WebSiteParser <IWorkUnit, ParserExecutorResult>(tree); }
public void Parse_WorkUnitThrowsException_SaveToExceptionProperty() { var tree = new WorkUnitTree(new WuRoot()); tree.AddNextNode(new WorkUnitTree(new Wu1())) .AddNextNode(new WorkUnitTree(new WorkUnitException())) .AddNextNode(new WorkUnitTree(new Wu2())); var parser = new WebSiteParser <IWorkUnit, ParserExecutorResult>(tree); var result = parser.Parse(new In { Id = "1" }); var expected = JsonConvert.SerializeObject(new { UnitName = "WorkUnitException", Message = "Exception in work unit", Path = "WuRoot > Wu1 > WorkUnitException > " }); Assert.AreEqual(expected, result.Exception); }