Refactor tests to send commands directly to mediator

Refactored test code to remove ToObjectProcedure usage and send command objects directly to the mediator. Updated update procedure tests to use Data and Id properties. Replaced custom Execute*Procedure methods with sender.Send. Cleaned up unused usings. These changes improve consistency and reflect updates to command structures.
This commit is contained in:
2026-03-24 11:29:15 +01:00
parent 3e10176d98
commit 302fee4908
7 changed files with 28 additions and 52 deletions

View File

@@ -1,12 +1,6 @@
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;
@@ -24,11 +18,10 @@ public class EndpointParamsProcedureTests : RecApplicationTestBase
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);
var result = await sender.Send(procedure);
Assert.That(result, Is.GreaterThan(0));
}
@@ -36,12 +29,11 @@ public class EndpointParamsProcedureTests : RecApplicationTestBase
[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 procedure = new UpdateEndpointParamsProcedure { 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(objectProc);
var result = await sender.Send(procedure);
Assert.That(result, Is.Not.EqualTo(default(int)));
}
@@ -50,11 +42,10 @@ public class EndpointParamsProcedureTests : RecApplicationTestBase
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);
var result = await sender.Send(procedure);
Assert.That(result, Is.Not.EqualTo(default(int)));
}