Renamed Insert/Update/DeleteEndpointParamsProcedure classes and handlers to use the "Command" suffix (e.g., InsertEndpointParamsCommand) for consistency with CQRS conventions. Updated all controller actions, handlers, and tests to use the new command names. This improves clarity and aligns naming with standard command patterns.
53 lines
1.7 KiB
C#
53 lines
1.7 KiB
C#
using MediatR;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using ReC.Application.EndpointParams.Commands;
|
|
|
|
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 InsertEndpointParamsCommand { Active = true, Description = "param", GroupId = 1, Sequence = 1, Key = "k", Value = "v" };
|
|
|
|
var (sender, scope) = CreateScopedSender();
|
|
using var _ = scope;
|
|
var result = await sender.Send(procedure);
|
|
|
|
Assert.That(result, Is.GreaterThan(0));
|
|
}
|
|
|
|
[Test]
|
|
public async Task UpdateEndpointParamsProcedure_runs_via_mediator()
|
|
{
|
|
var procedure = new UpdateEndpointParamsCommand { Data = { Active = false, Description = "param-update", GroupId = 2, Sequence = 2, Key = "k2", Value = "v2" }, Id = 25 };
|
|
|
|
var (sender, scope) = CreateScopedSender();
|
|
using var _ = scope;
|
|
var result = await sender.Send(procedure);
|
|
|
|
Assert.That(result, Is.Not.EqualTo(default(int)));
|
|
}
|
|
|
|
[Test]
|
|
public async Task DeleteEndpointParamsProcedure_runs_via_mediator()
|
|
{
|
|
var procedure = new DeleteEndpointParamsCommand { Start = 5, End = 6, Force = true };
|
|
|
|
var (sender, scope) = CreateScopedSender();
|
|
using var _ = scope;
|
|
var result = await sender.Send(procedure);
|
|
|
|
Assert.That(result, Is.Not.EqualTo(default(int)));
|
|
}
|
|
}
|