예제 #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);
        }
예제 #2
0
        public void Run()
        {
            // Arrange
            var server = new HttpServer();
            server.When(request => request.Uri.Is("/home/index"))
                  .Then(response => response.Text("foo"));

            var engine = new HttpServerEngine(server,9000).Start();

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

            // Assert
            Assert.That(result, Is.EqualTo("foo"));
        }
예제 #3
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");
        }
예제 #4
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);
        }
예제 #5
0
        public void Run()
        {
            // Arrange
            var server = new HttpServer();

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

            var engine = new HttpServerEngine(server, 9000).Start();

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

            engine.Stop();

            // Assert
            Assert.That(result, Is.EqualTo("foo"));
        }
예제 #6
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");
        }