Ejemplo n.º 1
0
 public void GetReturns4t6()
 {
     var responseHeaders = new Dictionary<string, string[]>();
     var responseStream = new MemoryStream();
     var requestBody = new MemoryStream();
     
     //set status code defaults to 200, so it's not called
     Action<int> setStatusCode = i => {};
     var runtime = new Runtime();
     var resource = new TestResource();
     runtime.RegisterResource(resource);
     
     var task = runtime.HandleRequest("GET", "foo/yippy", "x=4&y=t6", responseHeaders, requestBody, responseHeaders,
         responseStream, setStatusCode);
     Task.WaitAll(task);
     
     responseStream.Position = 0;
     
     using (var reader = new StreamReader(responseStream, Encoding.UTF8))
     {
         var response = reader.ReadToEnd();
         Assert.Equal("4t6", response);
     }
     
     
     
     //TODO: test content type, etc once they're not hard coded
 }
Ejemplo n.º 2
0
 public void GetReturns404()
 {
     var responseHeaders = new Dictionary<string, string[]>();
     var responseStream = new MemoryStream();
     var requestBody = new MemoryStream();
     
     var statusCode = 0;
     
     Action<int> setStatusCode = i => { statusCode = i; };
     var runtime = new Runtime();
     var resource = new TestResource();
     runtime.RegisterResource(resource);
     
     var task = runtime.HandleRequest("GET", "foo2", "", responseHeaders, requestBody, responseHeaders,
         responseStream, setStatusCode);
     Task.WaitAll(task);
     
     responseStream.Position = 0;
     
     using (var reader = new StreamReader(responseStream, Encoding.UTF8))
     {
         var response = reader.ReadToEnd();
         Assert.True(response.EndsWith("not found"));
     }
     
     Assert.Equal(404, statusCode);
 }
Ejemplo n.º 3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app)
        {
            var runtime = new Runtime();
            runtime.RegisterResource(new FooResource());
            app.UseOwin(builder => builder.UseTurquoise(runtime));
            //app.UseServer();
            
            // app.UseIISPlatformHandler();

            // app.Run(async (context) =>
            // {
            //     await context.Response.WriteAsync("Hello World!");
            // });
        }
Ejemplo n.º 4
0
 public void TokenizedRouteSetsParameters()
 {
     var responseHeaders = new Dictionary<string, string[]>();
     var responseStream = new MemoryStream();
     var requestBody = new MemoryStream();
     
     //set status code defaults to 200, so it's not called
     Action<int> setStatusCode = i => {};
     var runtime = new Runtime();
     var resource = new TestResource();
     runtime.RegisterResource(resource);
     
     var task = runtime.HandleRequest("GET", "foo/yippy/4/t6", "", responseHeaders, requestBody, responseHeaders,
         responseStream, setStatusCode);
     Task.WaitAll(task);
     
     responseStream.Position = 0;
     
     using (var reader = new StreamReader(responseStream, Encoding.UTF8))
     {
         var response = reader.ReadToEnd();
         Assert.Equal("4t6", response);
     }
 }