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

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.

主站蜘蛛池模板: 武乡县| 同仁县| 旅游| 邵武市| 巴彦淖尔市| 隆尧县| 宜阳县| 南昌市| 开阳县| 陆丰市| 南昌县| 衡山县| 黄山市| 平阴县| 正镶白旗| 罗定市| 景洪市| 凤山市| 樟树市| 黄骅市| 辽中县| 平乡县| 叶城县| 丰都县| 六枝特区| 来安县| 鹰潭市| 邓州市| 马鞍山市| 锡林浩特市| 杭锦旗| 宽城| 会同县| 甘南县| 乐平市| 岚皋县| 平邑县| 洮南市| 汽车| 高州市| 二连浩特市|