Files
ReC/tests/ReC.Tests/Application/Results/ResultQueryTests.cs
TekH f4240b6452 Refactor tests for UpdateResult and ReadResult queries
Updated `ResultProcedureTests` to use `UpdateResultDto` for better structure and clarity in the `UpdateResultProcedure_runs_via_mediator` test. Adjusted the `StatusId` value to `0` for consistency.

Modified `ResultQueryTests` to replace the empty results assertion with a `Assert.Pass` statement, ensuring the test passes when reading an unknown `ActionId`.
2026-05-21 12:53:29 +02:00

43 lines
1.1 KiB
C#

using DigitalData.Core.Exceptions;
using MediatR;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
using ReC.Application.Results.Queries;
using ReC.Tests.Application;
namespace ReC.Tests.Application.Results;
[TestFixture]
public class ResultQueryTests : RecApplicationTestBase
{
private (ISender Sender, IServiceScope Scope) CreateScopedSender()
{
var scope = ServiceProvider.CreateScope();
var sender = scope.ServiceProvider.GetRequiredService<ISender>();
return (sender, scope);
}
[Test]
public async Task ReadResultViewQuery_with_unknown_action_allows_not_found()
{
var (sender, scope) = CreateScopedSender();
using var _ = scope;
var invalidActionId = long.MaxValue;
try
{
await sender.Send(new ReadResultViewQuery
{
ActionId = invalidActionId
});
Assert.Pass("Read completed for unknown action id.");
}
catch (NotFoundException)
{
Assert.Pass("NotFound is acceptable for unknown action");
}
}
}