Exemplo n.º 1
0
        public void Handle_when_request_not_matched_should_return_404()
        {
            // Assert
            var httpServer = new HttpServer();

            var httpEngine = new HttpServerEngine(httpServer, 9000);
            httpEngine.Start();

            // Act
            var result = Http.Get("http://localhost:9000/home/index").GetContent();
            httpEngine.Stop();

            // Assert
            result.Should().Be(string.Empty);
        }
Exemplo n.º 2
0
        public void Handle_when_matched_request_should_reponse_setting_content()
        {
            // Assert
            var httpServer = new HttpServer();
            httpServer.When(request => request.Uri.Is("/home/index"))
                      .Then(response => response.Text("hello"));

            var httpEngine = new HttpServerEngine(httpServer, 9000);
            httpEngine.Start();

            // Act
            var result = Http.Get("http://localhost:9000/home/index").GetContent();
            httpEngine.Stop();

            // Assert
            result.Should().Be("hello");
        }
Exemplo n.º 3
0
        public void Handle_when_request_not_matched_should_return_404()
        {
            // Assert
            var httpServer = new HttpServer();

            var httpEngine = new HttpServerEngine(httpServer, 9000);

            httpEngine.Start();

            // Act
            var result = Http.Get("http://localhost:9000/home/index").GetContent();

            httpEngine.Stop();

            // Assert
            result.Should().Be(string.Empty);
        }
Exemplo n.º 4
0
        public void Handle_when_matched_request_should_reponse_setting_content()
        {
            // Assert
            var httpServer = new HttpServer();

            httpServer.When(request => request.Uri.Is("/home/index"))
            .Then(response => response.Text("hello"));

            var httpEngine = new HttpServerEngine(httpServer, 9000);

            httpEngine.Start();

            // Act
            var result = Http.Get("http://localhost:9000/home/index").GetContent();

            httpEngine.Stop();

            // Assert
            result.Should().Be("hello");
        }