Пример #1
0
        public async Task TestGetAll()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.GetAsync("/Api/v1/Books");

                response.EnsureSuccessStatusCode();

                response.StatusCode.Should().Be(HttpStatusCode.OK);
            }
        }
Пример #2
0
        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);
            }
        }