public async void TestPut() { using (var client = server.CreateClient().AcceptJson()) { var service = new StrategicImportanceService(); var item = service.GetAll().FirstOrDefault(); if (item == null) { this.TestPost(); item = service.GetAll().FirstOrDefault(); } var itemId = item.Id; string unique = (Guid.NewGuid()).ToString(); item.Name = unique; var response = await client.PutAsJsonAsync(string.Format("/api/StrategicImportances/{0}", itemId), item); var result = await response.Content.ReadAsJsonAsync <StrategicImportance>(); item = service.GetById(itemId); Assert.True(item.Name.Equals(unique, StringComparison.OrdinalIgnoreCase)); Assert.Equal((int)response.StatusCode, 200); } }
public void TestUpdate() { ConfigurationHelper.Ensure(); var service = new StrategicImportanceService(); var item = service.GetAll().FirstOrDefault(); if (item == null) { this.TestAdd(); item = service.GetAll().FirstOrDefault(); } var itemId = item.Id; string unique = (Guid.NewGuid()).ToString(); item.Name = unique; service.Update(item); item = service.GetById(itemId); Assert.True(item.Name.Equals(unique, StringComparison.OrdinalIgnoreCase)); }