Ejemplo n.º 1
0
        public void DeleteBookingReturns201()
        {
            BookingPayload payload = new BookingPayload();

            payload.SetFirstname("Mary");
            payload.SetLastname("White");
            payload.SetTotalPrice(200);
            payload.SetDepositPaid(true);
            payload.SetBookingDates(new BookingDatesPayload(new DateTime(2017, 3, 31), new DateTime(2017, 4, 3)));
            payload.SetAdditionalNeeds("None");

            var    response        = Booking.PostBooking(payload);
            string responsePayload = response.Content.ReadAsStringAsync().Result;
            BookingResponsePayload bookingResponse = JsonConvert.DeserializeObject <BookingResponsePayload>(responsePayload);

            AuthPayload authPayload = new AuthPayload();

            authPayload.SetUsername("admin");
            authPayload.SetPassword("password123");

            AuthResponsePayload authResponse = Auth.PostAuth(authPayload);

            var deleteResponse = Booking.DeleteBooking(bookingResponse.bookingid, authResponse.token);

            Assert.IsTrue(deleteResponse.StatusCode == HttpStatusCode.Created, "Http Status Code is not 201");
        }
Ejemplo n.º 2
0
        public void PostBookingReturns200()
        {
            BookingPayload payload = new BookingPayload();

            payload.SetFirstname("Mary");
            payload.SetLastname("White");
            payload.SetTotalPrice(200);
            payload.SetDepositPaid(true);
            payload.SetBookingDates(new BookingDatesPayload(new DateTime(2017, 3, 31), new DateTime(2017, 4, 3)));
            payload.SetAdditionalNeeds("None");

            var response = Booking.PostBooking(payload);

            Assert.IsTrue(response.IsSuccessStatusCode, "Status Code is not 200");
        }
Ejemplo n.º 3
0
        public static HttpResponseMessage PostBooking(BookingPayload payload)
        {
            var    bookingUrl  = _baseUrl + "/booking/";
            string requestBody = JsonConvert.SerializeObject(payload);

            using (var httpClient = new HttpClient())
            {
                using (HttpRequestMessage request = new HttpRequestMessage {
                    RequestUri = new Uri(bookingUrl), Method = HttpMethod.Post
                })
                {
                    request.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
                    //request.Headers.Add("Content-Type", "application/json");
                    request.Headers.Add("Accept", "application/json");
                    var response = httpClient.SendAsync(request).Result;
                    CheckFor200Response(response);
                    return(response);
                }
            }
        }
Ejemplo n.º 4
0
 public void SetBooking(BookingPayload booking)
 {
     this.booking = booking;
 }