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:
61
tests/ReC.Tests/Application/Profile/ProfileProcedureTests.cs
Normal file
61
tests/ReC.Tests/Application/Profile/ProfileProcedureTests.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
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.Profile;
|
||||
|
||||
[TestFixture]
|
||||
public class ProfileProcedureTests : RecApplicationTestBase
|
||||
{
|
||||
private (ISender Sender, IServiceScope Scope) CreateScopedSender()
|
||||
{
|
||||
var scope = ServiceProvider.CreateScope();
|
||||
var sender = scope.ServiceProvider.GetRequiredService<ISender>();
|
||||
return (sender, scope);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task InsertProfileProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new InsertProfileProcedure { Active = true, TypeId = 1, Name = "name", Mandantor = "man" };
|
||||
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 UpdateProfileProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new UpdateProfileProcedure { Active = false, TypeId = 2, Name = "updated", Mandantor = "man2" };
|
||||
var objectProc = procedure.ToObjectProcedure(45, "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 DeleteProfileProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new DeleteProfileProcedure { Start = 9, End = 10, Force = false };
|
||||
var objectProc = procedure.ToObjectProcedure();
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
|
||||
Assert.That(result, Is.EqualTo(0));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user