@@ -62,6 +62,14 @@ TWebMockMatchingTests = class(TObject)
6262 [TestCase(' No Resource by ID' , ' GET,^/resource/\d+$,resource/abc' )]
6363 procedure RequestWithMethodAndRegExPath_NotMatching_RespondsNotImplemented (const AMatcherMethod, AMatcherURIPattern, ARequestURI: string);
6464 [Test]
65+ procedure Request_MatchingQueryParam_RespondsOK ;
66+ [Test]
67+ procedure Request_NotMatchingQueryParam_RespondsNotImplemented ;
68+ [Test]
69+ procedure Request_MatchingQueryParamByRegEx_RespondsOK ;
70+ [Test]
71+ procedure Request_NotMatchingQueryParamByRegEx_RespondsNotImplemented ;
72+ [Test]
6573 procedure Request_MatchingSingleHeader_RespondsOK ;
6674 [Test]
6775 procedure Request_NotMatchingSingleHeader_RespondsNotImplemented ;
@@ -133,6 +141,26 @@ procedure TWebMockMatchingTests.Request_MatchingMultipleHeaders_RespondsOK;
133141 Assert.AreEqual(200 , LResponse.StatusCode);
134142end ;
135143
144+ procedure TWebMockMatchingTests.Request_MatchingQueryParamByRegEx_RespondsOK ;
145+ var
146+ LResponse: IHTTPResponse;
147+ begin
148+ WebMock.StubRequest(' *' , ' *' ).WithQueryParam(' Param1' , TRegEx.Create(' Value\d' ));
149+ LResponse := WebClient.Get(WebMock.URLFor(' /endpoint?Param1=Value1' ));
150+
151+ Assert.AreEqual(200 , LResponse.StatusCode);
152+ end ;
153+
154+ procedure TWebMockMatchingTests.Request_MatchingQueryParam_RespondsOK ;
155+ var
156+ LResponse: IHTTPResponse;
157+ begin
158+ WebMock.StubRequest(' *' , ' *' ).WithQueryParam(' Param1' , ' Value1' );
159+ LResponse := WebClient.Get(WebMock.URLFor(' /endpoint?Param1=Value1' ));
160+
161+ Assert.AreEqual(200 , LResponse.StatusCode);
162+ end ;
163+
136164procedure TWebMockMatchingTests.Request_MatchingSingleHeaderByRegEx_RespondsOK ;
137165var
138166 LHeaderName: string;
@@ -179,6 +207,26 @@ procedure TWebMockMatchingTests.StubWithMethodAndStringURI_NotMatching_RespondsN
179207 Assert.AreEqual(501 , LResponse.StatusCode);
180208end ;
181209
210+ procedure TWebMockMatchingTests.Request_NotMatchingQueryParamByRegEx_RespondsNotImplemented ;
211+ var
212+ LResponse: IHTTPResponse;
213+ begin
214+ WebMock.StubRequest(' *' , ' *' ).WithQueryParam(' Param1' , TRegEx.Create(' Value\d' ));
215+ LResponse := WebClient.Get(WebMock.URLFor(' /endpoint?Param1=ValueA' ));
216+
217+ Assert.AreEqual(501 , LResponse.StatusCode);
218+ end ;
219+
220+ procedure TWebMockMatchingTests.Request_NotMatchingQueryParam_RespondsNotImplemented ;
221+ var
222+ LResponse: IHTTPResponse;
223+ begin
224+ WebMock.StubRequest(' *' , ' *' ).WithQueryParam(' Param1' , ' Value1' );
225+ LResponse := WebClient.Get(WebMock.URLFor(' /endpoint?Param1=Value2' ));
226+
227+ Assert.AreEqual(501 , LResponse.StatusCode);
228+ end ;
229+
182230procedure TWebMockMatchingTests.Request_NotMatchingSingleHeaderByRegEx_RespondsNotImplemented ;
183231var
184232 LHeaderName: string;
0 commit comments