Files
ReC/tests/ReC.Tests/Application/Procedures/ProcedureExecutionTests.cs
TekH ce35ef588f Add integration test project with MediatR procedure tests
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.
2026-01-16 15:24:51 +01:00

59 lines
1.8 KiB
C#

using System.Threading.Tasks;
using MediatR;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
using ReC.Application.Common.Procedures.DeleteProcedure;
using ReC.Application.Common.Procedures.InsertProcedure;
using ReC.Application.Common.Procedures.UpdateProcedure;
using ReC.Application.Profile.Commands;
using ReC.Tests.Application;
namespace ReC.Tests.Application.Procedures;
[TestFixture]
public class ProcedureExecutionTests : RecApplicationTestBase
{
private (ISender Sender, IServiceScope Scope) CreateScopedSender()
{
var scope = ServiceProvider.CreateScope();
var sender = scope.ServiceProvider.GetRequiredService<ISender>();
return (sender, scope);
}
[Test]
public async Task ExecuteInsertProcedure_runs_with_addedWho()
{
var procedure = new InsertProfileProcedure { Name = "name" };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
var result = await sender.ExecuteInsertProcedure(procedure, "ReC.Tests");
Assert.That(result, Is.GreaterThan(0));
}
[Test]
public async Task ExecuteUpdateProcedure_runs_with_changedWho()
{
var procedure = new UpdateProfileProcedure { Name = "updated" };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
var result = await sender.ExecuteUpdateProcedure(procedure, 123, "ReC.Tests");
Assert.That(result, Is.EqualTo(0));
}
[Test]
public async Task ExecuteDeleteProcedure_runs()
{
var procedure = new DeleteProfileProcedure { Start = 1, End = 2, Force = true };
var (sender, scope) = CreateScopedSender();
using var _ = scope;
var result = await sender.ExecuteDeleteProcedure(procedure);
Assert.That(result, Is.EqualTo(0));
}
}