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

            // Assert
            Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode, "DELETE Competition not No Content.");
            Assert.AreEqual(HttpStatusCode.NotFound, deletedStatus, "DELETE Competition not deleted.");
        }
Beispiel #2
0
        /// <summary>
        /// The get.
        /// </summary>
        /// <param name="competition">
        /// The competition.
        /// </param>
        /// <returns>
        /// The <see cref="GetCompetition"/>.
        /// </returns>
        private GetCompetition Get(GetCompetition competition)
        {
            // Act
            var response = Client.GetAsync(GetUrRequestUri(competition)).Result;

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

            return response.Content.ReadAsAsync<GetCompetition>().Result;
        }
Beispiel #3
0
 /// <summary>
 /// The get ur request uri.
 /// </summary>
 /// <param name="competition">
 /// The competition.
 /// </param>
 /// <returns>
 /// The <see cref="string"/>.
 /// </returns>
 private static string GetUrRequestUri(GetCompetition competition)
 {
     return string.Format("{0}/{1}", Resources.Competitions, competition.Id);
 }
Beispiel #4
0
        /// <summary>
        /// The put.
        /// </summary>
        /// <param name="competition">
        /// The competition.
        /// </param>
        private void Put(GetCompetition competition)
        {
            // Arrange
            var putCompetition = new PutCompetition()
                {
                    Answers = new[] {"A", "B", "C", "D"}, 
                    ClosingDate = DateTime.Now.AddMonths(1), 
                    CorrectAnswerKey = 1, 
                    Question = "Test Question"
                };

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

            // Assert
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "PUT Competition not OK.");
            Assert.AreEqual(putCompetition.Question, Get(competition).Question, "PUT Competition not updated.");
        }