Added ReC.Tests project with integration tests for stored procedure commands and queries via MediatR, covering endpoints, actions, results, and profiles. Introduced a test base for DI/configuration, helper for private property access, and updated the solution to include the new test suite. Tests use NUnit and cover both positive and negative scenarios.
35 lines
958 B
C#
35 lines
958 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 void ReadResultViewQuery_with_unknown_action_throws_not_found()
|
|
{
|
|
var (sender, scope) = CreateScopedSender();
|
|
using var _ = scope;
|
|
|
|
var invalidActionId = long.MaxValue;
|
|
|
|
Assert.ThrowsAsync<NotFoundException>(async () =>
|
|
await sender.Send(new ReadResultViewQuery
|
|
{
|
|
ActionId = invalidActionId
|
|
}));
|
|
}
|
|
}
|