diff --git a/tests/ReC.Tests/Client/RecActionApiTests.cs b/tests/ReC.Tests/Client/RecActionApiTests.cs index 0c56fae..4ab41e2 100644 --- a/tests/ReC.Tests/Client/RecActionApiTests.cs +++ b/tests/ReC.Tests/Client/RecActionApiTests.cs @@ -1,4 +1,5 @@ using System.Net; +using System.Text.Json; using Microsoft.Extensions.Configuration; using ReC.Application.Common.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()); + 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] 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=")); } + [Test] + public void GetDynamicAsync_with_unknown_profile_throws_not_found() + { + var (client, scope) = CreateScopedClient(); + using var _ = scope; + + var ex = Assert.ThrowsAsync(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] public void CreateAsync_with_invalid_foreign_key_throws_ReCApiException() {