官术网_书友最值得收藏!

There's more...

The Browser type not only supports in making simulated HTTP GET requests but also supports the other HTTP verbs through the methods Post, Delete, Put, Patch, Options, and Head, it. Each of these methods is used in a similar fashion to Get. In later recipes, we will see how to specify the body of the simulated HTTP request; for example, a call to Post. We will also see how to set HTTP headers for calls made through the Browser objects.

Furthermore, if you want a test to make a sequence of calls to your API, you can do this by using the Then method on the BrowserResponse class. The Then method allows you to chain simulated HTTP requests one after the other in the following manner:

      var actual = sut.Get("/").Then.Get("/foo");

Lastly, Nancy.Testing includes some convenient methods for asserting against the contents of the body of responses when the body is either JSON, XML, or HTML. We will see these features in the upcoming recipes as we will actually start returning something from our route handlers.

主站蜘蛛池模板: 瓮安县| 郧西县| 景德镇市| 扶绥县| 舟曲县| 务川| 合江县| 诸暨市| 景德镇市| 盖州市| 成安县| 离岛区| 资溪县| 衡阳市| 民权县| 尤溪县| 黄山市| 涿鹿县| 汶川县| 石狮市| 定襄县| 宝兴县| 大关县| 大关县| 绥滨县| 黄冈市| 台南县| 烟台市| 丰县| 金沙县| 宜州市| 长治市| 隆回县| 峨眉山市| 大关县| 镇康县| 札达县| 渝中区| 林甸县| 五河县| 宜春市|