예제 #1
0
 public void can_write_strings_to_the_output()
 {
     HarnessApplication.Run(endpoints => {
         endpoints.Get <StringEndpoint>(x => x.get_hello()).ContentShouldBe(MimeType.Text, "Hello.")
         .StatusCode.ShouldEqual(HttpStatusCode.OK);
     });
 }
예제 #2
0
 public void read_custom_header()
 {
     HarnessApplication.Run(x => {
         x.GetByInput(new HeaderRequest
         {
             Name = "x-1"
         }, configure: req => req.Headers["x-1"] = "A").ReadAsText().ShouldEqual("A");
     });
 }
예제 #3
0
 public void read_build_in_header()
 {
     HarnessApplication.Run(x => {
         x.GetByInput(new HeaderRequest
         {
             Name = HttpRequestHeaders.IfNoneMatch
         }, configure: req => req.Headers[HttpRequestHeaders.IfNoneMatch] = "A").ReadAsText().ShouldEqual("A");
     });
 }
예제 #4
0
 public void bind_data_against_routing_data()
 {
     HarnessApplication.Run(x => {
         x.GetByInput(new RouteInput {
             Name = "Jeremy",
             Age  = 38
         }).ReadAsText()
         .ShouldEqual("Name=Jeremy, Age=38");
     });
 }
예제 #5
0
        public void can_write_the_contents_of_a_file_to_the_output()
        {
            HarnessApplication.Run(x => {
                var response = x.GetByInput(new FileInput
                {
                    Name = "Test.txt"
                });

                response.ContentTypeShouldBe(MimeType.Text);
                response.ReadAsText().ShouldContain("Some text here");
            });
        }
예제 #6
0
        public void read_and_write_json()
        {
            HarnessApplication.Run(x => {
                var message = new Message
                {
                    Color     = "Blue",
                    Direction = "East"
                };

                var response = x.PostJson(message, contentType: "text/json", accept: "text/json");

                response.StatusCodeShouldBe(HttpStatusCode.OK);
                response.ContentType.ShouldEqual("text/json");

                response.ReadAsJson <Message>().ShouldEqual(message);
            });
        }
예제 #7
0
        public void read_and_write_xml()
        {
            HarnessApplication.Run(x => {
                var message = new Message
                {
                    Color     = "Blue",
                    Direction = "East"
                };

                var response = x.PostXml(message, contentType: "text/xml", accept: "text/xml");

                response.StatusCodeShouldBe(HttpStatusCode.OK);
                response.ContentType.ShouldEqual("text/xml");

                var serializer = new XmlSerializer(typeof(Message));
                serializer.Deserialize(new XmlTextReader(new StringReader(response.ReadAsText()))).ShouldEqual(message);
            });
        }
예제 #8
0
 public void can_write_a_different_status_code()
 {
     HarnessApplication.Run(endpoints => {
         endpoints.Get <StatusCodeEndpoint>(x => x.get_not_modified()).StatusCodeShouldBe(HttpStatusCode.NotModified);
     });
 }