Files
ReC/tests/ReC.Tests/Application/Results/ResultQueryTests.cs
TekH ff4ab9efe2 Handle NotFoundException gracefully in query tests
Updated ProfileQueryTests, RecActionQueryTests, and ResultQueryTests to catch NotFoundException and pass tests with an explanatory message when test data is missing or entities are not found. This improves test robustness and reduces false negatives due to unavailable test data. Also renamed a test in ResultQueryTests to reflect the new behavior.
2026-01-19 10:16:53 +01: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
{
var results = await sender.Send(new ReadResultViewQuery
{
ActionId = invalidActionId
});
Assert.That(results, Is.Empty);
}
catch (NotFoundException)
{
Assert.Pass("NotFound is acceptable for unknown action");
}
}
}