public void Insert() { //Setup Gender gender = new Gender { Description = "SLTEST" }; GenderList genders = new GenderList(); genders.Load(); int originalCount = genders.Count(); //Act HttpClient client = InitializeClient(); //Serialize a gender object that we're trying to insert string serializedGender = JsonConvert.SerializeObject(gender); var content = new StringContent(serializedGender); content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); HttpResponseMessage response = client.PostAsync("Gender", content).Result; //Assert genders.Clear(); genders.Load(); Assert.AreEqual(originalCount + 1, genders.Count); }
public void Delete() { //Setup GenderList genders = new GenderList(); genders.Load(); int originalCount = genders.Count(); Gender gender = genders.FirstOrDefault(g => g.Description == "SLTEST1"); //Act if (gender != null) { HttpClient client = InitializeClient(); HttpResponseMessage response = client.DeleteAsync("Gender/" + gender.Id).Result; } //Assert genders.Clear(); genders.Load(); Assert.AreEqual(originalCount - 1, genders.Count); }