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); }); }
public void can_write_etag() { HarnessApplication.Run(endpoints => { var response = endpoints.Get <ResponseHeadersEndpoint>(x => x.get_etag()); response.ResponseHeaderFor(HttpResponseHeaders.ETag).ShouldEqual("123456"); }); }
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"); }); }
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"); }); }
public void can_write_multiple_cookies() { HarnessApplication.Run(endpoints => { var response = endpoints.Get <ResponseHeadersEndpoint>(x => x.get_multiple_cookies()); response.Cookies["Foo"].Value.ShouldEqual("1"); response.Cookies["Bar"].Value.ShouldEqual("2"); }); }
public void can_write_built_in_response_headers() { HarnessApplication.Run(endpoints => { Thread.Sleep(100); //mono ci build hack, maybe static state in Harness? var response = endpoints.Get <ResponseHeadersEndpoint>(x => x.get_response_headers()); response.ResponseHeaderFor(HttpResponseHeaders.KeepAlive).ShouldEqual("True"); response.ResponseHeaderFor(HttpResponseHeaders.Server).ShouldStartWith("Server1"); }); }
public void can_write_extension_headers() { HarnessApplication.Run(endpoints => { var response = endpoints.Get <ResponseHeadersEndpoint>(x => x.get_response_headers()); response.ResponseHeaderFor("x-1").ShouldEqual("a"); response.ResponseHeaderFor("x-2").ShouldEqual("b"); }); }
public void bind_data_against_routing_data() { HarnessApplication.Run(x => { x.GetByInput(new RouteInput { Name = "Jeremy", Age = 38 }).ReadAsText() .ShouldEqual("Name=Jeremy, Age=38"); }); }
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"); }); }
public void can_write_content_headers() { HarnessApplication.Run(endpoints => { var response = endpoints.Get <ResponseHeadersEndpoint>(x => x.get_content_headers()); response.ResponseHeaderFor(HttpResponseHeaders.ContentMd5).ShouldEqual("A"); response.ResponseHeaderFor(HttpResponseHeaders.ContentDisposition).ShouldEqual("B"); response.ResponseHeaderFor(HttpResponseHeaders.ContentLocation).ShouldEqual("C"); response.ResponseHeaderFor(HttpResponseHeaders.Allow).ShouldEqual("D"); response.ResponseHeaderFor(HttpResponseHeaders.ContentEncoding).ShouldEqual("UTF-16"); response.ResponseHeaderFor(HttpResponseHeaders.ContentLength).ShouldEqual("19"); response.ResponseHeaderFor(HttpResponseHeaders.ContentLanguage).ShouldEqual("jp-JP"); response.ResponseHeaderFor(HttpResponseHeaders.ContentRange).ShouldEqual("E"); response.ResponseHeaderFor(HttpResponseHeaders.Expires).ShouldEqual("5"); response.ResponseHeaderFor(HttpResponseHeaders.LastModified).ShouldEqual("12345"); }); }
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); }); }
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); }); }
public void can_write_a_different_status_code() { HarnessApplication.Run(endpoints => { endpoints.Get <StatusCodeEndpoint>(x => x.get_not_modified()).StatusCodeShouldBe(HttpStatusCode.NotModified); }); }