public async void TestPost() { using (var client = server.CreateClient().AcceptJson()) { var step = 1; var service = new StrategicImportanceService(); var countBefore = service.GetAll().Count(); var item = service.GetAll().FirstOrDefault(); if (item == null) { var newItem = new StrategicImportance() { Id = 0, Name = string.Format("StrategicImportance {0}", countBefore) }; service.Add(item); item = service.GetAll().FirstOrDefault(); step = 2; } var response = await client.PostAsJsonAsync("/api/StrategicImportances", item); var result = await response.Content.ReadAsJsonAsync <StrategicImportance>(); var countAfter = service.GetAll().Count(); Assert.Equal(countBefore, countAfter - step); Assert.Equal((int)response.StatusCode, 201); } }
public void TestAdd() { ConfigurationHelper.Ensure(); var service = new StrategicImportanceService(); var countBefore = service.GetAll().Count(); var newItem = new StrategicImportance() { Id = 0, Name = string.Format("StrategicImportance {0}", countBefore) }; service.Add(newItem); var countAfter = service.GetAll().Count(); Assert.Equal(countBefore, countAfter - 1); }