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.
44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using MediatR;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using NUnit.Framework;
|
|
using ReC.Application.Profile.Queries;
|
|
using ReC.Tests.Application;
|
|
|
|
namespace ReC.Tests.Application.Profile;
|
|
|
|
[TestFixture]
|
|
public class ProfileQueryTests : RecApplicationTestBase
|
|
{
|
|
private (ISender Sender, IServiceScope Scope) CreateScopedSender()
|
|
{
|
|
var scope = ServiceProvider.CreateScope();
|
|
var sender = scope.ServiceProvider.GetRequiredService<ISender>();
|
|
return (sender, scope);
|
|
}
|
|
|
|
[Test]
|
|
public async Task ReadProfileViewQuery_returns_profile_from_database()
|
|
{
|
|
var profileId = Configuration.GetValue<long?>("FakeProfileId");
|
|
Assert.That(profileId, Is.Not.Null.And.GreaterThan(0), "FakeProfileId must be configured in appsettings.json");
|
|
|
|
var (sender, scope) = CreateScopedSender();
|
|
using var _ = scope;
|
|
|
|
var profiles = await sender.Send(new ReadProfileViewQuery
|
|
{
|
|
Id = profileId,
|
|
IncludeActions = false
|
|
});
|
|
|
|
var profile = profiles.Single();
|
|
|
|
Assert.That(profile.Id, Is.EqualTo(profileId));
|
|
Assert.That(profile.ProfileName, Is.Not.Null.And.Not.Empty);
|
|
Assert.That(profile.Active, Is.True);
|
|
}
|
|
}
|