c# - Not Awaitable Type error in my async MSTest Test -
this first time using async in .net i'm totally lost here.
also i'm trying use httpclient in unit test make calls wcf web service. i'm not doing right because "httpresponsemessage" not awaitable below. it's not recognizing "readasasync".
i'm not sure doing right yet
[testmethod] public async task gettest_restendpoint_listofinventoryreturnedisnotnull() { // arrange using (var client = new httpclient()) { client.baseaddress = new uri("http://localhost/inventory/"); client.defaultrequestheaders.accept.clear(); client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/json")); // http httpresponsemessage response = await client.getasync("?memberid=323&count=12&pagenumber=1&sortorder=2&eventid=1211"); if (response.issuccessstatuscode) { inventoryresponse inventoryresponse = await response.content.readasasync<inventoryresponse>(); console.writeline("{0}\t${1}\t{2}", inventorypostresponse.eventid); } ... }
also it's not recognizing "readasasync".
here's primary problem. readasasync<t>() extension method part of httpcontentextensions class, located in system.net.http.formatting.dll assembly. make sure you've added reference system.net.http.formatting project.
Comments
Post a Comment