/// <summary> /// Method calls domain functionality to get list of Starships /// </summary> /// <returns></returns> public static List <StarShip> GetStarShips() { if (starShipList.Count == 0) { string url = "https://swapi.co/api/starships/"; bool hasNextPage = true; while (hasNextPage) { var starships = SWDomainRequests.GetStarshipList(@url); url = starships.SelectToken("next").ToString(); if (url == null || url == "") { hasNextPage = false; } foreach (var starShip in starships.SelectToken("results")) { if (!(starShip.SelectToken("consumables").ToString().ToLower().Equals("unknown") || starShip.SelectToken("MGLT").ToString().ToLower().Equals("unknown"))) { starShipList.Add(ResolveStarship(starShip)); } } } } return(starShipList); }
public void TestMethodApiRequest() { var test1 = SWDomainRequests.GetStarshipList(@"https://swapi.co/api/starships/"); Assert.IsNotNull(test1); }