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

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.

主站蜘蛛池模板: 吉隆县| 唐山市| 塔河县| 雷州市| 新平| 高雄市| 黄大仙区| 宝鸡市| 巍山| 荥经县| 卓资县| 封开县| 古丈县| 金平| 商河县| 将乐县| 宝坻区| 安西县| 开化县| 腾冲县| 灯塔市| 鲁山县| 西林县| 刚察县| 抚松县| 洪泽县| 黎川县| 乐山市| 葵青区| 鸡泽县| 桐庐县| 霍山县| 饶阳县| 马公市| 凤翔县| 海口市| 潼南县| 永福县| 台州市| 深泽县| 邓州市|