public async Task GetAllReviewsForAllTapes()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.GetAsync("/v1/api/tapes/reviews");

                response.EnsureSuccessStatusCode();
                Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            }
        }
        public async Task GetUserByValidID()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.GetAsync("/v1/api/users/1");

                response.EnsureSuccessStatusCode();
                string data = await response.Content.ReadAsStringAsync();

                UserDetailDTO user = JsonConvert.DeserializeObject <UserDetailDTO>(data);
                Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
                Assert.AreEqual(1, user.Id);
            }
        }
        public async Task GetAllReviewsForUser()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.GetAsync("/v1/api/users/100/reviews");

                response.EnsureSuccessStatusCode();
                string data = await response.Content.ReadAsStringAsync();

                IEnumerable <ReviewDTO> reviews = JsonConvert.DeserializeObject <IEnumerable <ReviewDTO> >(data);
                Assert.IsNotNull(reviews);
                Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            }
        }
        public async Task DeleteUserValidId()
        {
            using (var client = new TestClientProvider().Client)
            {
                var data = await client.GetAsync("/v1/api/users");

                string json = await data.Content.ReadAsStringAsync();

                IEnumerable <UserDTO> users = JsonConvert.DeserializeObject <IEnumerable <UserDTO> >(json);
                var maxId    = users.Max(u => u.Id);
                var response = await client.DeleteAsync($"/v1/api/users/{maxId}");

                response.EnsureSuccessStatusCode();
                Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode);
            }
        }
Ejemplo n.º 5
0
        public async Task GetTapesOnLoanForUserInvalidUserId()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.GetAsync("/v1/api/users/99999/tapes");

                response.EnsureSuccessStatusCode();

                string json = await response.Content.ReadAsStringAsync();

                IEnumerable <TapeDTO> tapes = JsonConvert.DeserializeObject <IEnumerable <TapeDTO> >(json);
                var tape = tapes.FirstOrDefault(t => t.Id == 10);
                Assert.IsNotNull(tape);
                Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            }
        }
        public async Task GetUserReviewForTape()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.GetAsync("/v1/api/users/100/reviews/10");

                response.EnsureSuccessStatusCode();
                string data = await response.Content.ReadAsStringAsync();

                ReviewDTO review = JsonConvert.DeserializeObject <ReviewDTO>(data);
                Assert.IsNotNull(review);
                Assert.AreEqual(review.UserId, 100);
                Assert.AreEqual(review.TapeId, 10);
                Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            }
        }