public async Task TestDeleteSingle() { using (var client = new TestClientProvider().Client) { var response = await client.DeleteAsync("/Api/v1/Books/1"); response.EnsureSuccessStatusCode(); response.StatusCode.Should().Be(HttpStatusCode.OK); } }
public async Task TestPost() { using (var client = new TestClientProvider().Client) { var response = await client.PostAsync("/Api/v1/Books", new StringContent(JsonConvert.SerializeObject( new Book() { Author = "Dostoyevski", Title = "Karamazof Brothers 2", Price = 300, CoverImage = "karamazov.jpg", Description = "It's Dostoyevski." }), Encoding.UTF8, "application/json")); response.StatusCode.Should().Be(HttpStatusCode.Created); } }
public async Task TestGetSingle() { using (var client = new TestClientProvider().Client) { var response = await client.GetAsync("/Api/v1/Books/1"); response.EnsureSuccessStatusCode(); try { var testBook = JsonConvert.DeserializeObject <Book>(response.Content.ReadAsStringAsync().Result); } catch (Exception) { Assert.True(false, "Returned Json is not a Book object."); } response.StatusCode.Should().Be(HttpStatusCode.OK); } }