Refactor tests and introduce UpdateProfileDto
Refactored `ProfileProcedureTests` to use `UpdateProfileDto` for the `Data` property in `UpdateProfileCommand`, improving code clarity. Updated `ProfileQueryTests` to replace `FakeProfileId` retrieval with `TryResolveProfileIdAsync` and added a conditional check to ignore the test if no valid profile ID is available, enhancing test robustness and flexibility.
This commit is contained in:
@@ -5,6 +5,7 @@ using NUnit.Framework;
|
|||||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||||
|
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||||
using ReC.Application.Profile.Commands;
|
using ReC.Application.Profile.Commands;
|
||||||
using ReC.Tests.Application;
|
using ReC.Tests.Application;
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ public class ProfileProcedureTests : RecApplicationTestBase
|
|||||||
[Test]
|
[Test]
|
||||||
public async Task UpdateProfileProcedure_runs_via_mediator()
|
public async Task UpdateProfileProcedure_runs_via_mediator()
|
||||||
{
|
{
|
||||||
var procedure = new UpdateProfileCommand { Data = { Active = false, TypeId = 2, Name = "updated", Mandantor = "man2" }, Id = 45 };
|
var procedure = new UpdateProfileCommand { Data = new UpdateProfileDto { Active = false, TypeId = 2, Name = "updated", Mandantor = "man2" }, Id = 45 };
|
||||||
|
|
||||||
var (sender, scope) = CreateScopedSender();
|
var (sender, scope) = CreateScopedSender();
|
||||||
using var _ = scope;
|
using var _ = scope;
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ public class ProfileQueryTests : RecApplicationTestBase
|
|||||||
[Test]
|
[Test]
|
||||||
public async Task ReadProfileViewQuery_returns_profile_from_database()
|
public async Task ReadProfileViewQuery_returns_profile_from_database()
|
||||||
{
|
{
|
||||||
var profileId = Configuration.GetValue<long?>("FakeProfileId");
|
var profileId = await TryResolveProfileIdAsync();
|
||||||
Assert.That(profileId, Is.Not.Null.And.GreaterThan(0), "FakeProfileId must be configured in appsettings.json");
|
if (profileId is null or <= 0)
|
||||||
|
Assert.Ignore("No profile available in the database for this test (set FakeProfileId or insert a profile).");
|
||||||
|
|
||||||
var (sender, scope) = CreateScopedSender();
|
var (sender, scope) = CreateScopedSender();
|
||||||
using var _ = scope;
|
using var _ = scope;
|
||||||
|
|||||||
Reference in New Issue
Block a user