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