Exemplo n.º 1
0
 public void Build_returns_404_by_default()
 {
     var builder = new AppBuilder();
     var app = builder.Materialize();
     var callResult = AppUtils.Call(app);
     Assert.That(callResult.Status, Is.EqualTo("404 Not Found"));
 }
Exemplo n.º 2
0
        public Task Build_returns_404_by_default()
        {
            var builder = new AppBuilder();
            var app = builder.Materialize<AppDelegate>();
            var client = TestHttpClient.ForAppDelegate(app);

            return client.GetAsync("http://localhost")
                .Then(response => response.StatusCode.ShouldBe(HttpStatusCode.NotFound));
        }
Exemplo n.º 3
0
        public void Method_that_returns_app_action_may_also_be_called()
        {
            var loader = new StartupLoader();
            var configuration = loader.Load("Gate.Builder.Tests.Loader.DefaultConfigurationLoaderTests.Alpha");

            var builder = new AppBuilder();
            configuration(builder);
            var app = builder.Materialize<AppDelegate>();

            _alphaCalls = 0;
            app(new Dictionary<string, object>(), null, null);
            Assert.That(_alphaCalls, Is.EqualTo(1));
        }
Exemplo n.º 4
0
        public void Use_middleware_between_calls_to_map_only_apply_to_requests_that_reach_later_maps()
        {
            var builder = new AppBuilder();
            builder
                .Use(AddStatus, " Outer")
                .Map("/here1", map => map
                    .Use(AddStatus, " Mapped1")
                    .Run(TwoHundredFoo))
                .Use(AddStatus, " Between")
                .Map("/here2", map => map
                    .Use(AddStatus, " Mapped2")
                    .Run(TwoHundredFoo))
                .Use(AddStatus, " Inner")
                .Run(TwoHundredFoo);

            var app = builder.Materialize();

            var resultThere = AppUtils.Call(app, "/there");
            var resultHere1 = AppUtils.Call(app, "/here1");
            var resultHere2 = AppUtils.Call(app, "/here2");

            Assert.That(resultThere.Status, Is.EqualTo("200 Foo Inner Between Outer"));
            Assert.That(resultHere1.Status, Is.EqualTo("200 Foo Mapped1 Outer"));
            Assert.That(resultHere2.Status, Is.EqualTo("200 Foo Mapped2 Between Outer"));
        }
Exemplo n.º 5
0
        //private static IDisposable StartupWorkingTitleApp()
        //{
        //    var server = new Server((req, resp) =>
        //                                {
        //                                    resp.Write("Hello, again, world");
        //                                    resp.End();
        //                                });
        //    server.Listen(8081, null);
        //    return server;
        //}
        private static IDisposable StartupNancyApp()
        {
            var builder = new AppBuilder();

            builder
                .Use(SetResponseHeader, "X-Server", "Dragonfly")
                .Use(ShowCalls)
                .UseWebSockets("/socketserver", OnConnection)
                .UseChunked()
                .RunNancy();

            var app = builder.Materialize<AppDelegate>();
            var server = new ServerFactory(new StdoutTrace()).Create(app, 8080);

            Console.WriteLine("Running on localhost:8080");
            return server;
        }