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.
62 lines
2.1 KiB
C#
62 lines
2.1 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.EndpointParams.Commands;
|
|
using ReC.Tests.Application;
|
|
|
|
namespace ReC.Tests.Application.EndpointParams;
|
|
|
|
[TestFixture]
|
|
public class EndpointParamsProcedureTests : RecApplicationTestBase
|
|
{
|
|
private (ISender Sender, IServiceScope Scope) CreateScopedSender()
|
|
{
|
|
var scope = ServiceProvider.CreateScope();
|
|
var sender = scope.ServiceProvider.GetRequiredService<ISender>();
|
|
return (sender, scope);
|
|
}
|
|
|
|
[Test]
|
|
public async Task InsertEndpointParamsProcedure_runs_via_mediator()
|
|
{
|
|
var procedure = new InsertEndpointParamsProcedure { Active = true, Description = "param", GroupId = 1, Sequence = 1, Key = "k", Value = "v" };
|
|
var objectProc = procedure.ToObjectProcedure("ReC.Tests");
|
|
|
|
var (sender, scope) = CreateScopedSender();
|
|
using var _ = scope;
|
|
var result = await sender.Send(objectProc);
|
|
|
|
Assert.That(result, Is.GreaterThan(0));
|
|
}
|
|
|
|
[Test]
|
|
public async Task UpdateEndpointParamsProcedure_runs_via_mediator()
|
|
{
|
|
var procedure = new UpdateEndpointParamsProcedure { Active = false, Description = "param-update", GroupId = 2, Sequence = 2, Key = "k2", Value = "v2" };
|
|
var objectProc = procedure.ToObjectProcedure(25, "ReC.Tests");
|
|
|
|
var (sender, scope) = CreateScopedSender();
|
|
using var _ = scope;
|
|
var result = await sender.Send(objectProc);
|
|
|
|
Assert.That(result, Is.EqualTo(0));
|
|
}
|
|
|
|
[Test]
|
|
public async Task DeleteEndpointParamsProcedure_runs_via_mediator()
|
|
{
|
|
var procedure = new DeleteEndpointParamsProcedure { Start = 5, End = 6, Force = true };
|
|
var objectProc = procedure.ToObjectProcedure();
|
|
|
|
var (sender, scope) = CreateScopedSender();
|
|
using var _ = scope;
|
|
var result = await sender.Send(objectProc);
|
|
|
|
Assert.That(result, Is.EqualTo(0));
|
|
}
|
|
}
|