diff --git a/tests/ReC.Tests/Client/RecActionApiTests.cs b/tests/ReC.Tests/Client/RecActionApiTests.cs index 868b417..8cdf1b2 100644 --- a/tests/ReC.Tests/Client/RecActionApiTests.cs +++ b/tests/ReC.Tests/Client/RecActionApiTests.cs @@ -201,4 +201,70 @@ public class RecActionApiTests : RecClientTestBase Assert.That(ex, Is.Not.Null); Assert.That(ex!.Method, Is.EqualTo("POST")); } + + [Test] + public async Task InvokeAsync_returns_BatchRecActionViewResponse_on_success() + { + var profileId = await TryResolveProfileIdAsync(); + if (profileId is null or <= 0) + Assert.Ignore("No profile available in the database for this test (set FakeProfileId or insert a profile)."); + + var (client, scope) = CreateScopedClient(); + using var _ = scope; + + BatchRecActionViewResponse? result; + try + { + result = await client.RecActions.InvokeAsync(profileId!.Value, new ClientInvokeReferences { BatchId = "test-batch" }); + } + catch (ReCApiException ex) + { + Assert.Pass($"API returned {ex.StatusCode} — acceptable when test data is unavailable."); + return; + } + + Assert.That(result, Is.Not.Null); + Assert.That(result!.TotalActionCount, Is.GreaterThanOrEqualTo(0)); + Assert.That(result.ActionExceptionCount, Is.GreaterThanOrEqualTo(0)); + Assert.That(result.ActionExceptionCount, Is.LessThanOrEqualTo(result.TotalActionCount)); + } + + [Test] + public async Task InvokeAsync_with_batchId_string_returns_BatchRecActionViewResponse() + { + var profileId = await TryResolveProfileIdAsync(); + if (profileId is null or <= 0) + Assert.Ignore("No profile available in the database for this test (set FakeProfileId or insert a profile)."); + + var (client, scope) = CreateScopedClient(); + using var _ = scope; + + BatchRecActionViewResponse? result; + try + { + result = await client.RecActions.InvokeAsync(profileId!.Value, "test-batch"); + } + catch (ReCApiException ex) + { + Assert.Pass($"API returned {ex.StatusCode} — acceptable when test data is unavailable."); + return; + } + + Assert.That(result, Is.Not.Null); + Assert.That(result!.TotalActionCount, Is.GreaterThanOrEqualTo(0)); + } + + [Test] + public void InvokeAsync_with_batchId_string_and_unknown_profile_throws_ReCApiException() + { + var (client, scope) = CreateScopedClient(); + using var _ = scope; + + var ex = Assert.ThrowsAsync(async () => + await client.RecActions.InvokeAsync(long.MaxValue, "test-batch")); + + Assert.That(ex, Is.Not.Null); + Assert.That(ex!.Method, Is.EqualTo("POST")); + Assert.That(ex.RequestUri!.AbsolutePath, Does.Contain("invoke")); + } }