public void ReaderMustIdentifyHowManyTimesARelevantWordAppearInEachArticle() { // Arrange reader = RSSReader.Read(simpleFeedURI); // Act var mostRelevantWords = reader.GetMostRelevantWords(1); // Assert var appearnceCountPerArticle = mostRelevantWords[0].AppearanceCountPerArticle; // Assert this.AssertAppearnceCountPerArticle(mostRelevantWords, new List <WordTest>() { // Word: "Erik" new WordTest() { AppearanceCountPerArticle = new List <AppearanceCountWordArticle>() { new AppearanceCountWordArticle { ArticleTitle = "Fisrt Article", NumberOfTimesInArticle = 2 }, new AppearanceCountWordArticle { ArticleTitle = "Second Article", NumberOfTimesInArticle = 2 }, new AppearanceCountWordArticle { ArticleTitle = "Third Article", NumberOfTimesInArticle = 1 } } } }); }
public void ReaderMustIdentifyFeedsFiveMostRelevantWords() { // Arrange reader = RSSReader.Read(simpleFeedURI); // Act var mostRelevantWords = reader.GetMostRelevantWords(5); // Assert Assert.IsNotNull(mostRelevantWords); Assert.AreEqual(5, mostRelevantWords.Count); Assert.AreEqual("Erik", mostRelevantWords[0].Text); Assert.AreEqual(5, mostRelevantWords[0].AppearanceCount); Assert.AreEqual("AT&T", mostRelevantWords[1].Text); Assert.AreEqual(4, mostRelevantWords[1].AppearanceCount); Assert.AreEqual("Thor", mostRelevantWords[2].Text); Assert.AreEqual(4, mostRelevantWords[2].AppearanceCount); Assert.AreEqual("Yoshi", mostRelevantWords[3].Text); Assert.AreEqual(4, mostRelevantWords[3].AppearanceCount); Assert.AreEqual("Jim", mostRelevantWords[4].Text); Assert.AreEqual(3, mostRelevantWords[4].AppearanceCount); }
public void FeedMustBeCorrectlyLoadedWhenXMLIsWellFormed() { // Arrange && Act feed = RSSReader.Read(simpleFeedURI).Feed; // Assert Assert.IsNotNull(feed); Assert.IsTrue(feed.Articles.Count == 3); Assert.AreEqual("Test website", feed.Title); Assert.AreEqual("Test website description", feed.Description); Assert.AreEqual("http://test.com", feed.Link); }
public void ARSTechnicaFeedMustBeCorrectlyLoaded() { // Arrange && Act Feed feed = RSSReader.Read(arstechnicaFeedURL).Feed; // Assert Assert.IsNotNull(feed); Assert.IsTrue(feed.Articles.Count > 0); Assert.AreEqual("Technology Lab – Ars Technica", feed.Title); Assert.AreEqual("Serving the Technologist for more than a decade. IT news, reviews, and analysis.", feed.Description); Assert.AreEqual("http://arstechnica.com", feed.Link); }
public void ReaderMustidentifyFeedsMostRelevantWord() { // Arrange reader = RSSReader.Read(simpleFeedURI); // Act var mostRelevantWords = reader.GetMostRelevantWords(1); // Assert Assert.IsNotNull(mostRelevantWords); Assert.AreEqual(1, mostRelevantWords.Count); Assert.AreEqual("Erik", mostRelevantWords[0].Text); Assert.AreEqual(5, mostRelevantWords[0].AppearanceCount); }
public void WriteAFeed() { var TestObject = new RSSWriter(); var TestReader = new RSSReader(); var ResultReader = new RSSReader(); using (var ResultFile = File.Open("./Results/WriteAFeed.rss", FileMode.OpenOrCreate)) { using var TestFile = File.OpenRead("../../../TestData/TestRSS.rss"); Assert.True(TestObject.Write(ResultFile, TestReader.Read(TestFile))); } using (var ResultFile = File.Open("./Results/WriteAFeed.rss", FileMode.OpenOrCreate)) { var Result = ResultReader.Read(ResultFile); Assert.Equal(1, Result.Count); Assert.Equal(10, Result.Channels[0].Count); Assert.Equal(12056, Result.Content.Length); } }
private void btnRead_Click(object sender, EventArgs e) { try { lvArticles.Items.Clear(); lvWordArticle.Items.Clear(); lvRelevantWords.Items.Clear(); var feedURI = txtFeedURI.Text; reader = RSSReader.Read(txtFeedURI.Text); feed = reader.Feed; this.FillControls(); btnIdendify.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void ArticlesMustBeCorrectlyLoadedWhenXMLIsWellFormed() { // Arrange && Act feed = RSSReader.Read(simpleFeedURI).Feed; // Assert var articles = feed.Articles; Assert.IsNotNull(articles); Assert.IsTrue(articles.Count == 3); this.AssertArticle(articles[0], "Fisrt Article", "Description of first article.", "http://test.com/firstArticle", new DateTime(2016, 12, 02, 20, 55, 38), "22 AT&T Thor's Jim, AT&T, Erik, Yoshi with me in the beach. They were at my place, but Erik wanted to go out with Thor, so I let them. 22 "); this.AssertArticle(articles[1], "Second Article", "Description of second article.", "http://test.com/secondArticle", new DateTime(2016, 12, 03, 21, 55, 38), "22 AT&T Out of nowhere, AT&T, some Storm started and we all looked at Thor because we thought he did it. " + "But it turns out, it was actually Erik. Erik did it in order for us to open a portal to the land of Yoshi. Where we could eat some " + "apples and play in some other beach. "); this.AssertArticle(articles[2], "Third Article", "Description of third article.", "http://test.com/thirdArticle", new DateTime(2016, 12, 04, 22, 55, 38), "22 When we got back from the land of Yoshi, I woke up and realized it was a dream, a bad dream. " + "A dream I only had because Jim put some Gim in my drink. Today all I can think of is my friends in the beach, all of them: Thor, " + "Jim, Erik and Yoshi. "); }
public void MustThrowExceptionWhenFeedIsMalformed() { // Act and Assert RSSReader.Read(malformedFeedURI); }
public void MustThrowExceptionWhenURIIsInvalid() { // Act and Assert RSSReader.Read("!#@$%"); }
public void MustThrowExceptionWhenURIIsNull() { // Act and Assert RSSReader.Read(null); }
public void MustThrowExceptionWhenURIIsEmpty() { // Act and Assert RSSReader.Read(string.Empty); }
public void ReaderMustIdentifyHowManyTimesEachOfFiveRelevantWordsAppearInEachArticle() { // Arrange reader = RSSReader.Read(simpleFeedURI); // Act var mostRelevantWords = reader.GetMostRelevantWords(5); // Assert this.AssertAppearnceCountPerArticle(mostRelevantWords, new List <WordTest>() { // Word: "Erik" new WordTest() { AppearanceCountPerArticle = new List <AppearanceCountWordArticle>() { new AppearanceCountWordArticle { ArticleTitle = "Fisrt Article", NumberOfTimesInArticle = 2 }, new AppearanceCountWordArticle { ArticleTitle = "Second Article", NumberOfTimesInArticle = 2 }, new AppearanceCountWordArticle { ArticleTitle = "Third Article", NumberOfTimesInArticle = 1 } } }, // Word: "AT&T" new WordTest() { AppearanceCountPerArticle = new List <AppearanceCountWordArticle>() { new AppearanceCountWordArticle { ArticleTitle = "Fisrt Article", NumberOfTimesInArticle = 2 }, new AppearanceCountWordArticle { ArticleTitle = "Second Article", NumberOfTimesInArticle = 2 }, new AppearanceCountWordArticle { ArticleTitle = "Third Article", NumberOfTimesInArticle = 0 } } }, // Word: "Thor" new WordTest() { AppearanceCountPerArticle = new List <AppearanceCountWordArticle>() { new AppearanceCountWordArticle { ArticleTitle = "Fisrt Article", NumberOfTimesInArticle = 2 }, new AppearanceCountWordArticle { ArticleTitle = "Second Article", NumberOfTimesInArticle = 1 }, new AppearanceCountWordArticle { ArticleTitle = "Third Article", NumberOfTimesInArticle = 1 } } }, // Word: "Yoshi" new WordTest() { AppearanceCountPerArticle = new List <AppearanceCountWordArticle>() { new AppearanceCountWordArticle { ArticleTitle = "Fisrt Article", NumberOfTimesInArticle = 1 }, new AppearanceCountWordArticle { ArticleTitle = "Second Article", NumberOfTimesInArticle = 1 }, new AppearanceCountWordArticle { ArticleTitle = "Third Article", NumberOfTimesInArticle = 2 } } }, // Word: "Jim" new WordTest() { AppearanceCountPerArticle = new List <AppearanceCountWordArticle>() { new AppearanceCountWordArticle { ArticleTitle = "Fisrt Article", NumberOfTimesInArticle = 1 }, new AppearanceCountWordArticle { ArticleTitle = "Second Article", NumberOfTimesInArticle = 0 }, new AppearanceCountWordArticle { ArticleTitle = "Third Article", NumberOfTimesInArticle = 2 } } } }); }