public void Test_Method_GetTitleListXML() { //Build Connector AnimeNNEncyclopediaConnector con = new AnimeNNEncyclopediaConnector(); //Retrieve data XElement result = con.GetTitleListXML(0, 1000, 0); int actual = (from r in result.Elements("item") select r).Count(); //Assert behaviour Assert.AreEqual<int>(1000, actual); }
public void Test_Method_GetAnimeDetail() { //Create Connector AnimeNNEncyclopediaConnector con = new AnimeNNEncyclopediaConnector(); //Get list of Anime to retrieve details from XElement expected = con.GetTitleListXML(0, 20, APIRequestType.ANIME); //Build Request List<AniMoConsole.src.API.APIRequestDesc> descColl = (from r in expected.Elements("item") select new APIRequestDesc() { RequestType = APIRequestType.ANIME, RequestValue = r.Element("id").Value }).ToList(); //Request Data XElement actual = con.GetItemDetailsXML(descColl); //Check data var results = from r in expected.Elements("item") join a in actual.Elements("anime") on r.Element("id").Value equals a.Attribute("id").Value where r.Element("name").Value == a.Attribute("name").Value select new { NameExpected = r.Element("name").Value, NameActual = a.Attribute("name").Value }; //See if method behaved as expected Assert.AreEqual(results.Count(), 20); }