@@ -4224,6 +4224,47 @@ public async Task OpenApi_InteractiveSwaggerUI(
42244224 }
42254225 }
42264226
4227+ /// <summary>
4228+ /// End to end test that validates that REST requests with OData query
4229+ /// options $filter and $orderby succeed to ensure no regression can occur.
4230+ /// </summary>
4231+ [ DataTestMethod ]
4232+ [ DataRow ( "/api/Book?$orderby=id desc&$filter=publisher_id eq 1234" , DisplayName = "REST URL without encoded characters" ) ]
4233+ [ DataRow ( "/api/Book?%24orderby=id%20desc&%24filter=publisher_id%20eq%201234" , DisplayName = "REST URL with encoded characters" ) ]
4234+ [ TestCategory ( TestCategory . MSSQL ) ]
4235+ public async Task TestForRestRequestsWithFilterAndOrderbyParameters ( string restUri )
4236+ {
4237+ // The configuration file is constructed by merging hard-coded JSON strings to simulate the scenario where users manually edit the
4238+ // configuration file (instead of using CLI).
4239+ string configJson = TestHelper . AddPropertiesToJson ( TestHelper . BASE_CONFIG , BOOK_ENTITY_JSON ) ;
4240+ Assert . IsTrue ( RuntimeConfigLoader . TryParseConfig (
4241+ configJson ,
4242+ out RuntimeConfig deserializedConfig ,
4243+ replacementSettings : new ( ) ,
4244+ connectionString : GetConnectionStringFromEnvironmentConfig ( environment : TestCategory . MSSQL ) ) ) ;
4245+ string configFileName = "custom-config.json" ;
4246+ File . WriteAllText ( configFileName , deserializedConfig . ToJson ( ) ) ;
4247+ string [ ] args = new [ ]
4248+ {
4249+ $ "--ConfigFileName={ configFileName } "
4250+ } ;
4251+
4252+ using ( TestServer server = new ( Program . CreateWebHostBuilder ( args ) ) )
4253+ using ( HttpClient client = server . CreateClient ( ) )
4254+ {
4255+ // Act
4256+ using HttpRequestMessage restRequest = new ( HttpMethod . Get , restUri ) ;
4257+ using HttpResponseMessage restResponse = await client . SendAsync ( restRequest ) ;
4258+
4259+ // Assert - Verify REST response
4260+ Assert . AreEqual ( HttpStatusCode . OK , restResponse . StatusCode , "REST request to auto-generated entity should succeed" ) ;
4261+
4262+ string restResponseBody = await restResponse . Content . ReadAsStringAsync ( ) ;
4263+ Assert . IsTrue ( ! string . IsNullOrEmpty ( restResponseBody ) , "REST response should contain data" ) ;
4264+ Assert . IsTrue ( restResponseBody . Contains ( "\" publisher_id\" :1234" ) ) ;
4265+ }
4266+ }
4267+
42274268 /// <summary>
42284269 /// Test different loglevel values that are avaliable by deserializing RuntimeConfig with specified LogLevel
42294270 /// and checks if value exists properly inside the deserialized RuntimeConfig.
0 commit comments