public void GetAllHeadersForArticleRange() { using (var client = new Rfc977NntpClient()) { client.Connect(Server); client.SelectNewsgroup(TestNewsGroup); var count = 0; foreach (var h in client.RetrieveArticleHeaders(client.CurrentGroup.LastArticleId - 20, client.CurrentGroup.LastArticleId)) { if (count++ > 10) { break; } } Assert.LessOrEqual(10, count, "Not necessarily an error. Assumes newsgroup contains at least 10 articles."); } }
public void PostArticle() { using (var client = new Rfc977NntpClient()) { client.Connect(Server); client.SelectNewsgroup(TestNewsGroup); var headers = new ArticleHeadersDictionary(); headers.AddHeader("From", "[email protected] (Anonymous)"); headers.AddHeader("Subject", "Test - Please Ignore."); headers.AddHeader("Newsgroups", TestNewsGroup); headers.AddHeader("Date", new NntpDateTime(DateTime.Now).ToString()); var body = new List<string>(); body.Add("One line test message body."); client.PostArticle(new ArticleHeadersDictionaryEnumerator(headers), body); } }
public void MoveArticleForwardAndBackward() { using (var client = new Rfc977NntpClient()) { client.Connect(Server); client.ProtocolLogger = Console.Error; client.SelectNewsgroup(TestNewsGroup); var range = 3; Assert.Greater(client.CurrentGroup.EstimatedCount, range, "Article count may not be large enough, this might not be an error."); var count = 0; for (; count < range; count++) { var ids = client.SetNextArticle(); } for (; count > 0; count--) { var ids = client.SetPreviousArticle(); } Assert.AreEqual(0, count, "Should have backed up same count as forward."); } }
public void MoveArticleForwardFromBeginning() { using (var client = new Rfc977NntpClient()) { client.Connect(Server); client.SelectNewsgroup(TestNewsGroup); var range = 3; Assert.Greater(client.CurrentGroup.EstimatedCount, range, "Article count may not be large enough, this might not be an error."); var count = 0; for (; count < range; count++) { var ids = client.SetNextArticle(); } Assert.Greater(count, 2, "Could not get more than 2 LAST commands, this might not be an error."); } }
public void MoveArticleBackwardFromEnd() { using (var client = new Rfc977NntpClient()) { client.Connect(Server); client.SelectNewsgroup(TestNewsGroup); client.RetrieveStatistics(client.CurrentGroup.LastArticleId); var range = 3; Assert.Greater(client.CurrentGroup.EstimatedCount, range, "Article count may not be large enough, this might not be an error."); var count = range; while (--count > 0) { var ids = client.SetPreviousArticle(); } Assert.AreEqual(0, count, "Should have backed up to 20 articles."); } }
public void GroupSelect() { using (var client = new Rfc977NntpClient()) { client.Connect(Server); client.SelectNewsgroup(TestNewsGroup); } }
public void GetSingleArticleBodyWithProcessors() { using (var client = new Rfc977NntpClient()) { client.Connect(Server); client.SelectNewsgroup(TestNewsGroup); var d = client.RetrieveArticleHeader(); var ap = new ArticleProcessor(); client.RetrieveArticle(ap, ap); Assert.IsTrue(ap.IsValid(), "Didn't read header line or body text lines."); } }
public void GetMutlipleArticlesBodies() { using (var client = new Rfc977NntpClient()) { client.ProtocolLogger = Console.Error; client.Connect(Server); client.SelectNewsgroup(TestNewsGroup); var d = client.RetrieveArticleHeader(); Assert.Greater(client.CurrentGroup.EstimatedCount, 5, "Not an error. This test assumes 5 available articles."); for (var i = 0; i < 5; i++) { foreach (var b in client.RetrieveArticleBody()) { } } } }
public void GetAllHeadersForArticleRangeInLoop() { using (var client = new Rfc977NntpClient()) { client.Connect(Server); client.SelectNewsgroup(TestNewsGroup); for (var i = client.CurrentGroup.LastArticleId - 20; i < client.CurrentGroup.LastArticleId; i++) { try { client.RetrieveArticleHeader(i); } catch (NntpResponseException error) { if (error.LastResponseCode == 423) { continue; } } } } }