Exemplo n.º 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));
                }
            }
        }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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."));
            }
        }