本文整理汇总了C#中HttpServer.When方法的典型用法代码示例。如果您正苦于以下问题:C# HttpServer.When方法的具体用法?C# HttpServer.When怎么用?C# HttpServer.When使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpServer
的用法示例。
在下文中一共展示了HttpServer.When方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
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"));
}
示例2: Handle_when_matched_request_should_reponse_setting_content
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");
}
示例3: MappingTest
public void MappingTest()
{
var server = new HttpServer();
server.When(request => request.Uri.Is("home/index"));
// .Then(response => response.File("c:\\test.html").Header("Accept", "text/html"));
}