Refactored query handlers (`ReadProfileViewQueryHandler`, `ReadRecActionViewQueryHandler`, and `ReadResultViewQueryHandler`) to return empty results instead of throwing `NotFoundException` when no data is found. Simplified the logic by removing null or empty result checks and directly returning mapped results. Updated corresponding test cases to align with the new behavior: - Removed `try-catch` blocks for `NotFoundException`. - Adjusted assertions to handle empty results. - Removed the test case for `ReadRecActionViewQuery` that expected `NotFoundException`. This change reflects a design shift to let the calling code handle empty results instead of relying on exceptions.
39 lines
1004 B
C#
39 lines
1004 B
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.");
|
|
}
|
|
}
|
|
}
|