Exemplo n.º 1
0
        private void DoWork(string url)
        {
            try
            {
                HtmlAnalyzer analyzer = new HtmlAnalyzer(url);
                analyzer.SetKeywords();
                var results = analyzer.findingWord();
                foreach (var item in results)
                {
                    var listViewItem = new ListViewItem(new string[] { item.Key, item.Value.ToString() });
                    lvResults.Items.Add(listViewItem);
                }

                lvResults.AutoResizeColumn(0, ColumnHeaderAutoResizeStyle.ColumnContent);
                lvResults.AutoResizeColumn(1, ColumnHeaderAutoResizeStyle.HeaderSize);
                lvResults.Show();
            }
            catch (UriFormatException ex)
            {
                Logger.Error(ex, "Bad url: ");
                MessageBox.Show(ex.Message);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        public void ValidateKeyWords()
        {
            var url      = "http://www.mechatrobot.pl";
            var analyzer = new Header_Reader.HtmlAnalyzer(url);

            analyzer.SetKeywords();
            Assert.IsNotNull(analyzer.keyWordsArray);
        }
Exemplo n.º 3
0
        public void ValidateBadUrl()
        {
            var url = "www.mechatrobot.pl";

            try
            {
                var analyzer = new Header_Reader.HtmlAnalyzer(url);
                Assert.Fail("no exception thrown");
            }
            catch (UriFormatException ex)
            {
                Assert.IsTrue(ex is UriFormatException);
            }
        }
Exemplo n.º 4
0
        public void EmptyKeyWords()
        {
            var url = "http://www.google.pl";

            try
            {
                var analyzer = new Header_Reader.HtmlAnalyzer(url);
                analyzer.SetKeywords();
                Assert.Fail("no exception thrown");
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex is Exception);
            }
        }