public async Task drone_getbyidasync() { var httpclient = fixture.Client; if (String.IsNullOrEmpty(TokenTest.TokenValue)) { await TokenTest.token_get(httpclient); } // var util = new UtilityExt(); //MANUAL UPDATES REQUIRED! //todo - add if any parent of the entity //add entity var droneid = await util.addDrone(httpclient); // httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", TokenTest.TokenValue); var response = await httpclient.GetAsync("/api/droneasync/" + droneid.ToString()); response.EnsureSuccessStatusCode(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var jsonString = await response.Content.ReadAsStringAsync(); var vmenitity = JsonConvert.DeserializeObject <DroneViewModel>(jsonString); Assert.True(vmenitity.TestText == "tt updated"); //clean await util.removeDrone(httpclient, droneid); //remove if any parent entity added }
public async Task drone_getall() { var httpclient = fixture.Client; if (String.IsNullOrEmpty(TokenTest.TokenValue)) { await TokenTest.token_get(httpclient); } // var util = new UtilityExt(); //MANUAL UPDATES REQUIRED! //todo - add if any parent of the entity //add entity var droneid = await util.addDrone(httpclient); // httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", TokenTest.TokenValue); var response = await httpclient.GetAsync("/api/drone"); response.EnsureSuccessStatusCode(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var jsonString = await response.Content.ReadAsStringAsync(); var vmenititys = (ICollection <UserViewModel>)JsonConvert.DeserializeObject <IEnumerable <UserViewModel> >(jsonString); Assert.True(vmenititys.Count > 0); // lazy-loading test if entity has children response = await httpclient.GetAsync("/api/drone/" + droneid.ToString()); response.EnsureSuccessStatusCode(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); jsonString = await response.Content.ReadAsStringAsync(); var vmenitity = JsonConvert.DeserializeObject <DroneViewModel>(jsonString); //Assert.True(vmenitity.Kids.Count == 1); //clean await util.removeDrone(httpclient, droneid); //remove if any parent entity added }