Skip to content

Commit a5e72f4

Browse files
Add testing
1 parent 024e0b0 commit a5e72f4

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

src/Service.Tests/Configuration/ConfigurationTests.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4224,6 +4224,42 @@ 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+
[TestMethod]
4232+
[TestCategory(TestCategory.MSSQL)]
4233+
public async Task TestForRestRequestsWithFilterAndOrderbyParameters()
4234+
{
4235+
// The configuration file is constructed by merging hard-coded JSON strings to simulate the scenario where users manually edit the
4236+
// configuration file (instead of using CLI).
4237+
string configJson = TestHelper.AddPropertiesToJson(TestHelper.BASE_CONFIG, BOOK_ENTITY_JSON);
4238+
Assert.IsTrue(RuntimeConfigLoader.TryParseConfig(
4239+
configJson,
4240+
out RuntimeConfig deserializedConfig,
4241+
replacementSettings: new(),
4242+
connectionString: GetConnectionStringFromEnvironmentConfig(environment: TestCategory.MSSQL)));
4243+
string configFileName = "custom-config.json";
4244+
File.WriteAllText(configFileName, deserializedConfig.ToJson());
4245+
string[] args = new[]
4246+
{
4247+
$"--ConfigFileName={configFileName}"
4248+
};
4249+
4250+
using (TestServer server = new(Program.CreateWebHostBuilder(args)))
4251+
using (HttpClient client = server.CreateClient())
4252+
{
4253+
// Act
4254+
RuntimeConfigProvider configProvider = server.Services.GetService<RuntimeConfigProvider>();
4255+
using HttpRequestMessage restRequest = new(HttpMethod.Get, "/api/Book?$orderby=id desc&$filter=publisher_id eq 1234");
4256+
using HttpResponseMessage restResponse = await client.SendAsync(restRequest);
4257+
4258+
// Assert - Verify REST response
4259+
Assert.AreEqual(HttpStatusCode.OK, restResponse.StatusCode, "REST request to auto-generated entity should succeed");
4260+
}
4261+
}
4262+
42274263
/// <summary>
42284264
/// Test different loglevel values that are avaliable by deserializing RuntimeConfig with specified LogLevel
42294265
/// and checks if value exists properly inside the deserialized RuntimeConfig.

0 commit comments

Comments
 (0)