Add tests for GetDynamicAsync method in RecActionApiTests
Added a `using` directive for `System.Text.Json` to support JSON operations. Introduced two new test methods: `GetDynamicAsync_without_filters_returns_dynamic_payload_or_throws_not_found` to validate the behavior of `GetDynamicAsync` without filters, and `GetDynamicAsync_with_unknown_profile_throws_not_found` to ensure proper handling of unknown profile IDs.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Text.Json;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using ReC.Application.Common.Dto;
|
using ReC.Application.Common.Dto;
|
||||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||||
@@ -41,6 +42,27 @@ public class RecActionApiTests : RecClientTestBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task GetDynamicAsync_without_filters_returns_dynamic_payload_or_throws_not_found()
|
||||||
|
{
|
||||||
|
var (client, scope) = CreateScopedClient();
|
||||||
|
using var _ = scope;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
dynamic? actions = await client.RecActions.GetDynamicAsync();
|
||||||
|
Assert.That(actions, Is.Not.Null);
|
||||||
|
Assert.That(actions, Is.TypeOf<JsonElement>());
|
||||||
|
Assert.That(((JsonElement)actions).ValueKind, Is.EqualTo(JsonValueKind.Array));
|
||||||
|
}
|
||||||
|
catch (ReCApiException ex)
|
||||||
|
{
|
||||||
|
Assert.That(ex.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
|
||||||
|
Assert.That(ex.Method, Is.EqualTo("GET"));
|
||||||
|
Assert.That(ex.RequestUri!.AbsolutePath, Does.EndWith("api/RecAction"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task GetAsync_with_profile_filter_returns_only_matching_actions()
|
public async Task GetAsync_with_profile_filter_returns_only_matching_actions()
|
||||||
{
|
{
|
||||||
@@ -81,6 +103,21 @@ public class RecActionApiTests : RecClientTestBase
|
|||||||
Assert.That(ex.RequestUri!.Query, Does.Contain("ProfileId="));
|
Assert.That(ex.RequestUri!.Query, Does.Contain("ProfileId="));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetDynamicAsync_with_unknown_profile_throws_not_found()
|
||||||
|
{
|
||||||
|
var (client, scope) = CreateScopedClient();
|
||||||
|
using var _ = scope;
|
||||||
|
|
||||||
|
var ex = Assert.ThrowsAsync<ReCApiException>(async () =>
|
||||||
|
await client.RecActions.GetDynamicAsync(profileId: long.MaxValue));
|
||||||
|
|
||||||
|
Assert.That(ex, Is.Not.Null);
|
||||||
|
Assert.That(ex!.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
|
||||||
|
Assert.That(ex.Method, Is.EqualTo("GET"));
|
||||||
|
Assert.That(ex.RequestUri!.Query, Does.Contain("ProfileId="));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void CreateAsync_with_invalid_foreign_key_throws_ReCApiException()
|
public void CreateAsync_with_invalid_foreign_key_throws_ReCApiException()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user