protected void Analyze_Click(object sender, EventArgs e) { try { var counter = new WordCounter.WordCounter(textUrlOrText.Text, radioAnalyzeUrl.Checked, textStopWords.Text); analyzeDic(checkBoxCalculateWordsOnPage.Checked, gridViewWords, counter.GetWordsDictionary, "wordsTable"); analyzeDic(checkBoxCalculateKeywordsOnPage.Checked, gridViewKeywords, counter.GetKeywordsDictionary, "keywordsTable"); if (checkBoxCalculateExternalLinks.Checked) { labelExternalLinkNumber.Text = String.Format("Number of external links: {0}", counter.GetExternalLinksNumber()); } else { labelExternalLinkNumber.Text = ""; } } catch (UriFormatException) { labelErrorText.Text = "Incompatible url format"; textUrlOrText.BorderColor = Color.Red; } catch (WebException ex) { labelErrorText.Text = ex.Message; textUrlOrText.BorderColor = Color.Red; } }
public void TestDoCountManyRowsResult() { var counter = new WordCounter.WordCounter(); var rows = new string[] { "abc: def, Abc and egh", "abc: def, Abc and egh" }; var words = counter.CountWords(rows); var sorter = new WordCounter.WordCollectionSorter(); var lines = sorter.GetLines(words); Assert.AreEqual(4, lines.Length); Assert.AreEqual("abc 4", lines[0]); Assert.AreEqual("and 2", lines[1]); Assert.AreEqual("def 2", lines[2]); Assert.AreEqual("egh 2", lines[3]); }
public Main() { try { InitializeComponent(); _wordCounter = new WordCounter.WordCounter(); ClearForm(); } catch (Exception e) { ShowError(e.ToString()); } }
public void TestDoCountSample1Result() { var counter = new WordCounter.WordCounter(); var rows = new string[] { "abc: def, abc and egh" }; var words = counter.CountWords(rows); Assert.AreEqual(4, words.Count); var sorter = new WordCounter.WordCollectionSorter(); var lines = sorter.GetLines(words); Assert.AreEqual("abc 2", lines[0]); Assert.AreEqual("and 1", lines[1]); Assert.AreEqual("def 1", lines[2]); Assert.AreEqual("egh 1", lines[3]); }