public void Update() { GenderList genders = new GenderList(); genders.Load(); Gender gender = genders.FirstOrDefault(g => g.Description == "SLTEST"); Gender retrievedGender = new Gender(); if (gender != null) { retrievedGender.Id = gender.Id; gender.Description = "SLTEST1"; //Act HttpClient client = InitializeClient(); //Serialize a question 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.PutAsync("Gender/" + gender.Id, content).Result; retrievedGender.LoadById(); } //Assert Assert.AreEqual(gender.Description, retrievedGender.Description); }
public void DeleteTest() { Gender gender = new Gender(); GenderList genders = new GenderList(); genders.Load(); gender = genders.FirstOrDefault(g => g.Description == "Update"); int results = gender.Delete(); Assert.IsTrue(results == 1); }
public void LoadById() { Gender gender = new Gender(); GenderList genders = new GenderList(); genders.Load(); gender = genders.FirstOrDefault(g => g.Description == "Update"); Gender newGender = new Gender { Id = gender.Id }; newGender.LoadById(); Assert.AreEqual(gender.Description, newGender.Description); }
private void cboComposer_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (cboComposer.SelectedItem != null) { Composer composer = composers.ElementAt(cboComposer.SelectedIndex); // Change the boxes on screen based on selected object txtFirstName.Text = composer.FirstName; txtLastName.Text = composer.LastName; txtBio.Text = composer.Bio; cboLocation.SelectedItem = locations.FirstOrDefault(l => l.Id == composer.LocationId); cboGender.SelectedItem = genders.FirstOrDefault(g => g.Id == composer.GenderId); cboRace.SelectedItem = races.FirstOrDefault(r => r.Id == composer.RaceId); } btnSave.Content = "Save Composer"; }
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); }
public void GetOne() { //Setup Gender gender = new Gender(); Gender retrievedGender = new Gender(); GenderList genders = new GenderList(); genders.Load(); gender = genders.FirstOrDefault(g => g.Description == "Male"); //Act if (gender != null) { HttpClient client = InitializeClient(); HttpResponseMessage response = client.GetAsync("Gender/" + gender.Id).Result; string result = response.Content.ReadAsStringAsync().Result; retrievedGender = JsonConvert.DeserializeObject <Gender>(result); } //Assert Assert.IsTrue(gender.Description == retrievedGender.Description && !string.IsNullOrEmpty(retrievedGender.Description)); }