public async Task should_provide_enumerable_independently()
        {
            var server = new InMemoryHost(() =>
            {
                ResourceSpace.Has.ResourcesNamed("multipart_parser")
                .AtUri("/multipart/{id}")
                .HandledBy <MultiPartHandler>();
            });
            var response = await server.Post(
                "/multipart/1",
                contentType : "multipart/form-data;boundary=bound",
                content : @"
--bound
Content-Disposition: form-data; name=""id""

1
--bound
Content-Disposition: form-data; name=""another""

another
--bound--
");

            response.StatusCode.ShouldBe(200);
            response.ReadString().ShouldBe("id=1;count=1");
        }
        public async Task is_processed()
        {
            var server = new InMemoryHost(() => ResourceSpace.Has
                                          .ResourcesOfType <DemoResource>()
                                          .AtUri("/demo")
                                          .HandledBy <DemoResourceHandler>()
                                          .TranscodedBy <DemoResourceReader>().ForMediaType("*/*"));

            var response = await server.Post("/demo", "data");

            response.StatusCode.ShouldBe(204);
        }
Пример #3
0
        public static async Task <(IResponse, JToken)> PostJsonLd(this InMemoryHost host, string uri, string content)
        {
            var response = await host.Post(uri, content, contentType : "application/ld+json", accept : "application/ld+json");

            if (response.StatusCode / 100 != 2)
            {
                throw new InvalidOperationException($"Returned a {response.StatusCode} status code");
            }
            var responseBody = response.ReadString();

            return(response, JObject.Parse(responseBody));
        }
Пример #4
0
        public async Task response_is_400()
        {
            var server = new InMemoryHost(() => ResourceSpace.Has
                                          .ResourcesOfType <DemoResource>()
                                          .AtUri("/demo")
                                          .HandledBy <DemoHandler>()
                                          .TranscodedBy <ThrowingCodec>().ForMediaType("*/*")
                                          );
            var response = await server.Post("/demo", "yo");

            response.StatusCode.ShouldBe(400);
        }
Пример #5
0
        public async Task should_return_400()
        {
            var server = new InMemoryHost(() =>
            {
                ResourceSpace.Has.ResourcesNamed("multipart_parser")
                .AtUri("/multipart/")
                .HandledBy <DoNothing>();
            });
            var response = await server.Post(
                "/multipart/",
                contentType : "multipart/form-data;boundary=bound4",
                content : @"
--bound4
Content-Disposition: form-data; name=""id""

1
");

            response.StatusCode.ShouldBe(400);
        }
        public async Task post_with_uri_var_gets_selected()
        {
            var response = await server.Post("/account/1/domain/new", "my new stuff");

            response.ReadString().ShouldBe("POST:1");
        }