예제 #1
0
        public void EmptyResponsePageTest()
        {
            Action<IAppBuilder> config = (builder) =>
            {
                builder.Use(typeof(EmptyResponseApplication));
            };

            using (var server = new FosSelfHost(config))
            {
                server.Bind(ListenOn, ListenPort);
                server.Start(true);

                System.Threading.Thread.Sleep(100);

                // Make the request and expect the empty response page with 500 status code
                var browser = new Browser(ListenOn, ListenPort);
                using (var response = browser.ExecuteRequest("http://localhost/", "GET"))
                {
                    var emptyResponsePage = new EmptyResponsePage();

                    //Assert.AreNotEqual(0, response.AppStatusCode);
                    Assert.AreEqual(500, response.HttpStatusCode);
                    Assert.AreEqual(emptyResponsePage.Contents, ReadStream(response.ResponseBody));
                }
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: ss22219/Booker
 public static void FastCgi(int port)
 {
     var startup = new Startup();
     using (var fosServer = new FosSelfHost(startup.Configuration))
     {
         fosServer.Bind(System.Net.IPAddress.Loopback, port);
         fosServer.Start(false);
     }
 }
예제 #3
0
파일: SocketTests.cs 프로젝트: knocte/Fos
        protected FosSelfHost GetHelloWorldBoundServer()
        {
            Action<IAppBuilder> config = (builder) =>
            {
                builder.Use(typeof(Fos.Tests.Middleware.HelloWorldApplication));
            };

            var server = new FosSelfHost(config);
            server.Bind(ListenOn, ListenPort);

            return server;
        }
예제 #4
0
파일: Startup.cs 프로젝트: knocte/Fos
        public void StartAndDispose()
        {
            int port = 9007; // Let's hope this is not being used..

            FosSelfHost server;
            using (server = new FosSelfHost(app => {}))
            {
                server.Bind(System.Net.IPAddress.Loopback, port);

                server.Start(true);
                Assert.AreEqual(true, server.IsRunning);
            }

            Assert.AreEqual(false, server.IsRunning);
        }
예제 #5
0
        public void StartAndDisposeUnixSocket()
        {
            FosSelfHost server;
            using (server = new FosSelfHost(app => {}))
            {
                server.Bind("./.FosTestSocket");

                server.Start(true);
                Assert.AreEqual(true, server.IsRunning);
            }

            using (server = new FosSelfHost(app => {}))
            {
                server.Bind("./.FosTestSocket");

                server.Start(true);
                Assert.AreEqual(true, server.IsRunning);
            }

            Assert.AreEqual(false, server.IsRunning);
        }
예제 #6
0
        public void ErrorPageTest()
        {
            Action<IAppBuilder> config = (builder) =>
            {
                builder.Use(typeof(ThrowsExceptionApplication));
            };

            using (var server = new FosSelfHost(config))
            {
                server.Bind(ListenOn, ListenPort);
                server.Start(true);

                //System.Threading.Thread.Sleep(1000000);
                // Make the request and expect the empty response page with 500 status code
                var browser = new Browser(ListenOn, ListenPort);
                var response = browser.ExecuteRequest("http://localhost/", "GET");

                //Assert.AreNotEqual(0, response.AppStatusCode);
                Assert.AreEqual(500, response.HttpStatusCode);
                Assert.That(ReadStream(response.ResponseBody).Contains("An error occured in the application. On purpose."));
            }
        }