Exemplo n.º 1
0
 static void Main(string[] args)
 {
     using (var app = new Conpanna()) {
         app.Get("/hello", (req, res) => res.Send("Hello World!"));
         app.Listen("localhost", 8080, () => Console.WriteLine("Listening on http://localhost:8080"));
         Console.ReadLine();
     }
 }
Exemplo n.º 2
0
        public void CheckThatStartsFineWithoutCallback()
        {
            var address = "localhost";
            var port    = 8080;

            // Pass our container with mock HTTP service
            var app = new Conpanna(_container);

            app.Listen(address, port);
            app.Close();
        }
Exemplo n.º 3
0
        public void IsListeningSetByStartAndClose()
        {
            var app = new Conpanna(_container);

            Assert.False(app.IsListening);

            app.Listen("localhost", 1000);
            Assert.True(app.IsListening);

            app.Close();
            Assert.False(app.IsListening);
        }
Exemplo n.º 4
0
        public void CheckThatCallbackFires()
        {
            var address = "localhost";
            var port    = 8080;

            // Pass our container with mock HTTP service
            var app = new Conpanna(_container);

            bool called = false;

            app.Listen(address, port, () =>
            {
                called = true;
                return;
            });

            // Check if callback was called
            Assert.True(called);

            app.Close();
        }