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.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user