public void return_a_correct_response_for_a_post_request() { using (var httpClient = new HttpClientFactory().Create()) { var entry = new { id = new Guid().ToString(), name = "John Smith", email = "*****@*****.**", active = true, creationTime = new DateTime(2016, 1, 1) }; var response = httpClient.PostAsJsonAsync("", entry).Result; Assert.True(response.IsSuccessStatusCode, "Status code: " + response.StatusCode); } }
public void return_a_posted_entry_after_a_post_request() { using (var httpClient = new HttpClientFactory().Create()) { var json = new { id = new Guid(), name = "John Smith", email = "*****@*****.**", active = true, creationTime = new DateTime(2016, 1, 1) }; var expected = json.ToJObject(); httpClient.PostAsJsonAsync("", json).Wait(); var response = httpClient.GetAsync("").Result; var actual = response.Content.ReadAsJsonAsync().Result; Assert.Contains(expected, actual.appUsers); } }