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

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.

主站蜘蛛池模板: 霞浦县| 雷波县| 云霄县| 新乡市| 黄浦区| 临武县| 大埔区| 东乡族自治县| 瑞丽市| 黎川县| 义乌市| 林州市| 牡丹江市| 莲花县| 昌黎县| 平安县| 南丹县| 桦川县| 盈江县| 尉犁县| 芦溪县| 舟山市| 习水县| 洛浦县| 郓城县| 乌恰县| 张家界市| 易门县| 孟村| 甘南县| 十堰市| 乐清市| 扎兰屯市| 手机| 凌云县| 谢通门县| 通渭县| 沈丘县| 炎陵县| 邹平县| 炎陵县|