Ejemplo n.º 1
0
        public void the_key_value_pairs_are_matched_to_string_parameters()
        {
            given_request_as_url_form_encoded("PUT", "/flat/3", "firstname=John&lastname=Doe", "utf-8");

            when_reading_response_as_a_string(Encoding.GetEncoding("utf-8"));
            TheResponseAsString.ShouldBe("Flat3JohnDoe");
        }
Ejemplo n.º 2
0
        public void the_pairs_are_matched_to_complex_parameters()
        {
            given_request_as_url_form_encoded("PUT", "/constructed/3", "Customer.FirstName=John&Customer.LastName=Doe",
                                              "utf-8");

            when_reading_response_as_a_string(Encoding.GetEncoding("utf-8"));
            TheResponse.StatusCode.ShouldBe(HttpStatusCode.OK);
            TheResponseAsString.ShouldBe("Constructed3JohnDoe");
        }
 public void second_request_is_successful()
 {
     GivenARequest("GET", "/customer");
     TheResponse.StatusCode.ShouldBe(HttpStatusCode.InternalServerError);
     GivenARequest("GET", "/customer/success");
     TheResponse.StatusCode.ShouldBe(HttpStatusCode.OK);
     TheResponse.ContentLength.ShouldBe(5);
     GivenTheResponseIsInEncoding(Encoding.UTF8);
     TheResponseAsString.ShouldBe("hello");
 }
        public void the_response_is_formatted_in_text_plain()
        {
            given_request("GET", "/3");
            when_reading_response_as_a_string(Encoding.ASCII);

            TheResponse.StatusCode.ShouldBe(HttpStatusCode.OK);
            TheResponse.ContentType.ShouldContain("text/plain");

            TheResponseAsString.ShouldBe("Customer with id 3");
        }
        public void the_request_is_matched_to_the_parameter()
        {
            given_request_as_string("PATCH", "/3", "new customer name", "UTF-16");
            when_reading_response_as_a_string(Encoding.ASCII);

            TheResponse.StatusCode.ShouldBe(HttpStatusCode.OK);
            TheResponse.ContentType.ShouldContain("text/plain");

            TheResponseAsString.ShouldBe("new customer name");
        }
Ejemplo n.º 6
0
        public void the_request_is_matched_to_the_parameter()
        {
            GivenATextRequest("PATCH", "/3", "new customer name", "UTF-16");
            GivenTheResponseIsInEncoding(Encoding.ASCII);

            TheResponse.StatusCode.ShouldBe(HttpStatusCode.OK);
            TheResponseAsString.ShouldBe("new customer name");
            TheResponse.Headers["Location"].ShouldBe("http://127.0.0.1:6688/3");

            TheResponse.ContentType.ShouldContain("text/plain");
        }
        public void a_response_is_received_upon_a_get()
        {
            try
            {
                var id = Random.Next();
                given_request("GET", "/customers/" + id);
                when_reading_response_as_a_string(Encoding.ASCII);

                TheResponse.StatusCode.ShouldBe(HttpStatusCode.OK);
                TheResponseAsString.ShouldBe(id.ToString());
            }
            catch (Exception e)
            {
                collectedException = e;
                throw;
            }
            finally
            {
                Done.Set();
            }
        }
Ejemplo n.º 8
0
 private void ThenResultShouldBe(string expected)
 {
     TheResponseAsString.ShouldEqual(expected);
 }