Beispiel #1
0
        /// <summary>
        /// The delete.
        /// </summary>
        /// <param name="user">
        /// The user.
        /// </param>
        private void Delete(GetUser user)
        {
            // Act
            var response = Client.DeleteAsync(GetUrRequestUri(user)).Result;
            var deletedStatus = Client.GetAsync(GetUrRequestUri(user)).Result.StatusCode;

            // Assert
            Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode, "DELETE User not No Content.");
            Assert.AreEqual(HttpStatusCode.NotFound, deletedStatus, "DELETE User not deleted.");
        }
Beispiel #2
0
        /// <summary>
        /// The put.
        /// </summary>
        /// <param name="user">
        /// The user.
        /// </param>
        private void Put(GetUser user)
        {
            // Arrange
            user.Username = RandomGenerator.GetRandomString(10);

            // Act
            var response = Client.PutAsJsonAsync(GetUrRequestUri(user), user).Result;

            // Assert
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "PUT User not OK.");
            Assert.AreEqual(user.Username, Get(user).Username, "PUT User not updated.");
        }
Beispiel #3
0
        /// <summary>
        /// The get.
        /// </summary>
        /// <param name="user">
        /// The user.
        /// </param>
        /// <returns>
        /// The <see cref="GetUser"/>.
        /// </returns>
        private GetUser Get(GetUser user)
        {
            // Act
            var response = Client.GetAsync(GetUrRequestUri(user)).Result;

            // Assert
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "Get user by ID not OK.");

            return response.Content.ReadAsAsync<GetUser>().Result;
        }
Beispiel #4
0
 /// <summary>
 /// The get ur request uri.
 /// </summary>
 /// <param name="user">
 /// The user.
 /// </param>
 /// <returns>
 /// The <see cref="string"/>.
 /// </returns>
 private static string GetUrRequestUri(GetUser user)
 {
     return string.Format("{0}/{1}", Resources.Users, user.ID);
 }