I am just playing around with some Json and Fluentassertions, I am able to make a call to an API successfully, get the results, deserialize them but for some reason when i get to do an assertion on the response its losing the data and it empty. I have debugged, can see the data flowing through and then losing it during assertion.
Any help appreciated.
Код: Выделить всё
{ [TestClass] public class UnitTest1 { HttpClient client = new HttpClient(); [TestMethod] public void ActorNotInSeason6Episode1() { try { //test = extent.CreateTest("Test 1"); HttpResponseMessage respone = client.GetAsync("https://api.themoviedb.org/3/tv/1399/season/6/episode/1/credits?api_key=").Result; Assert.IsTrue(respone.IsSuccessStatusCode.Equals(true)); string ResponseMessage = respone.Content.ReadAsStringAsync().Result; Actors actors = JsonConvert.DeserializeObject(ResponseMessage); //var a = Actors.cast["cast"]; //var names = a.Children[]; //var a = actors.cast.Children(); actors.cast.Should().Contain("Emilia Clarke", "Test"); } catch(AssertFailedException) { Assert.Fail(); } } } } class Actors { public JArray cast { get; set; } public JArray guest_stars { get; set; } } } Код: Выделить всё
{[ { "character": "Daenerys Targaryen", "credit_id": "5256c8af19c2956ff60479f6", "gender": 1, "id": 1223786, "name": "Emilia Clarke", "order": 0, "profile_path": "/lRSqMNNhPL4Ib1hAJxmDFBXHAMU.jpg" } ]} Источник: https://stackoverflow.com/questions/534 ... ns-on-json
Мобильная версия