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:
@@ -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)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user