public void TestCats() { var response = httpCommunication.Execute(UrlList.PetsUrl, null, "GET", "application/json", typeof(List <Person>)); Assert.IsTrue(CheckTypeAndData(response)); var typedResponse = (List <Person>)response; var onlyCats = new List <Pet>(); foreach (var person in typedResponse.Where(a => a.pets != null)) { foreach (var pet in person.pets.Where(a => a.type?.ToLower() == "cat")) { onlyCats.Add(pet); } } DataManip dataManip = new DataManip(); var resultFromDataManip = dataManip.GetAllCats(typedResponse, false); var firstNotSecond = onlyCats.Except(resultFromDataManip).ToList(); var secondNotFirst = resultFromDataManip.Except(onlyCats).ToList(); Assert.IsTrue(onlyCats.Count == resultFromDataManip.Count); Assert.IsFalse(!onlyCats.Any() && !secondNotFirst.Any()); }
static void Main(string[] args) { var httpCommunication = new HttpComm(); var response = httpCommunication.Execute(UrlList.PetsUrl, null, "GET", "application/json", typeof(List <Person>)); if (!(response is List <Person>)) { Console.WriteLine($"Response is not of desired type!"); } var typedResponse = ((List <Person>)response).ToList(); DataManip dataManip = new DataManip(); dataManip.GetAllCats(typedResponse, true); Console.WriteLine("press any key..."); Console.ReadKey(); }