@@ -12,29 +12,20 @@ namespace netmockery
1212 public class TestCaseHttpRequest : IHttpRequestWrapper
1313 {
1414 private string path ;
15+ private string querystring ;
1516 private HeaderDictionary headerDictionary = new HeaderDictionary ( ) ;
1617
17- public TestCaseHttpRequest ( string path )
18+ public TestCaseHttpRequest ( string path , string querystring )
1819 {
1920 this . path = path ;
20- }
21-
22- public IHeaderDictionary Headers
23- {
24- get
25- {
26- return headerDictionary ;
27- }
21+ this . querystring = querystring ;
2822 }
2923
30- public PathString Path
31- {
32- get
33- {
24+ public IHeaderDictionary Headers => headerDictionary ;
3425
35- return new PathString ( path ) ;
36- }
37- }
26+ public PathString Path => new PathString ( path ) ;
27+
28+ public QueryString QueryString => new QueryString ( querystring ) ;
3829 }
3930
4031 public class TestCaseHttpResponse : IHttpResponseWrapper
@@ -44,13 +35,7 @@ public class TestCaseHttpResponse : IHttpResponseWrapper
4435 Encoding writtenEncoding ;
4536 string contentType ;
4637
47- public Stream Body
48- {
49- get
50- {
51- return memoryStream ;
52- }
53- }
38+ public Stream Body => memoryStream ;
5439
5540 public string ContentType
5641 {
@@ -62,12 +47,12 @@ public string ContentType
6247
6348 async public Task WriteAsync ( string content , Encoding encoding )
6449 {
65-
6650 writtenContent = content ;
6751 writtenEncoding = encoding ;
6852 await Task . Yield ( ) ;
6953 }
7054 }
55+
7156 public class NetmockeryTestCase
7257 {
7358 public string Name ;
@@ -145,7 +130,7 @@ async public Task<NetmockeryTestCaseResult> ExecuteAsync(EndpointCollection endp
145130 else
146131 {
147132 bool singleMatch ;
148- var matcher_and_creator = endpoint . Resolve ( new PathString ( RequestPath ) , new QueryString ( QueryString ) , RequestBody , null , out singleMatch ) ;
133+ var matcher_and_creator = endpoint . Resolve ( new PathString ( RequestPath ) , new QueryString ( QueryString ) , RequestBody ?? "" , null , out singleMatch ) ;
149134 if ( matcher_and_creator != null )
150135 {
151136 var responseCreator = matcher_and_creator . Item2 ;
@@ -158,7 +143,7 @@ async public Task<NetmockeryTestCaseResult> ExecuteAsync(EndpointCollection endp
158143 {
159144 if ( NeedsResponseBody )
160145 {
161- var responseBodyBytes = await responseCreator . CreateResponseAsync ( new TestCaseHttpRequest ( RequestPath ) , Encoding . UTF8 . GetBytes ( RequestBody ) , new TestCaseHttpResponse ( ) , endpoint . Directory ) ;
146+ var responseBodyBytes = await responseCreator . CreateResponseAsync ( new TestCaseHttpRequest ( RequestPath , QueryString ) , Encoding . UTF8 . GetBytes ( RequestBody ?? "" ) , new TestCaseHttpResponse ( ) , endpoint . Directory ) ;
162147 responseBody = Encoding . UTF8 . GetString ( responseBodyBytes ) ;
163148 }
164149 string message ;
@@ -197,7 +182,7 @@ async public Task<Tuple<string, string>> GetResponseAsync(EndpointCollection end
197182 if ( matcher_and_creator != null )
198183 {
199184 var responseCreator = matcher_and_creator . Item2 ;
200- var responseBodyBytes = await responseCreator . CreateResponseAsync ( new TestCaseHttpRequest ( RequestPath ) , Encoding . UTF8 . GetBytes ( RequestBody ) , new TestCaseHttpResponse ( ) , endpoint . Directory ) ;
185+ var responseBodyBytes = await responseCreator . CreateResponseAsync ( new TestCaseHttpRequest ( RequestPath , QueryString ) , Encoding . UTF8 . GetBytes ( RequestBody ) , new TestCaseHttpResponse ( ) , endpoint . Directory ) ;
201186 return Tuple . Create ( Encoding . UTF8 . GetString ( responseBodyBytes ) , ( string ) null ) ;
202187 }
203188 else
0 commit comments