public void TestUpdate() { try { Shoutbox.Update(TestEnvironment.Session); if (Shoutbox.TopChatter.Count > 10) { Assert.Fail("More than 10 top chatters were parsed"); } foreach (var chatter in Shoutbox.TopChatter) { Assert.AreNotEqual(0, chatter.ID, "The id of a top chatter was not set"); Assert.AreNotEqual(0, chatter.Name.Length, "The name of a top chatter was not set"); } } catch (RequestFailedException exc) { AssertExtender.Exception("A HTTP request failed", exc); } catch (InvalidSessionException exc) { AssertExtender.Exception("Session is invalid", exc); } }
public void TestShouts() { try { var shouts = Shoutbox.Global.Shouts(TestEnvironment.Session); Assert.AreNotEqual(0, shouts.Count, "No shouts were parsed"); if (shouts.Count > 15) { Assert.Fail("More than 15 shouts were parsed"); } foreach (var shout in shouts) { Assert.AreNotEqual(0, shout.Content.ToString().Length, "The message content of a shout was not set"); Assert.AreNotEqual(default(DateTime), shout.Date, "The date and time of a shout was not set"); Assert.AreNotEqual(0, shout.Sender.Name.Length, "The name of the shout sender was not set"); Assert.AreNotEqual(0, shout.Sender.ID, "The ID of the shout sender was not set"); } } catch (RequestFailedException exc) { AssertExtender.Exception("A HTTP request failed", exc); } catch (InvalidSessionException exc) { AssertExtender.Exception("Session is invalid", exc); } }
public void TestGetTransactions() { try { TestEnvironment.Session.User.TBMProfile.SecretWord = TestEnvironment.TestCredentials.SecretWord; var transactions = TestEnvironment.Session.User.TBMProfile.GetTransactions(TestEnvironment.Session); Assert.AreNotEqual(0, transactions.Count, "No transactions were found"); foreach (var transaction in transactions) { Assert.AreNotEqual(0, transaction.EliteGold, "elite*gold amount of a transaction was not set"); Assert.AreNotEqual(default(DateTime), transaction.Time, "Date and time of a transaction was not set"); Assert.AreNotEqual(0, transaction.Sender.ID, "The ID of the transaction sender was not set"); Assert.AreNotEqual(0, transaction.Sender.Name.Length, "The name of the transaction sender was not set"); Assert.AreNotEqual(0, transaction.Receiver.ID, "The ID of the transaction receiver was not set"); Assert.AreNotEqual(0, transaction.Receiver.Name.Length, "The name of the transaction receiver was not set"); } } catch (RequestFailedException exc) { AssertExtender.Exception("A HTTP request failed", exc); } catch (InvalidSessionException exc) { AssertExtender.Exception("Session is invalid", exc); } catch (InvalidAuthenticationException exc) { AssertExtender.Exception("Secret word is invalid", exc); } }
public void TestHistory() { try { var globalHistoryShouts = Shoutbox.Global.History(TestEnvironment.Session, 1, 1); Assert.AreNotEqual(0, globalHistoryShouts.Count, "No shouts were pulled from the global channel history"); // one page contains 15 shouts. If we're specifiying that we want to parse just one page, we shouldn't get more than 15 shouts if (globalHistoryShouts.Count > 15) { Assert.Fail("More than 15 shouts were parsed"); } foreach (var shout in globalHistoryShouts) { Assert.AreNotEqual(0, shout.Content.ToString().Length, "The message content of a shout was not set"); Assert.AreNotEqual(default(DateTime), shout.Date, "The date and time of a shout was not set"); Assert.AreNotEqual(0, shout.Sender.Name.Length, "The name of the shout sender was not set"); Assert.AreNotEqual(0, shout.Sender.ID, "The ID of the shout sender was not set"); } } catch (RequestFailedException exc) { AssertExtender.Exception("A HTTP request failed", exc); } catch (InvalidSessionException exc) { AssertExtender.Exception("Session is invalid", exc); } }
public void AvatarTest() { try { var schmittAvatar = Image.FromWeb(new Uri("http://i.epvpimg.com/GQp1h.jpg")); var gitAvatar = Image.FromFileSystem("../../Resources/identicon.png"); if (!String.IsNullOrEmpty(TestEnvironment.Session.User.AvatarUrl)) { TestEnvironment.Session.Profile.RemoveAvatar(TestEnvironment.Session); TestEnvironment.Session.User.Update(TestEnvironment.Session); Assert.AreEqual(0, TestEnvironment.Session.User.AvatarUrl.Length, "The avatar of the logged-in user was not removed"); } TestEnvironment.Session.Profile.SetAvatar(TestEnvironment.Session, schmittAvatar); TestEnvironment.Session.User.Update(TestEnvironment.Session); Assert.AreNotEqual(0, TestEnvironment.Session.User.AvatarUrl.Length, "The test avatar from the web was not uploaded and set"); TestEnvironment.Session.Profile.SetAvatar(TestEnvironment.Session, gitAvatar); TestEnvironment.Session.User.Update(TestEnvironment.Session); Assert.AreNotEqual(0, TestEnvironment.Session.User.AvatarUrl, "The test avatar from the file system was not uploaded and set"); } catch (RequestFailedException exc) { AssertExtender.Exception("A HTTP request failed", exc); } catch (InvalidSessionException exc) { AssertExtender.Exception("Session is invalid", exc); } }
public void TestUpdate() { try { Section.Main.Update(TestEnvironment.Session); if (Section.Main.Announcements.Count < 2) // every section needs to supply at least 2 announcements { Assert.Fail("The announcements were not fully detected. Announcement count: {0}", Section.Main.Announcements.Count); } foreach (var announcement in Section.Main.Announcements) { Assert.AreNotEqual(0, announcement.Title.Length, "The title of an announcement was not set"); Assert.AreNotEqual(default(DateTime), announcement.Begins, "The begin date of the announcement was not set"); Assert.AreNotEqual(0, announcement.Sender.ID, "The ID of the announcement creator was not set"); Assert.AreNotEqual(0, announcement.Sender.Name, "The name of the announcement creator was not set"); } } catch (RequestFailedException exc) { AssertExtender.Exception("A HTTP request failed", exc); } catch (InvalidSessionException exc) { AssertExtender.Exception("Session is invalid", exc); } }
public void TestReplies() { // http://www.elitepvpers.com/forum/main/1329965-de-en-infractions-warnings-things-you-should-know.html var testThread = new SectionThread(1329965, Section.Main); try { var replies = testThread.Replies(TestEnvironment.Session); Assert.AreNotEqual(0, replies.Count, "No replies were pulled from the test thread"); Assert.AreNotEqual(0, testThread.InitialPost.ID, "The initial post of the test thread was not set"); foreach (var reply in replies) { Assert.AreNotEqual(0, reply.ID, "The ID of a reply was not set"); Assert.AreNotEqual(0, reply.Content.ToString().Length, "The content of a reply was not set"); Assert.AreNotEqual(default(DateTime), reply.Date, "The date and time of a reply was not set"); Assert.AreNotEqual(0, reply.Sender.ID, "The ID of a reply sender was not set"); Assert.AreNotEqual(0, reply.Sender.Name.Length, "The name of a reply sender was not set"); Assert.AreNotEqual(0, reply.Sender.Title.Length, "The user title of a reply sender was not set"); Assert.AreNotEqual(default(DateTime), reply.Sender.JoinDate, "The join date of a reply sender was not set"); } } catch (RequestFailedException exc) { AssertExtender.Exception("A HTTP request failed", exc); } catch (InvalidSessionException exc) { AssertExtender.Exception("Session is invalid", exc); } }
public void TestUserUpdate() { try { // copy the 2 required properties of the logged-in user to a new object to see if the update function works properly var testUser = new User(TestEnvironment.Session.User.Name, TestEnvironment.Session.User.ID); testUser.Update(TestEnvironment.Session); // Test the properties which always have to be set Assert.AreNotEqual(0, testUser.Title.Length, "Title of the user was not set"); Assert.AreNotEqual(0, testUser.Namecolor.IsEmpty, "Namecolor of the user was not set"); Assert.AreNotEqual(0, testUser.TBMProfile.ID, "ID of the user's TBM profile was not set"); if (testUser.JoinDate == new DateTime() && testUser.CurrentStatus != User.Status.Invisible) { Assert.Fail("The join date of the user was not retrieved although the status was not detected invisible"); } } catch (RequestFailedException exc) { AssertExtender.Exception("A HTTP request failed", exc); } catch (InvalidSessionException exc) { AssertExtender.Exception("Session is invalid", exc); } }
public void TestGetPrivateMessages() { try { // parse only the first page var messages = PrivateMessageFolder.Inbox.GetMessages(TestEnvironment.Session); if (messages.Count <= 0) { Assert.Fail("Messages could not be parsed or no private messages do exist in the inbox"); } // grab only 3 messages (if available) // check if the properties of all messages were parsed correctly foreach (var message in messages.Count >= 3 ? messages.Take(3) : messages.Take(messages.Count)) { Assert.AreNotEqual(0, message.ID, "The ID of a private message was not set"); if (new DateTime() == message.Date) { Assert.Fail("The date and time of a private message was not set"); } Assert.AreNotEqual(0, message.Title.Length, "The title of a private message was not set"); Assert.AreNotEqual(0, message.Sender.ID); Assert.AreNotEqual(0, message.Sender.Name.Length, "The name of a sender of a private message was not set"); // update the private message and retrieve extra information // since this function also updates the properties handled before, we'll check them again message.Update(TestEnvironment.Session); Assert.AreNotEqual(0, message.ID, "The ID of a private message was not set after updating"); if (new DateTime() == message.Date) { Assert.Fail("The date and time of a private message was not set after updating"); } Assert.AreNotEqual(0, message.Title.Length, "The title of a private message was not set after updating"); Assert.AreNotEqual(0, message.Sender.ID); Assert.AreNotEqual(0, message.Sender.Name.Length, "The name of a sender of a private message was not set after updating"); Assert.AreNotEqual(0, message.Content.ToString().Length, "The content of a private message was not set after updating"); } } catch (RequestFailedException exc) { AssertExtender.Exception("A HTTP request failed", exc); } catch (InvalidSessionException exc) { AssertExtender.Exception("Session is invalid", exc); } }
public void TestGetSectionByShortname() { try { var sections = Section.GetSectionByShortname(TestEnvironment.Session, "main"); Assert.AreNotEqual(0, sections, "The Main section wasn't found by its shortname"); var mainSection = sections.First(); Assert.AreNotEqual(0, mainSection.ID, "The ID of the section was not set"); Assert.AreNotEqual(0, mainSection.Name, "The section name was not set"); } catch (RequestFailedException exc) { AssertExtender.Exception("A HTTP request failed", exc); } catch (InvalidSessionException exc) { AssertExtender.Exception("Session is invalid", exc); } }
public void TestUserSearch() { try { var foundUsers = new List <User>(User.Search(TestEnvironment.Session, TestEnvironment.Session.User.Name)); Assert.AreNotEqual(0, foundUsers.Count, "No users were found for search term {0}", TestEnvironment.Session.User.Name); if (foundUsers.Count != 0) { Assert.AreNotEqual(0, foundUsers.First().ID, "ID of the searched user was not set"); } } catch (RequestFailedException exc) { AssertExtender.Exception("A HTTP request failed", exc); } catch (InvalidSessionException exc) { AssertExtender.Exception("Session is invalid", exc); } }
private void TestGetTreasures(Treasure.Query targetStatus) { try { var treasures = TestEnvironment.Session.Profile.GetTreasures(TestEnvironment.Session, targetStatus, 1, 1); if (treasures.Count == 0) { Assert.Fail("No treasures were retrieved"); } if (treasures.Count > 15) { Assert.Fail("Too much treasures were retrieved"); } foreach (var treasure in treasures) { Assert.AreNotEqual(0, treasure.ID, "The ID of a treasure was not set"); Assert.AreNotEqual(0, treasure.Title.Length, "The title of a treasure was not set"); Assert.AreNotEqual(0, treasure.Cost, "The cost of a treasure was not set"); // The bought request needs to have the seller property set while the selled/listed query does not if (targetStatus == Treasure.Query.Bought) { Assert.AreNotEqual(0, treasure.Seller.ID); Assert.AreNotEqual(0, treasure.Seller.Name.Length); } } } catch (RequestFailedException exc) { AssertExtender.Exception("A HTTP request failed", exc); } catch (InvalidSessionException exc) { AssertExtender.Exception("Session is invalid", exc); } }
public void TestThreads() { try { var threads = Section.Main.Threads(TestEnvironment.Session, 1, 1); Assert.AreNotEqual(0, threads.Count, "No threads could be retrieved"); foreach (var thread in threads) { Assert.AreNotEqual(0, thread.ID, "The ID of a thread was not set"); Assert.AreNotEqual(0, thread.InitialPost.Title.Length, "The thread title was not set"); Assert.AreNotEqual(0, thread.Creator.ID, "The ID of the thread creator was not set"); Assert.AreNotEqual(0, thread.Creator.Name.Length, "The name of the thread creator was not set"); } } catch (RequestFailedException exc) { AssertExtender.Exception("A HTTP request failed", exc); } catch (InvalidSessionException exc) { AssertExtender.Exception("Session is invalid", exc); } }