diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Scheduling/ScheduledJobEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Scheduling/ScheduledJobEntityFixture.cs
new file mode 100644
index 00000000..59c82fc0
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Scheduling/ScheduledJobEntityFixture.cs
@@ -0,0 +1,103 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Common.DataAccess.Entities.Scheduling;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobEntityFixture
+{
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the scheduled job.
+ /// Optional. The name of the scheduled job.
+ /// Optional. The type of the task executed by the scheduled job.
+ /// Optional. The type of the schedule of the scheduled job.
+ /// Optional. The interval in minutes of the schedule.
+ /// Optional. The hour of the schedule.
+ /// Optional. The minute of the schedule.
+ /// Optional. The status of the scheduled job.
+ /// Optional. The Id of the user that owns the scheduled job.
+ /// Optional. The last start time of the scheduled job.
+ /// Optional. The last completion time of the scheduled job.
+ /// The created .
+ public ScheduledJobEntity Create(
+ Guid? id = null,
+ string? name = null,
+ ScheduledTaskType? taskType = null,
+ ScheduleType? scheduleType = null,
+ int? intervalMinutes = null,
+ int? hour = null,
+ int? minute = null,
+ ScheduledJobStatus? status = null,
+ Guid? ownerUserId = null,
+ DateTime? lastStartedOnUtc = null,
+ DateTime? lastCompletedOnUtc = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f =>
+ {
+ ScheduleType resolvedScheduleType = scheduleType ?? f.PickRandom();
+ if (resolvedScheduleType == ScheduleType.WithIntervalInMinutes)
+ {
+ return new ScheduledJobEntity
+ {
+ Id = id ?? Guid.NewGuid(),
+ Name = name ?? f.Commerce.ProductName(),
+ TaskType = taskType ?? f.PickRandom(),
+ ScheduleType = resolvedScheduleType,
+ IntervalMinutes = intervalMinutes ?? f.Random.Int(1, 1440),
+ Hour = null,
+ Minute = null,
+ Status = status ?? f.PickRandom(),
+ OwnerUserId = ownerUserId ?? Guid.NewGuid(),
+ LastStartedOnUtc = lastStartedOnUtc,
+ LastCompletedOnUtc = lastCompletedOnUtc,
+ CreatedOnUtc = DateTime.UtcNow,
+ CreatedBy = Guid.NewGuid(),
+ UpdatedOnUtc = null,
+ UpdatedBy = null
+ };
+ }
+ return new ScheduledJobEntity
+ {
+ Id = id ?? Guid.NewGuid(),
+ Name = name ?? f.Commerce.ProductName(),
+ TaskType = taskType ?? f.PickRandom(),
+ ScheduleType = resolvedScheduleType,
+ IntervalMinutes = null,
+ Hour = hour ?? f.Random.Int(0, 23),
+ Minute = minute ?? f.Random.Int(0, 59),
+ Status = status ?? f.PickRandom(),
+ OwnerUserId = ownerUserId ?? Guid.NewGuid(),
+ LastStartedOnUtc = lastStartedOnUtc,
+ LastCompletedOnUtc = lastCompletedOnUtc,
+ CreatedOnUtc = DateTime.UtcNow,
+ CreatedBy = Guid.NewGuid(),
+ UpdatedOnUtc = null,
+ UpdatedBy = null
+ };
+ })
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Scheduling/ScheduledJobExecutionEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Scheduling/ScheduledJobExecutionEntityFixture.cs
new file mode 100644
index 00000000..ed2b07b2
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Scheduling/ScheduledJobExecutionEntityFixture.cs
@@ -0,0 +1,63 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Common.DataAccess.Entities.Scheduling;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobExecutionEntityFixture
+{
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the execution.
+ /// Optional. The Id of the scheduled job whose task was executed.
+ /// Optional. The type of the task that was executed.
+ /// Optional. Whether the execution was a cycle run.
+ /// Optional. The start time of the execution.
+ /// Optional. The completion time of the execution.
+ /// The created .
+ public ScheduledJobExecutionEntity Create(
+ Guid? id = null,
+ Guid? scheduledJobId = null,
+ ScheduledTaskType? taskType = null,
+ bool? isCycleRun = null,
+ DateTime? startedOnUtc = null,
+ DateTime? completedOnUtc = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f => new ScheduledJobExecutionEntity
+ {
+ Id = id ?? Guid.NewGuid(),
+ ScheduledJobId = scheduledJobId ?? Guid.NewGuid(),
+ TaskType = taskType ?? f.PickRandom(),
+ IsCycleRun = isCycleRun ?? f.Random.Bool(),
+ StartedOnUtc = startedOnUtc ?? DateTime.UtcNow,
+ CompletedOnUtc = completedOnUtc,
+ CreatedOnUtc = DateTime.UtcNow,
+ CreatedBy = Guid.NewGuid(),
+ UpdatedOnUtc = null,
+ UpdatedBy = null
+ })
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Scheduling/SchedulerDisplayPreferencesEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Scheduling/SchedulerDisplayPreferencesEntityFixture.cs
new file mode 100644
index 00000000..42ef10fc
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Scheduling/SchedulerDisplayPreferencesEntityFixture.cs
@@ -0,0 +1,60 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Common.DataAccess.Entities.Scheduling;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class SchedulerDisplayPreferencesEntityFixture
+{
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the display preferences.
+ /// Optional. The Id of the user that owns the display preferences.
+ /// Optional. The type of the scheduled job tasks whose executions are shown.
+ /// Optional. The displayed time span.
+ /// Optional. The unit of the displayed time span.
+ /// The created .
+ public SchedulerDisplayPreferencesEntity Create(
+ Guid? id = null,
+ Guid? userId = null,
+ ScheduledTaskType? jobTypeFilter = null,
+ int? displayTimeSpan = null,
+ SchedulerDisplayTimeUnit? displayTimeUnit = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f => new SchedulerDisplayPreferencesEntity
+ {
+ Id = id ?? Guid.NewGuid(),
+ UserId = userId ?? Guid.NewGuid(),
+ JobTypeFilter = jobTypeFilter ?? (f.Random.Bool() ? f.PickRandom() : null),
+ DisplayTimeSpan = displayTimeSpan ?? f.Random.Int(1, 24 * 60),
+ DisplayTimeUnit = displayTimeUnit ?? f.PickRandom(),
+ CreatedOnUtc = DateTime.UtcNow,
+ CreatedBy = Guid.NewGuid(),
+ UpdatedOnUtc = null,
+ UpdatedBy = null
+ })
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/AddScheduledJob/AddScheduledJobCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/AddScheduledJob/AddScheduledJobCommandFixture.cs
new file mode 100644
index 00000000..abb2d480
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/AddScheduledJob/AddScheduledJobCommandFixture.cs
@@ -0,0 +1,70 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Core.Scheduling.Commands.AddScheduledJob;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Core.Scheduling.Commands.AddScheduledJob;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class AddScheduledJobCommandFixture
+{
+ ///
+ /// Creates a random valid command to add a scheduled job.
+ ///
+ /// Optional. The name of the scheduled job.
+ /// Optional. The type of the task executed by the scheduled job.
+ /// Optional. The type of the schedule of the scheduled job.
+ /// Optional. The interval in minutes of the schedule.
+ /// Optional. The hour of the schedule.
+ /// Optional. The minute of the schedule.
+ /// The created command.
+ public AddScheduledJobCommand Create(
+ string? name = null,
+ ScheduledTaskType? taskType = null,
+ ScheduleType? scheduleType = null,
+ int? intervalMinutes = null,
+ int? hour = null,
+ int? minute = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f =>
+ {
+ ScheduleType resolvedScheduleType = scheduleType ?? f.PickRandom();
+ if (resolvedScheduleType == ScheduleType.WithIntervalInMinutes)
+ {
+ return new AddScheduledJobCommand(
+ name ?? f.Commerce.ProductName(),
+ taskType ?? f.PickRandom(),
+ resolvedScheduleType,
+ intervalMinutes ?? f.Random.Int(1, 1440),
+ null,
+ null);
+ }
+ return new AddScheduledJobCommand(
+ name ?? f.Commerce.ProductName(),
+ taskType ?? f.PickRandom(),
+ resolvedScheduleType,
+ null,
+ hour ?? f.Random.Int(0, 23),
+ minute ?? f.Random.Int(0, 59));
+ })
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/FireScheduledJob/FireScheduledJobCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/FireScheduledJob/FireScheduledJobCommandFixture.cs
new file mode 100644
index 00000000..22255c4b
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/FireScheduledJob/FireScheduledJobCommandFixture.cs
@@ -0,0 +1,40 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Core.Scheduling.Commands.FireScheduledJob;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Core.Scheduling.Commands.FireScheduledJob;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class FireScheduledJobCommandFixture
+{
+ ///
+ /// Creates a random valid command to fire the task of a scheduled job once.
+ ///
+ /// Optional. The Id of the scheduled job whose task is fired.
+ /// The created command.
+ public FireScheduledJobCommand Create(
+ Guid? scheduledJobId = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f => new FireScheduledJobCommand(scheduledJobId ?? Guid.NewGuid()))
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/RemoveScheduledJob/RemoveScheduledJobCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/RemoveScheduledJob/RemoveScheduledJobCommandFixture.cs
new file mode 100644
index 00000000..86b5c638
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/RemoveScheduledJob/RemoveScheduledJobCommandFixture.cs
@@ -0,0 +1,40 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Core.Scheduling.Commands.RemoveScheduledJob;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Core.Scheduling.Commands.RemoveScheduledJob;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class RemoveScheduledJobCommandFixture
+{
+ ///
+ /// Creates a random valid command to remove a scheduled job.
+ ///
+ /// Optional. The Id of the scheduled job to remove.
+ /// The created command.
+ public RemoveScheduledJobCommand Create(
+ Guid? scheduledJobId = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f => new RemoveScheduledJobCommand(scheduledJobId ?? Guid.NewGuid()))
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/StartScheduledJob/StartScheduledJobCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/StartScheduledJob/StartScheduledJobCommandFixture.cs
new file mode 100644
index 00000000..4a1abd0a
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/StartScheduledJob/StartScheduledJobCommandFixture.cs
@@ -0,0 +1,40 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Core.Scheduling.Commands.StartScheduledJob;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Core.Scheduling.Commands.StartScheduledJob;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class StartScheduledJobCommandFixture
+{
+ ///
+ /// Creates a random valid command to start the execution cycle of a scheduled job.
+ ///
+ /// Optional. The Id of the scheduled job whose execution cycle is started.
+ /// The created command.
+ public StartScheduledJobCommand Create(
+ Guid? scheduledJobId = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f => new StartScheduledJobCommand(scheduledJobId ?? Guid.NewGuid()))
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/StopScheduledJob/StopScheduledJobCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/StopScheduledJob/StopScheduledJobCommandFixture.cs
new file mode 100644
index 00000000..94411cc7
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/StopScheduledJob/StopScheduledJobCommandFixture.cs
@@ -0,0 +1,40 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Core.Scheduling.Commands.StopScheduledJob;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Core.Scheduling.Commands.StopScheduledJob;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class StopScheduledJobCommandFixture
+{
+ ///
+ /// Creates a random valid command to stop the execution cycle of a scheduled job.
+ ///
+ /// Optional. The Id of the scheduled job whose execution cycle is stopped.
+ /// The created command.
+ public StopScheduledJobCommand Create(
+ Guid? scheduledJobId = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f => new StopScheduledJobCommand(scheduledJobId ?? Guid.NewGuid()))
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/UpdateSchedulerDisplayPreferences/UpdateSchedulerDisplayPreferencesCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/UpdateSchedulerDisplayPreferences/UpdateSchedulerDisplayPreferencesCommandFixture.cs
new file mode 100644
index 00000000..4f83a71e
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Commands/UpdateSchedulerDisplayPreferences/UpdateSchedulerDisplayPreferencesCommandFixture.cs
@@ -0,0 +1,47 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Core.Scheduling.Commands.UpdateSchedulerDisplayPreferences;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Core.Scheduling.Commands.UpdateSchedulerDisplayPreferences;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class UpdateSchedulerDisplayPreferencesCommandFixture
+{
+ ///
+ /// Creates a random valid command to update the display preferences of the scheduler page of the current user.
+ ///
+ /// Optional. The type of the scheduled job tasks whose executions are shown.
+ /// Optional. The displayed time span.
+ /// Optional. The unit of the displayed time span.
+ /// The created command.
+ public UpdateSchedulerDisplayPreferencesCommand Create(
+ ScheduledTaskType? jobTypeFilter = null,
+ int? displayTimeSpan = null,
+ SchedulerDisplayTimeUnit? displayTimeUnit = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f => new UpdateSchedulerDisplayPreferencesCommand(
+ jobTypeFilter ?? (f.Random.Bool() ? f.PickRandom() : null),
+ displayTimeSpan ?? f.Random.Int(1, 24 * 60),
+ displayTimeUnit ?? f.PickRandom()))
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Queries/GetScheduledJobHistory/GetScheduledJobHistoryQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Queries/GetScheduledJobHistory/GetScheduledJobHistoryQueryFixture.cs
new file mode 100644
index 00000000..30778a36
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Core/Scheduling/Queries/GetScheduledJobHistory/GetScheduledJobHistoryQueryFixture.cs
@@ -0,0 +1,53 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Core.Scheduling.Queries.GetScheduledJobHistory;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Core.Scheduling.Queries.GetScheduledJobHistory;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetScheduledJobHistoryQueryFixture
+{
+ ///
+ /// Creates a random valid query to get the history of the executions of the tasks of scheduled jobs.
+ ///
+ /// Optional. The inclusive lower bound of the requested interval.
+ /// Optional. The inclusive upper bound of the requested interval.
+ /// Whether to include the lower bound in the query. When false, the lower bound is left unset.
+ /// Whether to include the upper bound in the query. When false, the upper bound is left unset.
+ /// The created query.
+ public GetScheduledJobHistoryQuery Create(
+ DateTime? from = null,
+ DateTime? to = null,
+ bool includeFrom = true,
+ bool includeTo = true)
+ {
+ return new Faker()
+ .CustomInstantiator(f =>
+ {
+ DateTime generatedFrom = f.Date.Recent(30);
+ DateTime? resolvedFrom = includeFrom ? (from ?? generatedFrom) : null;
+ DateTime resolvedToBase = resolvedFrom ?? generatedFrom;
+ DateTime? resolvedTo = includeTo ? (to ?? f.Date.Soon(1, resolvedToBase)) : null;
+ return new GetScheduledJobHistoryQuery(resolvedFrom, resolvedTo);
+ })
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/AddScheduledJobRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/AddScheduledJobRequestFixture.cs
new file mode 100644
index 00000000..95fda6aa
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/AddScheduledJobRequestFixture.cs
@@ -0,0 +1,70 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.Requests.Scheduling;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class AddScheduledJobRequestFixture
+{
+ ///
+ /// Creates a random valid request to add a scheduled job.
+ ///
+ /// Optional. The name of the scheduled job.
+ /// Optional. The type of the task executed by the scheduled job.
+ /// Optional. The type of the schedule of the scheduled job.
+ /// Optional. The interval in minutes of the schedule.
+ /// Optional. The hour of the schedule.
+ /// Optional. The minute of the schedule.
+ /// The created request.
+ public AddScheduledJobRequest Create(
+ string? name = null,
+ ScheduledTaskType? taskType = null,
+ ScheduleType? scheduleType = null,
+ int? intervalMinutes = null,
+ int? hour = null,
+ int? minute = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f =>
+ {
+ ScheduleType resolvedScheduleType = scheduleType ?? f.PickRandom();
+ if (resolvedScheduleType == ScheduleType.WithIntervalInMinutes)
+ {
+ return new AddScheduledJobRequest(
+ name ?? f.Commerce.ProductName(),
+ taskType ?? f.PickRandom(),
+ resolvedScheduleType,
+ intervalMinutes ?? f.Random.Int(1, 1440),
+ null,
+ null);
+ }
+ return new AddScheduledJobRequest(
+ name ?? f.Commerce.ProductName(),
+ taskType ?? f.PickRandom(),
+ resolvedScheduleType,
+ null,
+ hour ?? f.Random.Int(0, 23),
+ minute ?? f.Random.Int(0, 59));
+ })
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/FireScheduledJobRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/FireScheduledJobRequestFixture.cs
new file mode 100644
index 00000000..cb6e79ad
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/FireScheduledJobRequestFixture.cs
@@ -0,0 +1,40 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.Requests.Scheduling;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class FireScheduledJobRequestFixture
+{
+ ///
+ /// Creates a random valid request to fire the task of a scheduled job once.
+ ///
+ /// Optional. The Id of the scheduled job whose task is fired.
+ /// The created request.
+ public FireScheduledJobRequest Create(
+ Guid? scheduledJobId = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f => new FireScheduledJobRequest(scheduledJobId ?? Guid.NewGuid()))
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/GetScheduledJobHistoryRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/GetScheduledJobHistoryRequestFixture.cs
new file mode 100644
index 00000000..a794a0c1
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/GetScheduledJobHistoryRequestFixture.cs
@@ -0,0 +1,47 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.Requests.Scheduling;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetScheduledJobHistoryRequestFixture
+{
+ ///
+ /// Creates a random valid request to get the history of the executions of the tasks of scheduled jobs.
+ ///
+ /// Optional. The inclusive lower bound of the requested interval.
+ /// Optional. The inclusive upper bound of the requested interval.
+ /// The created request.
+ public GetScheduledJobHistoryRequest Create(
+ DateTime? from = null,
+ DateTime? to = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f =>
+ {
+ DateTime resolvedFrom = from ?? f.Date.Recent(30);
+ DateTime resolvedTo = to ?? f.Date.Soon(1, resolvedFrom);
+ return new GetScheduledJobHistoryRequest(resolvedFrom, resolvedTo);
+ })
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/RemoveScheduledJobRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/RemoveScheduledJobRequestFixture.cs
new file mode 100644
index 00000000..42b3209f
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/RemoveScheduledJobRequestFixture.cs
@@ -0,0 +1,40 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.Requests.Scheduling;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class RemoveScheduledJobRequestFixture
+{
+ ///
+ /// Creates a random valid request to remove a scheduled job.
+ ///
+ /// Optional. The Id of the scheduled job to remove.
+ /// The created request.
+ public RemoveScheduledJobRequest Create(
+ Guid? scheduledJobId = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f => new RemoveScheduledJobRequest(scheduledJobId ?? Guid.NewGuid()))
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/StartScheduledJobRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/StartScheduledJobRequestFixture.cs
new file mode 100644
index 00000000..305b686f
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/StartScheduledJobRequestFixture.cs
@@ -0,0 +1,40 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.Requests.Scheduling;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class StartScheduledJobRequestFixture
+{
+ ///
+ /// Creates a random valid request to start the execution cycle of a scheduled job.
+ ///
+ /// Optional. The Id of the scheduled job whose execution cycle is started.
+ /// The created request.
+ public StartScheduledJobRequest Create(
+ Guid? scheduledJobId = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f => new StartScheduledJobRequest(scheduledJobId ?? Guid.NewGuid()))
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/StopScheduledJobRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/StopScheduledJobRequestFixture.cs
new file mode 100644
index 00000000..0978d834
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/StopScheduledJobRequestFixture.cs
@@ -0,0 +1,40 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.Requests.Scheduling;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class StopScheduledJobRequestFixture
+{
+ ///
+ /// Creates a random valid request to stop the execution cycle of a scheduled job.
+ ///
+ /// Optional. The Id of the scheduled job whose execution cycle is stopped.
+ /// The created request.
+ public StopScheduledJobRequest Create(
+ Guid? scheduledJobId = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f => new StopScheduledJobRequest(scheduledJobId ?? Guid.NewGuid()))
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/UpdateSchedulerDisplayPreferencesRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/UpdateSchedulerDisplayPreferencesRequestFixture.cs
new file mode 100644
index 00000000..2c673344
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Scheduling/UpdateSchedulerDisplayPreferencesRequestFixture.cs
@@ -0,0 +1,47 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.Requests.Scheduling;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class UpdateSchedulerDisplayPreferencesRequestFixture
+{
+ ///
+ /// Creates a random valid request to update the display preferences of the scheduler page of the current user.
+ ///
+ /// Optional. The type of the scheduled job tasks whose executions are shown.
+ /// Optional. The displayed time span.
+ /// Optional. The unit of the displayed time span.
+ /// The created request.
+ public UpdateSchedulerDisplayPreferencesRequest Create(
+ ScheduledTaskType? jobTypeFilter = null,
+ int? displayTimeSpan = null,
+ SchedulerDisplayTimeUnit? displayTimeUnit = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f => new UpdateSchedulerDisplayPreferencesRequest(
+ jobTypeFilter ?? (f.Random.Bool() ? f.PickRandom() : null),
+ displayTimeSpan ?? f.Random.Int(1, 24 * 60),
+ displayTimeUnit ?? f.PickRandom()))
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Scheduling/ScheduledJobExecutionResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Scheduling/ScheduledJobExecutionResponseFixture.cs
new file mode 100644
index 00000000..66d6b3d8
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Scheduling/ScheduledJobExecutionResponseFixture.cs
@@ -0,0 +1,57 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.Responses.Scheduling;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.Responses.Scheduling;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobExecutionResponseFixture
+{
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the execution.
+ /// Optional. The Id of the scheduled job whose task was executed.
+ /// Optional. The type of the task that was executed.
+ /// Optional. Whether the execution was a cycle run.
+ /// Optional. The start time of the execution.
+ /// Optional. The completion time of the execution.
+ /// The created .
+ public ScheduledJobExecutionResponse Create(
+ Guid? id = null,
+ Guid? scheduledJobId = null,
+ ScheduledTaskType? taskType = null,
+ bool? isCycleRun = null,
+ DateTime? startedOnUtc = null,
+ DateTime? completedOnUtc = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f => new ScheduledJobExecutionResponse(
+ id ?? Guid.NewGuid(),
+ scheduledJobId ?? Guid.NewGuid(),
+ taskType ?? f.PickRandom(),
+ isCycleRun ?? f.Random.Bool(),
+ startedOnUtc ?? DateTime.UtcNow,
+ completedOnUtc))
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Scheduling/ScheduledJobResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Scheduling/ScheduledJobResponseFixture.cs
new file mode 100644
index 00000000..79de0565
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Scheduling/ScheduledJobResponseFixture.cs
@@ -0,0 +1,87 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.Responses.Scheduling;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.Responses.Scheduling;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobResponseFixture
+{
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the scheduled job.
+ /// Optional. The name of the scheduled job.
+ /// Optional. The type of the task executed by the scheduled job.
+ /// Optional. The type of the schedule of the scheduled job.
+ /// Optional. The interval in minutes of the schedule.
+ /// Optional. The hour of the schedule.
+ /// Optional. The minute of the schedule.
+ /// Optional. The status of the scheduled job.
+ /// Optional. The last start time of the scheduled job.
+ /// Optional. The last completion time of the scheduled job.
+ /// The created .
+ public ScheduledJobResponse Create(
+ Guid? id = null,
+ string? name = null,
+ ScheduledTaskType? taskType = null,
+ ScheduleType? scheduleType = null,
+ int? intervalMinutes = null,
+ int? hour = null,
+ int? minute = null,
+ ScheduledJobStatus? status = null,
+ DateTime? lastStartedOnUtc = null,
+ DateTime? lastCompletedOnUtc = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f =>
+ {
+ ScheduleType resolvedScheduleType = scheduleType ?? f.PickRandom();
+ if (resolvedScheduleType == ScheduleType.WithIntervalInMinutes)
+ {
+ return new ScheduledJobResponse(
+ id ?? Guid.NewGuid(),
+ name ?? f.Commerce.ProductName(),
+ taskType ?? f.PickRandom(),
+ resolvedScheduleType,
+ intervalMinutes ?? f.Random.Int(1, 1440),
+ null,
+ null,
+ status ?? f.PickRandom(),
+ lastStartedOnUtc,
+ lastCompletedOnUtc);
+ }
+ return new ScheduledJobResponse(
+ id ?? Guid.NewGuid(),
+ name ?? f.Commerce.ProductName(),
+ taskType ?? f.PickRandom(),
+ resolvedScheduleType,
+ null,
+ hour ?? f.Random.Int(0, 23),
+ minute ?? f.Random.Int(0, 59),
+ status ?? f.PickRandom(),
+ lastStartedOnUtc,
+ lastCompletedOnUtc);
+ })
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Scheduling/SchedulerDisplayPreferencesResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Scheduling/SchedulerDisplayPreferencesResponseFixture.cs
new file mode 100644
index 00000000..9a2774b1
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Scheduling/SchedulerDisplayPreferencesResponseFixture.cs
@@ -0,0 +1,51 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.Responses.Scheduling;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.Responses.Scheduling;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class SchedulerDisplayPreferencesResponseFixture
+{
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the user that owns the display preferences.
+ /// Optional. The type of the scheduled job tasks whose executions are shown.
+ /// Optional. The displayed time span.
+ /// Optional. The unit of the displayed time span.
+ /// The created .
+ public SchedulerDisplayPreferencesResponse Create(
+ Guid? userId = null,
+ ScheduledTaskType? jobTypeFilter = null,
+ int? displayTimeSpan = null,
+ SchedulerDisplayTimeUnit? displayTimeUnit = null)
+ {
+ return new Faker()
+ .CustomInstantiator(f => new SchedulerDisplayPreferencesResponse(
+ userId ?? Guid.NewGuid(),
+ jobTypeFilter ?? (f.Random.Bool() ? f.PickRandom() : null),
+ displayTimeSpan ?? f.Random.Int(1, 24 * 60),
+ displayTimeUnit ?? f.PickRandom()))
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/Events/LibraryDeletedDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/Events/LibraryDeletedDomainEventFixture.cs
new file mode 100644
index 00000000..452f7b32
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/Events/LibraryDeletedDomainEventFixture.cs
@@ -0,0 +1,33 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class LibraryDeletedDomainEventFixture
+{
+ private readonly LibraryFixture _libraryFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The library that was deleted.
+ /// Optional. The date and time when the domain event occurred.
+ /// The created .
+ public LibraryDeletedDomainEvent Create(Guid? id = null, Library? library = null, DateTime? occurredOnUtc = null)
+ {
+ return new LibraryDeletedDomainEvent(
+ id ?? Guid.NewGuid(),
+ library ?? _libraryFixture.Create(),
+ occurredOnUtc ?? DateTime.UtcNow);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryMediaItemDeletedDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryMediaItemDeletedDomainEventFixture.cs
new file mode 100644
index 00000000..98350482
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryMediaItemDeletedDomainEventFixture.cs
@@ -0,0 +1,47 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class LibraryMediaItemDeletedDomainEventFixture
+{
+ private readonly Faker _faker = new();
+ private readonly LibraryIdFixture _libraryIdFixture = new();
+ private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The unique identifier of the library to which the deleted media library item belonged.
+ /// Optional. The composite identifier of the media library scan during which the item deletion was detected.
+ /// Optional. The path of the media library item that was deleted.
+ /// Optional. The date and time when the domain event occurred.
+ /// The created .
+ public LibraryMediaItemDeletedDomainEvent Create(
+ Guid? id = null,
+ LibraryId? libraryId = null,
+ MediaLibraryScanCompositeId? mediaLibraryScanCompositeId = null,
+ string? path = null,
+ DateTime? occurredOnUtc = null)
+ {
+ return new LibraryMediaItemDeletedDomainEvent(
+ id ?? Guid.NewGuid(),
+ libraryId ?? _libraryIdFixture.Create(),
+ mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
+ path ?? _faker.System.FilePath(),
+ occurredOnUtc ?? DateTime.UtcNow);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanCancelledDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanCancelledDomainEventFixture.cs
new file mode 100644
index 00000000..431fb664
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanCancelledDomainEventFixture.cs
@@ -0,0 +1,42 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class LibraryScanCancelledDomainEventFixture
+{
+ private readonly ScanIdFixture _scanIdFixture = new();
+ private readonly LibraryIdFixture _libraryIdFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The unique identifier of the cancelled media library scan.
+ /// Optional. The unique identifier of the library whose scan was cancelled.
+ /// Optional. The date and time when the domain event occurred.
+ /// The created .
+ public LibraryScanCancelledDomainEvent Create(
+ Guid? id = null,
+ ScanId? scanId = null,
+ LibraryId? libraryId = null,
+ DateTime? occurredOnUtc = null)
+ {
+ return new LibraryScanCancelledDomainEvent(
+ id ?? Guid.NewGuid(),
+ scanId ?? _scanIdFixture.Create(),
+ libraryId ?? _libraryIdFixture.Create(),
+ occurredOnUtc ?? DateTime.UtcNow);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanFailedDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanFailedDomainEventFixture.cs
new file mode 100644
index 00000000..1d28c60a
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanFailedDomainEventFixture.cs
@@ -0,0 +1,49 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class LibraryScanFailedDomainEventFixture
+{
+ private readonly Faker _faker = new();
+ private readonly LibraryIdFixture _libraryIdFixture = new();
+ private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The unique identifier of the library whose scan has failed.
+ /// Optional. The composite identifier of the media library scan that has failed.
+ /// Optional. The date and time when the domain event occurred.
+ /// Optional. The descriptive message of the failure.
+ /// Whether to include an error message in the domain event. When false, the error message is left unset.
+ /// The created .
+ public LibraryScanFailedDomainEvent Create(
+ Guid? id = null,
+ LibraryId? libraryId = null,
+ MediaLibraryScanCompositeId? mediaLibraryScanCompositeId = null,
+ DateTime? occurredOnUtc = null,
+ string? errorMessage = null,
+ bool includeErrorMessage = true)
+ {
+ return new LibraryScanFailedDomainEvent(
+ id ?? Guid.NewGuid(),
+ libraryId ?? _libraryIdFixture.Create(),
+ mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
+ occurredOnUtc ?? DateTime.UtcNow,
+ includeErrorMessage ? (errorMessage ?? _faker.Random.Words()) : null);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanFinishedDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanFinishedDomainEventFixture.cs
new file mode 100644
index 00000000..98f0316d
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanFinishedDomainEventFixture.cs
@@ -0,0 +1,36 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class LibraryScanFinishedDomainEventFixture
+{
+ private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The composite identifier of the media library scan that was finished.
+ /// Optional. The date and time when the domain event occurred.
+ /// The created .
+ public LibraryScanFinishedDomainEvent Create(
+ Guid? id = null,
+ MediaLibraryScanCompositeId? mediaLibraryScanCompositeId = null,
+ DateTime? occurredOnUtc = null)
+ {
+ return new LibraryScanFinishedDomainEvent(
+ id ?? Guid.NewGuid(),
+ mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
+ occurredOnUtc ?? DateTime.UtcNow);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanJobProgressChangedDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanJobProgressChangedDomainEventFixture.cs
new file mode 100644
index 00000000..215ee411
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanJobProgressChangedDomainEventFixture.cs
@@ -0,0 +1,46 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class LibraryScanJobProgressChangedDomainEventFixture
+{
+ private readonly LibraryIdFixture _libraryIdFixture = new();
+ private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
+ private readonly MediaLibraryScanJobProgressFixture _mediaLibraryScanJobProgressFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The unique identifier of the library being scanned.
+ /// Optional. The composite identifier of the media library scan whose job progress changed.
+ /// Optional. The new media library scan job progress.
+ /// Optional. The date and time when the domain event occurred.
+ /// The created .
+ public LibraryScanJobProgressChangedDomainEvent Create(
+ Guid? id = null,
+ LibraryId? libraryId = null,
+ MediaLibraryScanCompositeId? mediaLibraryScanCompositeId = null,
+ MediaLibraryScanJobProgress? progress = null,
+ DateTime? occurredOnUtc = null)
+ {
+ return new LibraryScanJobProgressChangedDomainEvent(
+ id ?? Guid.NewGuid(),
+ libraryId ?? _libraryIdFixture.Create(),
+ mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
+ progress ?? _mediaLibraryScanJobProgressFixture.Create(),
+ occurredOnUtc ?? DateTime.UtcNow);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanProgressChangedDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanProgressChangedDomainEventFixture.cs
new file mode 100644
index 00000000..91678af3
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanProgressChangedDomainEventFixture.cs
@@ -0,0 +1,42 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class LibraryScanProgressChangedDomainEventFixture
+{
+ private readonly LibraryIdFixture _libraryIdFixture = new();
+ private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The unique identifier of the library being scanned.
+ /// Optional. The composite identifier of the media library scan whose progress changed.
+ /// Optional. The date and time when the domain event occurred.
+ /// The created .
+ public LibraryScanProgressChangedDomainEvent Create(
+ Guid? id = null,
+ LibraryId? libraryId = null,
+ MediaLibraryScanCompositeId? mediaLibraryScanCompositeId = null,
+ DateTime? occurredOnUtc = null)
+ {
+ return new LibraryScanProgressChangedDomainEvent(
+ id ?? Guid.NewGuid(),
+ libraryId ?? _libraryIdFixture.Create(),
+ mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
+ occurredOnUtc ?? DateTime.UtcNow);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanQueuedDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanQueuedDomainEventFixture.cs
new file mode 100644
index 00000000..8e729533
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanQueuedDomainEventFixture.cs
@@ -0,0 +1,42 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class LibraryScanQueuedDomainEventFixture
+{
+ private readonly ScanIdFixture _scanIdFixture = new();
+ private readonly LibraryIdFixture _libraryIdFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The unique identifier of the queued media library scan.
+ /// Optional. The unique identifier of the library whose scan was queued.
+ /// Optional. The date and time when the domain event occurred.
+ /// The created .
+ public LibraryScanQueuedDomainEvent Create(
+ Guid? id = null,
+ ScanId? scanId = null,
+ LibraryId? libraryId = null,
+ DateTime? occurredOnUtc = null)
+ {
+ return new LibraryScanQueuedDomainEvent(
+ id ?? Guid.NewGuid(),
+ scanId ?? _scanIdFixture.Create(),
+ libraryId ?? _libraryIdFixture.Create(),
+ occurredOnUtc ?? DateTime.UtcNow);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanStartedDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanStartedDomainEventFixture.cs
new file mode 100644
index 00000000..2bfd152d
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryScanAggregate/Events/LibraryScanStartedDomainEventFixture.cs
@@ -0,0 +1,33 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class LibraryScanStartedDomainEventFixture
+{
+ private readonly LibraryScanFixture _libraryScanFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The library scan that was started.
+ /// Optional. The date and time when the domain event occurred.
+ /// The created .
+ public LibraryScanStartedDomainEvent Create(Guid? id = null, LibraryScan? libraryScan = null, DateTime? occurredOnUtc = null)
+ {
+ return new LibraryScanStartedDomainEvent(
+ id ?? Guid.NewGuid(),
+ libraryScan ?? _libraryScanFixture.Create(),
+ occurredOnUtc ?? DateTime.UtcNow);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ExternalIdentifiers/UserManagementBoundedContext/UserAggregate/UserIdFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ExternalIdentifiers/UserManagementBoundedContext/UserAggregate/UserIdFixture.cs
new file mode 100644
index 00000000..a0a1cedf
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ExternalIdentifiers/UserManagementBoundedContext/UserAggregate/UserIdFixture.cs
@@ -0,0 +1,37 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
+
+///
+/// Fixture class for the value object.
+///
+[ExcludeFromCodeCoverage]
+public class UserIdFixture
+{
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The raw value of the user Id.
+ /// The created .
+ public UserId Create(
+ Guid? value = null)
+ {
+ return UserId.Create(value ?? Guid.NewGuid());
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobAddedDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobAddedDomainEventFixture.cs
new file mode 100644
index 00000000..fdd5fc47
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobAddedDomainEventFixture.cs
@@ -0,0 +1,36 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobAddedDomainEventFixture
+{
+ private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The unique identifier of the scheduled job that was added.
+ /// Optional. The date and time when the domain event occurred.
+ /// The created .
+ public ScheduledJobAddedDomainEvent Create(
+ Guid? id = null,
+ ScheduledJobId? scheduledJobId = null,
+ DateTime? occurredOnUtc = null)
+ {
+ return new ScheduledJobAddedDomainEvent(
+ id ?? Guid.NewGuid(),
+ scheduledJobId ?? _scheduledJobIdFixture.Create(),
+ occurredOnUtc ?? DateTime.UtcNow);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobCycleStartedDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobCycleStartedDomainEventFixture.cs
new file mode 100644
index 00000000..217dde04
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobCycleStartedDomainEventFixture.cs
@@ -0,0 +1,36 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobCycleStartedDomainEventFixture
+{
+ private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The unique identifier of the scheduled job whose execution cycle was started.
+ /// Optional. The date and time when the domain event occurred.
+ /// The created .
+ public ScheduledJobCycleStartedDomainEvent Create(
+ Guid? id = null,
+ ScheduledJobId? scheduledJobId = null,
+ DateTime? occurredOnUtc = null)
+ {
+ return new ScheduledJobCycleStartedDomainEvent(
+ id ?? Guid.NewGuid(),
+ scheduledJobId ?? _scheduledJobIdFixture.Create(),
+ occurredOnUtc ?? DateTime.UtcNow);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobCycleStoppedDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobCycleStoppedDomainEventFixture.cs
new file mode 100644
index 00000000..71cee8fc
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobCycleStoppedDomainEventFixture.cs
@@ -0,0 +1,36 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobCycleStoppedDomainEventFixture
+{
+ private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The unique identifier of the scheduled job whose execution cycle was stopped.
+ /// Optional. The date and time when the domain event occurred.
+ /// The created .
+ public ScheduledJobCycleStoppedDomainEvent Create(
+ Guid? id = null,
+ ScheduledJobId? scheduledJobId = null,
+ DateTime? occurredOnUtc = null)
+ {
+ return new ScheduledJobCycleStoppedDomainEvent(
+ id ?? Guid.NewGuid(),
+ scheduledJobId ?? _scheduledJobIdFixture.Create(),
+ occurredOnUtc ?? DateTime.UtcNow);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobExecutionCompletedDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobExecutionCompletedDomainEventFixture.cs
new file mode 100644
index 00000000..40c1a0c5
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobExecutionCompletedDomainEventFixture.cs
@@ -0,0 +1,46 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobExecutionCompletedDomainEventFixture
+{
+ private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The unique identifier of the scheduled job whose task completed its execution.
+ /// Optional. The unique identifier of the current execution of the task of the scheduled job.
+ /// The type of the task that completed its execution.
+ /// Whether the execution was triggered by the execution cycle of the scheduled job.
+ /// Optional. The date and time when the execution completed.
+ /// The created .
+ public ScheduledJobExecutionCompletedDomainEvent Create(
+ Guid? id = null,
+ ScheduledJobId? scheduledJobId = null,
+ Guid? runId = null,
+ ScheduledTaskType taskType = ScheduledTaskType.ScanMediaLibraries,
+ bool isCycleRun = false,
+ DateTime? completedOnUtc = null)
+ {
+ return new ScheduledJobExecutionCompletedDomainEvent(
+ id ?? Guid.NewGuid(),
+ scheduledJobId ?? _scheduledJobIdFixture.Create(),
+ runId ?? Guid.NewGuid(),
+ taskType,
+ isCycleRun,
+ completedOnUtc ?? DateTime.UtcNow);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobExecutionStartedDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobExecutionStartedDomainEventFixture.cs
new file mode 100644
index 00000000..866c3488
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobExecutionStartedDomainEventFixture.cs
@@ -0,0 +1,46 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobExecutionStartedDomainEventFixture
+{
+ private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The unique identifier of the scheduled job whose task started executing.
+ /// Optional. The unique identifier of the current execution of the task of the scheduled job.
+ /// The type of the task that started executing.
+ /// Whether the execution was triggered by the execution cycle of the scheduled job.
+ /// Optional. The date and time when the execution started.
+ /// The created .
+ public ScheduledJobExecutionStartedDomainEvent Create(
+ Guid? id = null,
+ ScheduledJobId? scheduledJobId = null,
+ Guid? runId = null,
+ ScheduledTaskType taskType = ScheduledTaskType.ScanMediaLibraries,
+ bool isCycleRun = false,
+ DateTime? startedOnUtc = null)
+ {
+ return new ScheduledJobExecutionStartedDomainEvent(
+ id ?? Guid.NewGuid(),
+ scheduledJobId ?? _scheduledJobIdFixture.Create(),
+ runId ?? Guid.NewGuid(),
+ taskType,
+ isCycleRun,
+ startedOnUtc ?? DateTime.UtcNow);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobExecutionStoppedDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobExecutionStoppedDomainEventFixture.cs
new file mode 100644
index 00000000..0a2a3afc
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobExecutionStoppedDomainEventFixture.cs
@@ -0,0 +1,36 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobExecutionStoppedDomainEventFixture
+{
+ private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The unique identifier of the scheduled job whose running execution was stopped.
+ /// Optional. The date and time when the domain event occurred.
+ /// The created .
+ public ScheduledJobExecutionStoppedDomainEvent Create(
+ Guid? id = null,
+ ScheduledJobId? scheduledJobId = null,
+ DateTime? occurredOnUtc = null)
+ {
+ return new ScheduledJobExecutionStoppedDomainEvent(
+ id ?? Guid.NewGuid(),
+ scheduledJobId ?? _scheduledJobIdFixture.Create(),
+ occurredOnUtc ?? DateTime.UtcNow);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobFiredDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobFiredDomainEventFixture.cs
new file mode 100644
index 00000000..d9400e01
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobFiredDomainEventFixture.cs
@@ -0,0 +1,36 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobFiredDomainEventFixture
+{
+ private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The unique identifier of the scheduled job whose task was fired.
+ /// Optional. The date and time when the domain event occurred.
+ /// The created .
+ public ScheduledJobFiredDomainEvent Create(
+ Guid? id = null,
+ ScheduledJobId? scheduledJobId = null,
+ DateTime? occurredOnUtc = null)
+ {
+ return new ScheduledJobFiredDomainEvent(
+ id ?? Guid.NewGuid(),
+ scheduledJobId ?? _scheduledJobIdFixture.Create(),
+ occurredOnUtc ?? DateTime.UtcNow);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobRemovedDomainEventFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobRemovedDomainEventFixture.cs
new file mode 100644
index 00000000..5e044e56
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/Events/ScheduledJobRemovedDomainEventFixture.cs
@@ -0,0 +1,36 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobRemovedDomainEventFixture
+{
+ private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the domain event.
+ /// Optional. The unique identifier of the scheduled job that was removed.
+ /// Optional. The date and time when the domain event occurred.
+ /// The created .
+ public ScheduledJobRemovedDomainEvent Create(
+ Guid? id = null,
+ ScheduledJobId? scheduledJobId = null,
+ DateTime? occurredOnUtc = null)
+ {
+ return new ScheduledJobRemovedDomainEvent(
+ id ?? Guid.NewGuid(),
+ scheduledJobId ?? _scheduledJobIdFixture.Create(),
+ occurredOnUtc ?? DateTime.UtcNow);
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/ScheduledJobFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/ScheduledJobFixture.cs
new file mode 100644
index 00000000..2cffc6b4
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/ScheduledJobFixture.cs
@@ -0,0 +1,83 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate;
+
+///
+/// Fixture class for the domain aggregate.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobFixture
+{
+ private readonly IntervalScheduleFixture _intervalScheduleFixture = new();
+
+ ///
+ /// Creates a random valid domain aggregate.
+ ///
+ /// Optional. The Id of the scheduled job. When provided, the aggregate is created with pre-existing data.
+ /// Optional. The name of the scheduled job.
+ /// Optional. The type of the task executed by the scheduled job.
+ /// Optional. The schedule of the scheduled job. Defaults to an interval schedule of 60 minutes.
+ /// Optional. The Id of the user that owns the scheduled job.
+ /// Optional. The status of the scheduled job. Only applied when is provided.
+ /// Optional. The last start time of the scheduled job. Only applied when is provided.
+ /// Optional. The last completion time of the scheduled job. Only applied when is provided.
+ /// The created .
+ public ScheduledJob Create(
+ Guid? id = null,
+ string? name = null,
+ ScheduledTaskType? taskType = null,
+ Schedule? schedule = null,
+ Guid? ownerUserId = null,
+ ScheduledJobStatus? status = null,
+ DateTime? lastStartedOnUtc = null,
+ DateTime? lastCompletedOnUtc = null)
+ {
+ Faker faker = new();
+ ScheduledJobStatus resolvedStatus = status ?? ScheduledJobStatus.Added;
+ string resolvedName = name ?? faker.Commerce.ProductName();
+ ScheduledTaskType resolvedTaskType = taskType ?? faker.PickRandom();
+ UserId resolvedOwnerUserId = UserId.Create(ownerUserId ?? Guid.NewGuid());
+ Schedule resolvedSchedule = schedule ?? _intervalScheduleFixture.Create(faker.Random.Int(5, 1440));
+
+ // When no pre-existing state is requested, create a fresh scheduled job with the default Added status.
+ if (id is null && status is null)
+ {
+ Result createResult = ScheduledJob.Create(resolvedName, resolvedTaskType, resolvedSchedule, resolvedOwnerUserId);
+ return createResult.Value;
+ }
+
+ // When a pre-existing Id or an explicit status is requested, create the scheduled job with that pre-existing state.
+ Result createWithIdResult = ScheduledJob.Create(
+ ScheduledJobId.Create(id ?? Guid.NewGuid()),
+ resolvedName,
+ resolvedTaskType,
+ resolvedSchedule,
+ resolvedOwnerUserId,
+ resolvedStatus,
+ Optional.FromNullable(lastStartedOnUtc),
+ Optional.FromNullable(lastCompletedOnUtc));
+ return createWithIdResult.Value;
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/ValueObjects/DailyScheduleFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/ValueObjects/DailyScheduleFixture.cs
new file mode 100644
index 00000000..a61dbdea
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/ValueObjects/DailyScheduleFixture.cs
@@ -0,0 +1,41 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+
+///
+/// Fixture class for the value object.
+///
+[ExcludeFromCodeCoverage]
+public class DailyScheduleFixture
+{
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The hour of the day at which the task runs.
+ /// Optional. The minute of the hour at which the task runs.
+ /// The created .
+ public DailySchedule Create(int? hour = null, int? minute = null)
+ {
+ Faker faker = new();
+ return DailySchedule.Create(
+ hour ?? faker.Random.Int(0, 23),
+ minute ?? faker.Random.Int(0, 59)).Value;
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/ValueObjects/IntervalScheduleFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/ValueObjects/IntervalScheduleFixture.cs
new file mode 100644
index 00000000..1bd9e736
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/ValueObjects/IntervalScheduleFixture.cs
@@ -0,0 +1,38 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+
+///
+/// Fixture class for the value object.
+///
+[ExcludeFromCodeCoverage]
+public class IntervalScheduleFixture
+{
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The number of minutes between each execution.
+ /// The created .
+ public IntervalSchedule Create(int? intervalMinutes = null)
+ {
+ Faker faker = new();
+ return IntervalSchedule.Create(intervalMinutes ?? faker.Random.Int(1, 1440)).Value;
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/ValueObjects/ScheduledJobIdFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/ValueObjects/ScheduledJobIdFixture.cs
new file mode 100644
index 00000000..b6fa81e4
--- /dev/null
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/SchedulingBoundedContext/ScheduledJobAggregate/ValueObjects/ScheduledJobIdFixture.cs
@@ -0,0 +1,37 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+
+///
+/// Fixture class for the value object.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobIdFixture
+{
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The raw value of the scheduled job Id.
+ /// The created .
+ public ScheduledJobId Create(
+ Guid? value = null)
+ {
+ return ScheduledJobId.Create(value ?? Guid.NewGuid());
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Scheduling/AddScheduledJob/AddScheduledJobEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Scheduling/AddScheduledJob/AddScheduledJobEndpointTests.cs
new file mode 100644
index 00000000..f04b5cd4
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Scheduling/AddScheduledJob/AddScheduledJobEndpointTests.cs
@@ -0,0 +1,183 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Authorization;
+using Lumina.Application.Common.DataAccess.Entities.Scheduling;
+using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+using Lumina.Contracts.Requests.Scheduling;
+using Lumina.Contracts.Responses.Scheduling;
+using Lumina.DataAccess.Core.UoW;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using Lumina.Presentation.Api.IntegrationTests.Common.Setup;
+using Microsoft.AspNetCore.Http;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Json;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Api.IntegrationTests.Core.Endpoints.Scheduling.AddScheduledJob;
+
+///
+/// Contains integration tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class AddScheduledJobEndpointTests : IClassFixture, IAsyncLifetime
+{
+ private readonly AuthenticatedLuminaApiFactory _apiFactory;
+ private readonly JsonSerializerOptions _jsonOptions = new()
+ {
+ PropertyNameCaseInsensitive = true,
+ Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
+ };
+ private readonly AddScheduledJobRequestFixture _addScheduledJobRequestFixture = new();
+ private readonly List _createdScheduledJobIds = [];
+ private HttpClient _client;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected in-memory API factory.
+ public AddScheduledJobEndpointTests(AuthenticatedLuminaApiFactory apiFactory)
+ {
+ _client = apiFactory.CreateClient();
+ _apiFactory = apiFactory;
+ }
+
+ ///
+ /// Initializes an authenticated admin API client.
+ ///
+ public async Task InitializeAsync()
+ {
+ _client = await _apiFactory.CreateAuthenticatedAdminClientAsync();
+ }
+
+ [Fact]
+ public async Task AddScheduledJob_WhenCalledWithValidIntervalRequest_ShouldCreateScheduledJob()
+ {
+ // Arrange
+ AddScheduledJobRequest request = _addScheduledJobRequestFixture.Create(
+ name: $"Scan job {Guid.NewGuid()}",
+ taskType: ScheduledTaskType.ScanMediaLibraries,
+ scheduleType: ScheduleType.WithIntervalInMinutes,
+ intervalMinutes: 60);
+
+ // Act
+ HttpResponseMessage response = await _client.PostAsJsonAsync("/api/v1/scheduled-jobs", request);
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ string content = await response.Content.ReadAsStringAsync();
+ ScheduledJobResponse? result = JsonSerializer.Deserialize(content, _jsonOptions);
+
+ Assert.NotNull(result);
+ Assert.Equal(request.Name, result!.Name);
+ Assert.Equal(request.TaskType, result.TaskType);
+ Assert.Equal(ScheduleType.WithIntervalInMinutes, result.ScheduleType);
+ Assert.Equal(60, result.IntervalMinutes);
+ Assert.Equal(ScheduledJobStatus.Added, result.Status);
+ _createdScheduledJobIds.Add(result.Id);
+ }
+
+ [Fact]
+ public async Task AddScheduledJob_WhenCalledWithValidDailyRequest_ShouldCreateScheduledJob()
+ {
+ // Arrange
+ AddScheduledJobRequest request = _addScheduledJobRequestFixture.Create(
+ name: $"Daily job {Guid.NewGuid()}",
+ taskType: ScheduledTaskType.CleanTemporaryFiles,
+ scheduleType: ScheduleType.DailyAtHourAndMinute,
+ hour: 6,
+ minute: 30);
+
+ // Act
+ HttpResponseMessage response = await _client.PostAsJsonAsync("/api/v1/scheduled-jobs", request);
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ string content = await response.Content.ReadAsStringAsync();
+ ScheduledJobResponse? result = JsonSerializer.Deserialize(content, _jsonOptions);
+
+ Assert.NotNull(result);
+ Assert.Equal(ScheduleType.DailyAtHourAndMinute, result!.ScheduleType);
+ Assert.Equal(6, result.Hour);
+ Assert.Equal(30, result.Minute);
+ Assert.Null(result.IntervalMinutes);
+ _createdScheduledJobIds.Add(result.Id);
+ }
+
+ [Fact]
+ public async Task AddScheduledJob_WhenCalledWithInvalidName_ShouldReturnValidationProblem()
+ {
+ // Arrange
+ AddScheduledJobRequest request = _addScheduledJobRequestFixture.Create(
+ name: " ",
+ scheduleType: ScheduleType.WithIntervalInMinutes,
+ intervalMinutes: 60);
+
+ // Act
+ HttpResponseMessage response = await _client.PostAsJsonAsync("/api/v1/scheduled-jobs", request);
+
+ // Assert
+ Assert.Equal(HttpStatusCode.UnprocessableEntity, response.StatusCode);
+ string content = await response.Content.ReadAsStringAsync();
+ Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions);
+ Assert.NotNull(problemDetails);
+ Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemDetails!["status"].GetInt32());
+ Assert.Equal("General.Validation", problemDetails["title"].GetString());
+ }
+
+ [Fact]
+ public async Task AddScheduledJob_WhenCalledWithNonAdminAccount_ShouldReturnForbiddenResult()
+ {
+ // Arrange
+ _client = await _apiFactory.CreateAuthenticatedClientAsync();
+ AddScheduledJobRequest request = _addScheduledJobRequestFixture.Create(scheduleType: ScheduleType.WithIntervalInMinutes, intervalMinutes: 60);
+
+ // Act
+ HttpResponseMessage response = await _client.PostAsJsonAsync("/api/v1/scheduled-jobs", request);
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
+ string content = await response.Content.ReadAsStringAsync();
+ Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions);
+ Assert.NotNull(problemDetails);
+ Assert.Equal(StatusCodes.Status403Forbidden, problemDetails!["status"].GetInt32());
+ Assert.Equal("General.Unauthorized", problemDetails["title"].GetString());
+ Assert.Equal("NotAuthorized", problemDetails["detail"].GetString());
+ }
+
+ ///
+ /// Disposes API factory resources.
+ ///
+ public async Task DisposeAsync()
+ {
+ using IServiceScope scope = _apiFactory.Services.CreateScope();
+ LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
+
+ // Wipe the tables touched by the tests, because the in-memory database of the class factory is shared between the tests of the class.
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+
+ await dbContext.SaveChangesAsync();
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Scheduling/GetScheduledJobs/GetScheduledJobsEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Scheduling/GetScheduledJobs/GetScheduledJobsEndpointTests.cs
new file mode 100644
index 00000000..b4956de0
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Scheduling/GetScheduledJobs/GetScheduledJobsEndpointTests.cs
@@ -0,0 +1,129 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Authorization;
+using Lumina.Application.Common.DataAccess.Entities.Scheduling;
+using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+using Lumina.Contracts.Requests.Scheduling;
+using Lumina.Contracts.Responses.Scheduling;
+using Lumina.DataAccess.Core.UoW;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using Lumina.Presentation.Api.IntegrationTests.Common.Setup;
+using Microsoft.AspNetCore.Http;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Json;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Api.IntegrationTests.Core.Endpoints.Scheduling.GetScheduledJobs;
+
+///
+/// Contains integration tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetScheduledJobsEndpointTests : IClassFixture, IAsyncLifetime
+{
+ private readonly AuthenticatedLuminaApiFactory _apiFactory;
+ private readonly JsonSerializerOptions _jsonOptions = new()
+ {
+ PropertyNameCaseInsensitive = true,
+ Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
+ };
+ private readonly AddScheduledJobRequestFixture _addScheduledJobRequestFixture = new();
+ private readonly List _createdScheduledJobIds = [];
+ private HttpClient _client;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected in-memory API factory.
+ public GetScheduledJobsEndpointTests(AuthenticatedLuminaApiFactory apiFactory)
+ {
+ _client = apiFactory.CreateClient();
+ _apiFactory = apiFactory;
+ }
+
+ ///
+ /// Initializes an authenticated admin API client.
+ ///
+ public async Task InitializeAsync()
+ {
+ _client = await _apiFactory.CreateAuthenticatedAdminClientAsync();
+ }
+
+ [Fact]
+ public async Task GetScheduledJobs_WhenScheduledJobsExist_ShouldReturnTheListOfScheduledJobs()
+ {
+ // Arrange
+ AddScheduledJobRequest addRequest = _addScheduledJobRequestFixture.Create(
+ name: $"Listed job {Guid.NewGuid()}",
+ scheduleType: ScheduleType.WithIntervalInMinutes,
+ intervalMinutes: 30);
+ HttpResponseMessage addResponse = await _client.PostAsJsonAsync("/api/v1/scheduled-jobs", addRequest);
+ string addContent = await addResponse.Content.ReadAsStringAsync();
+ ScheduledJobResponse? createdJob = JsonSerializer.Deserialize(addContent, _jsonOptions);
+ Assert.NotNull(createdJob);
+ _createdScheduledJobIds.Add(createdJob!.Id);
+
+ // Act
+ HttpResponseMessage response = await _client.GetAsync("/api/v1/scheduled-jobs");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ string content = await response.Content.ReadAsStringAsync();
+ List? result = JsonSerializer.Deserialize>(content, _jsonOptions);
+ Assert.NotNull(result);
+ Assert.Contains(result!, scheduledJob => scheduledJob.Id == createdJob.Id && scheduledJob.Name == addRequest.Name);
+ }
+
+ [Fact]
+ public async Task GetScheduledJobs_WhenCalledWithNonAdminAccount_ShouldReturnForbiddenResult()
+ {
+ // Arrange
+ _client = await _apiFactory.CreateAuthenticatedClientAsync();
+
+ // Act
+ HttpResponseMessage response = await _client.GetAsync("/api/v1/scheduled-jobs");
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
+ string content = await response.Content.ReadAsStringAsync();
+ Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions);
+ Assert.NotNull(problemDetails);
+ Assert.Equal(StatusCodes.Status403Forbidden, problemDetails!["status"].GetInt32());
+ Assert.Equal("General.Unauthorized", problemDetails["title"].GetString());
+ }
+
+ ///
+ /// Disposes API factory resources.
+ ///
+ public async Task DisposeAsync()
+ {
+ using IServiceScope scope = _apiFactory.Services.CreateScope();
+ LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
+
+ // Wipe the tables touched by the tests, because the in-memory database of the class factory is shared between the tests of the class.
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+
+ await dbContext.SaveChangesAsync();
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Scheduling/GetSchedulerDisplayPreferences/GetSchedulerDisplayPreferencesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Scheduling/GetSchedulerDisplayPreferences/GetSchedulerDisplayPreferencesEndpointTests.cs
new file mode 100644
index 00000000..1f7f7c18
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Scheduling/GetSchedulerDisplayPreferences/GetSchedulerDisplayPreferencesEndpointTests.cs
@@ -0,0 +1,110 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Authorization;
+using Lumina.Application.Common.DataAccess.Entities.Scheduling;
+using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Contracts.Responses.Scheduling;
+using Lumina.DataAccess.Core.UoW;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using Lumina.Presentation.Api.IntegrationTests.Common.Setup;
+using Microsoft.AspNetCore.Http;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Api.IntegrationTests.Core.Endpoints.Scheduling.GetSchedulerDisplayPreferences;
+
+///
+/// Contains integration tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetSchedulerDisplayPreferencesEndpointTests : IClassFixture, IAsyncLifetime
+{
+ private readonly AuthenticatedLuminaApiFactory _apiFactory;
+ private readonly JsonSerializerOptions _jsonOptions = new()
+ {
+ PropertyNameCaseInsensitive = true,
+ Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
+ };
+ private HttpClient _client;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected in-memory API factory.
+ public GetSchedulerDisplayPreferencesEndpointTests(AuthenticatedLuminaApiFactory apiFactory)
+ {
+ _client = apiFactory.CreateClient();
+ _apiFactory = apiFactory;
+ }
+
+ ///
+ /// Initializes an authenticated admin API client.
+ ///
+ public async Task InitializeAsync()
+ {
+ _client = await _apiFactory.CreateAuthenticatedAdminClientAsync();
+ }
+
+ [Fact]
+ public async Task GetSchedulerDisplayPreferences_WhenNoPreferencesStored_ShouldReturnTheDefaultPreferences()
+ {
+ // Act
+ HttpResponseMessage response = await _client.GetAsync("/api/v1/scheduled-jobs/display-preferences");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ string content = await response.Content.ReadAsStringAsync();
+ SchedulerDisplayPreferencesResponse? result = JsonSerializer.Deserialize(content, _jsonOptions);
+
+ Assert.NotNull(result);
+ Assert.Null(result!.JobTypeFilter);
+ Assert.Equal(10, result.DisplayTimeSpan);
+ Assert.Equal(SchedulerDisplayTimeUnit.Minutes, result.DisplayTimeUnit);
+ }
+
+ [Fact]
+ public async Task GetSchedulerDisplayPreferences_WhenCalledWithNonAdminAccount_ShouldReturnForbiddenResult()
+ {
+ // Arrange
+ _client = await _apiFactory.CreateAuthenticatedClientAsync();
+
+ // Act
+ HttpResponseMessage response = await _client.GetAsync("/api/v1/scheduled-jobs/display-preferences");
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
+ }
+
+ ///
+ /// Disposes API factory resources.
+ ///
+ public async Task DisposeAsync()
+ {
+ using IServiceScope scope = _apiFactory.Services.CreateScope();
+ LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
+
+ // Wipe the tables touched by the tests, because the in-memory database of the class factory is shared between the tests of the class.
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+
+ await dbContext.SaveChangesAsync();
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Scheduling/RemoveScheduledJob/RemoveScheduledJobEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Scheduling/RemoveScheduledJob/RemoveScheduledJobEndpointTests.cs
new file mode 100644
index 00000000..509a4bc7
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Scheduling/RemoveScheduledJob/RemoveScheduledJobEndpointTests.cs
@@ -0,0 +1,152 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Authorization;
+using Lumina.Application.Common.DataAccess.Entities.Scheduling;
+using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+using Lumina.Contracts.Requests.Scheduling;
+using Lumina.Contracts.Responses.Scheduling;
+using Lumina.DataAccess.Core.UoW;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using Lumina.Presentation.Api.IntegrationTests.Common.Setup;
+using Microsoft.AspNetCore.Http;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Json;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Api.IntegrationTests.Core.Endpoints.Scheduling.RemoveScheduledJob;
+
+///
+/// Contains integration tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class RemoveScheduledJobEndpointTests : IClassFixture, IAsyncLifetime
+{
+ private readonly AuthenticatedLuminaApiFactory _apiFactory;
+ private readonly JsonSerializerOptions _jsonOptions = new()
+ {
+ PropertyNameCaseInsensitive = true,
+ Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
+ };
+ private readonly AddScheduledJobRequestFixture _addScheduledJobRequestFixture = new();
+ private readonly List _createdScheduledJobIds = [];
+ private HttpClient _client;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected in-memory API factory.
+ public RemoveScheduledJobEndpointTests(AuthenticatedLuminaApiFactory apiFactory)
+ {
+ _client = apiFactory.CreateClient();
+ _apiFactory = apiFactory;
+ }
+
+ ///
+ /// Initializes an authenticated admin API client.
+ ///
+ public async Task InitializeAsync()
+ {
+ _client = await _apiFactory.CreateAuthenticatedAdminClientAsync();
+ }
+
+ [Fact]
+ public async Task RemoveScheduledJob_WhenScheduledJobExists_ShouldRemoveIt()
+ {
+ // Arrange
+ ScheduledJobResponse createdJob = await CreateScheduledJobAsync();
+
+ // Act
+ HttpResponseMessage response = await _client.DeleteAsync($"/api/v1/scheduled-jobs/{createdJob.Id}");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ using IServiceScope scope = _apiFactory.Services.CreateScope();
+ LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
+ Assert.Null(await dbContext.ScheduledJobs.FirstOrDefaultAsync(scheduledJob => scheduledJob.Id == createdJob.Id));
+ }
+
+ [Fact]
+ public async Task RemoveScheduledJob_WhenScheduledJobDoesNotExist_ShouldReturnNotFound()
+ {
+ // Arrange
+ Guid missingScheduledJobId = Guid.NewGuid();
+
+ // Act
+ HttpResponseMessage response = await _client.DeleteAsync($"/api/v1/scheduled-jobs/{missingScheduledJobId}");
+
+ // Assert
+ Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
+ string content = await response.Content.ReadAsStringAsync();
+ Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions);
+ Assert.NotNull(problemDetails);
+ Assert.Equal(StatusCodes.Status404NotFound, problemDetails!["status"].GetInt32());
+ Assert.Equal("ScheduledJobNotFound", problemDetails["detail"].GetString());
+ }
+
+ [Fact]
+ public async Task RemoveScheduledJob_WhenCalledWithNonAdminAccount_ShouldReturnForbiddenResult()
+ {
+ // Arrange
+ _client = await _apiFactory.CreateAuthenticatedClientAsync();
+ Guid scheduledJobId = Guid.NewGuid();
+
+ // Act
+ HttpResponseMessage response = await _client.DeleteAsync($"/api/v1/scheduled-jobs/{scheduledJobId}");
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
+ }
+
+ ///
+ /// Creates a scheduled job through the API and returns its response.
+ ///
+ /// The created scheduled job response.
+ private async Task CreateScheduledJobAsync()
+ {
+ AddScheduledJobRequest addRequest = _addScheduledJobRequestFixture.Create(
+ name: $"Removable job {Guid.NewGuid()}",
+ scheduleType: ScheduleType.WithIntervalInMinutes,
+ intervalMinutes: 60);
+ HttpResponseMessage addResponse = await _client.PostAsJsonAsync("/api/v1/scheduled-jobs", addRequest);
+ string addContent = await addResponse.Content.ReadAsStringAsync();
+ ScheduledJobResponse? createdJob = JsonSerializer.Deserialize(addContent, _jsonOptions);
+ Assert.NotNull(createdJob);
+ _createdScheduledJobIds.Add(createdJob!.Id);
+ return createdJob;
+ }
+
+ ///
+ /// Disposes API factory resources.
+ ///
+ public async Task DisposeAsync()
+ {
+ using IServiceScope scope = _apiFactory.Services.CreateScope();
+ LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
+
+ // Wipe the tables touched by the tests, because the in-memory database of the class factory is shared between the tests of the class.
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+
+ await dbContext.SaveChangesAsync();
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Scheduling/UpdateSchedulerDisplayPreferences/UpdateSchedulerDisplayPreferencesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Scheduling/UpdateSchedulerDisplayPreferences/UpdateSchedulerDisplayPreferencesEndpointTests.cs
new file mode 100644
index 00000000..43475a79
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Scheduling/UpdateSchedulerDisplayPreferences/UpdateSchedulerDisplayPreferencesEndpointTests.cs
@@ -0,0 +1,142 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Authorization;
+using Lumina.Application.Common.DataAccess.Entities.Scheduling;
+using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+using Lumina.Contracts.Requests.Scheduling;
+using Lumina.Contracts.Responses.Scheduling;
+using Lumina.DataAccess.Core.UoW;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using Lumina.Presentation.Api.IntegrationTests.Common.Setup;
+using Microsoft.AspNetCore.Http;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Json;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Api.IntegrationTests.Core.Endpoints.Scheduling.UpdateSchedulerDisplayPreferences;
+
+///
+/// Contains integration tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class UpdateSchedulerDisplayPreferencesEndpointTests : IClassFixture, IAsyncLifetime
+{
+ private readonly AuthenticatedLuminaApiFactory _apiFactory;
+ private readonly JsonSerializerOptions _jsonOptions = new()
+ {
+ PropertyNameCaseInsensitive = true,
+ Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
+ };
+ private readonly UpdateSchedulerDisplayPreferencesRequestFixture _updateSchedulerDisplayPreferencesRequestFixture = new();
+ private Guid? _createdPreferencesUserId;
+ private HttpClient _client;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected in-memory API factory.
+ public UpdateSchedulerDisplayPreferencesEndpointTests(AuthenticatedLuminaApiFactory apiFactory)
+ {
+ _client = apiFactory.CreateClient();
+ _apiFactory = apiFactory;
+ }
+
+ ///
+ /// Initializes an authenticated admin API client.
+ ///
+ public async Task InitializeAsync()
+ {
+ _client = await _apiFactory.CreateAuthenticatedAdminClientAsync();
+ }
+
+ [Fact]
+ public async Task UpdateSchedulerDisplayPreferences_WhenCalledWithValidRequest_ShouldPersistThePreferences()
+ {
+ // Arrange
+ UpdateSchedulerDisplayPreferencesRequest request = _updateSchedulerDisplayPreferencesRequestFixture.Create(
+ jobTypeFilter: ScheduledTaskType.ScanMediaLibraries,
+ displayTimeSpan: 30,
+ displayTimeUnit: SchedulerDisplayTimeUnit.Minutes);
+
+ // Act
+ HttpResponseMessage response = await _client.PutAsJsonAsync("/api/v1/scheduled-jobs/display-preferences", request);
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+
+ HttpResponseMessage getResponse = await _client.GetAsync("/api/v1/scheduled-jobs/display-preferences");
+ string content = await getResponse.Content.ReadAsStringAsync();
+ SchedulerDisplayPreferencesResponse? result = JsonSerializer.Deserialize(content, _jsonOptions);
+
+ Assert.NotNull(result);
+ Assert.Equal(ScheduledTaskType.ScanMediaLibraries, result!.JobTypeFilter);
+ Assert.Equal(30, result.DisplayTimeSpan);
+ Assert.Equal(SchedulerDisplayTimeUnit.Minutes, result.DisplayTimeUnit);
+ _createdPreferencesUserId = result.UserId;
+ }
+
+ [Fact]
+ public async Task UpdateSchedulerDisplayPreferences_WhenCalledWithNonPositiveTimeSpan_ShouldReturnValidationProblem()
+ {
+ // Arrange
+ UpdateSchedulerDisplayPreferencesRequest request = _updateSchedulerDisplayPreferencesRequestFixture.Create(displayTimeSpan: 0);
+
+ // Act
+ HttpResponseMessage response = await _client.PutAsJsonAsync("/api/v1/scheduled-jobs/display-preferences", request);
+
+ // Assert
+ Assert.Equal(HttpStatusCode.UnprocessableEntity, response.StatusCode);
+ string content = await response.Content.ReadAsStringAsync();
+ Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions);
+ Assert.NotNull(problemDetails);
+ Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemDetails!["status"].GetInt32());
+ Assert.Equal("General.Validation", problemDetails["title"].GetString());
+ }
+
+ [Fact]
+ public async Task UpdateSchedulerDisplayPreferences_WhenCalledWithNonAdminAccount_ShouldReturnForbiddenResult()
+ {
+ // Arrange
+ _client = await _apiFactory.CreateAuthenticatedClientAsync();
+ UpdateSchedulerDisplayPreferencesRequest request = _updateSchedulerDisplayPreferencesRequestFixture.Create();
+
+ // Act
+ HttpResponseMessage response = await _client.PutAsJsonAsync("/api/v1/scheduled-jobs/display-preferences", request);
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
+ }
+
+ ///
+ /// Disposes API factory resources.
+ ///
+ public async Task DisposeAsync()
+ {
+ using IServiceScope scope = _apiFactory.Services.CreateScope();
+ LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
+
+ // Wipe the tables touched by the tests, because the in-memory database of the class factory is shared between the tests of the class.
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+ await dbContext.Set().ExecuteDeleteAsync();
+
+ await dbContext.SaveChangesAsync();
+ }
+}
diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Scheduling/AddScheduledJob/AddScheduledJobEndpointTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Scheduling/AddScheduledJob/AddScheduledJobEndpointTests.cs
new file mode 100644
index 00000000..910ed7f2
--- /dev/null
+++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Scheduling/AddScheduledJob/AddScheduledJobEndpointTests.cs
@@ -0,0 +1,157 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Scheduling;
+using Lumina.DataAccess.Core.UoW;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using Lumina.Presentation.Api.SecurityTests.Common.Setup;
+using Microsoft.AspNetCore.Http;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Json;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Scheduling.AddScheduledJob;
+
+///
+/// Contains security tests for the /api/v1/scheduled-jobs route.
+///
+[ExcludeFromCodeCoverage]
+public class AddScheduledJobEndpointTests : IClassFixture, IAsyncDisposable
+{
+ private readonly HttpClient _client;
+ private readonly LuminaApiFactory _apiFactory;
+ private readonly JsonSerializerOptions _jsonOptions = new()
+ {
+ PropertyNameCaseInsensitive = true,
+ Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
+ };
+ private Guid _adminUserId;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected in-memory API factory.
+ public AddScheduledJobEndpointTests(LuminaApiFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ _client = apiFactory.CreateClient();
+ }
+
+ [Fact]
+ public async Task AddScheduledJob_WhenUnauthorized_ShouldReturnUnauthorizedResult()
+ {
+ // Arrange
+ object requestBody = new
+ {
+ Name = "Unauthorized job",
+ TaskType = ScheduledTaskType.ScanMediaLibraries,
+ ScheduleType = ScheduleType.WithIntervalInMinutes,
+ IntervalMinutes = 60
+ };
+
+ // Act
+ HttpResponseMessage response = await _client.PostAsJsonAsync("/api/v1/scheduled-jobs", requestBody);
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
+ string content = await response.Content.ReadAsStringAsync();
+ Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions);
+ Assert.NotNull(problemDetails);
+ Assert.Equal(StatusCodes.Status401Unauthorized, problemDetails!["status"].GetInt32());
+ Assert.Equal("Unauthorized", problemDetails["title"].GetString());
+ }
+
+ [Fact]
+ public async Task AddScheduledJob_WhenCalledWithNonAdminAccount_ShouldReturnForbiddenResult()
+ {
+ // Arrange
+ HttpClient client = _apiFactory.CreateClient();
+ await _apiFactory.CreateAndAuthenticateUserAsync(client);
+ object requestBody = new
+ {
+ Name = "Non admin job",
+ TaskType = ScheduledTaskType.ScanMediaLibraries,
+ ScheduleType = ScheduleType.WithIntervalInMinutes,
+ IntervalMinutes = 60
+ };
+
+ // Act
+ HttpResponseMessage response = await client.PostAsJsonAsync("/api/v1/scheduled-jobs", requestBody);
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
+ string content = await response.Content.ReadAsStringAsync();
+ Dictionary? problemDetails = JsonSerializer.Deserialize>(content, _jsonOptions);
+ Assert.NotNull(problemDetails);
+ Assert.Equal(StatusCodes.Status403Forbidden, problemDetails!["status"].GetInt32());
+ Assert.Equal("NotAuthorized", problemDetails["detail"].GetString());
+ }
+
+ [Theory]
+ [InlineData("'; DROP TABLE ScheduledJobs--")] // destructive injection
+ [InlineData("' OR '1'='1")] // boolean-based injection
+ [InlineData("")] // script injection
+ public async Task AddScheduledJob_WithMaliciousName_ShouldNotLeakDataOrExecuteInjection(string maliciousName)
+ {
+ // Arrange
+ HttpClient client = _apiFactory.CreateClient();
+ _adminUserId = await _apiFactory.CreateAndAuthenticateAdminUserAsync(client);
+ object requestBody = new
+ {
+ Name = maliciousName,
+ TaskType = ScheduledTaskType.ScanMediaLibraries,
+ ScheduleType = ScheduleType.WithIntervalInMinutes,
+ IntervalMinutes = 60
+ };
+
+ // Act
+ HttpResponseMessage response = await client.PostAsJsonAsync("/api/v1/scheduled-jobs", requestBody);
+
+ // Assert
+ string content = await response.Content.ReadAsStringAsync();
+ Assert.DoesNotContain("SqliteException", content, StringComparison.OrdinalIgnoreCase);
+ Assert.DoesNotContain("Exception", content, StringComparison.OrdinalIgnoreCase);
+ Assert.DoesNotContain("SQL", content, StringComparison.OrdinalIgnoreCase);
+ // The malicious name either reaches the parameterized insert verbatim or is rejected by validation; it never corrupts the storage medium.
+ Assert.True(response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.UnprocessableEntity);
+
+ if (response.StatusCode == HttpStatusCode.OK)
+ {
+ using IServiceScope scope = _apiFactory.Services.CreateScope();
+ LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
+ Assert.NotNull(await dbContext.ScheduledJobs.FirstOrDefaultAsync(scheduledJob => scheduledJob.Name == maliciousName));
+ }
+ }
+
+ ///
+ /// Disposes API factory resources.
+ ///
+ public async ValueTask DisposeAsync()
+ {
+ if (_adminUserId != Guid.Empty)
+ {
+ using IServiceScope scope = _apiFactory.Services.CreateScope();
+ LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
+
+ ScheduledJobEntity[] scheduledJobs = await dbContext.ScheduledJobs
+ .Where(scheduledJob => scheduledJob.OwnerUserId == _adminUserId)
+ .ToArrayAsync();
+ foreach (ScheduledJobEntity scheduledJob in scheduledJobs)
+ {
+ dbContext.ScheduledJobExecutions.RemoveRange(dbContext.ScheduledJobExecutions.Where(execution => execution.ScheduledJobId == scheduledJob.Id));
+ dbContext.ScheduledJobs.Remove(scheduledJob);
+ }
+ await dbContext.SaveChangesAsync();
+
+ await _apiFactory.RemoveAdminUserAsync(_adminUserId);
+ }
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/AddScheduledJobRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/AddScheduledJobRequestMappingTests.cs
new file mode 100644
index 00000000..4180f78b
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/AddScheduledJobRequestMappingTests.cs
@@ -0,0 +1,43 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Mapping.Scheduling;
+using Lumina.Application.Core.Scheduling.Commands.AddScheduledJob;
+using Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+using Lumina.Contracts.Requests.Scheduling;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Application.UnitTests.Common.Mapping.Scheduling;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class AddScheduledJobRequestMappingTests
+{
+ private readonly AddScheduledJobRequestFixture _requestFixture = new();
+
+ [Fact]
+ public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
+ {
+ // Arrange
+ AddScheduledJobRequest request = _requestFixture.Create(
+ name: "Scan at 6am",
+ taskType: ScheduledTaskType.ScanMediaLibraries,
+ scheduleType: ScheduleType.DailyAtHourAndMinute,
+ hour: 6,
+ minute: 0);
+
+ // Act
+ AddScheduledJobCommand result = request.ToCommand();
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(request.Name, result.Name);
+ Assert.Equal(request.TaskType, result.TaskType);
+ Assert.Equal(request.ScheduleType, result.ScheduleType);
+ Assert.Equal(request.IntervalMinutes, result.IntervalMinutes);
+ Assert.Equal(request.Hour, result.Hour);
+ Assert.Equal(request.Minute, result.Minute);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/FireScheduledJobRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/FireScheduledJobRequestMappingTests.cs
new file mode 100644
index 00000000..d8cda581
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/FireScheduledJobRequestMappingTests.cs
@@ -0,0 +1,34 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Mapping.Scheduling;
+using Lumina.Application.Core.Scheduling.Commands.FireScheduledJob;
+using Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+using Lumina.Contracts.Requests.Scheduling;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Application.UnitTests.Common.Mapping.Scheduling;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class FireScheduledJobRequestMappingTests
+{
+ private readonly FireScheduledJobRequestFixture _requestFixture = new();
+
+ [Fact]
+ public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
+ {
+ // Arrange
+ Guid scheduledJobId = Guid.NewGuid();
+ FireScheduledJobRequest request = _requestFixture.Create(scheduledJobId);
+
+ // Act
+ FireScheduledJobCommand result = request.ToCommand();
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(request.ScheduledJobId, result.ScheduledJobId);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/GetScheduledJobHistoryRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/GetScheduledJobHistoryRequestMappingTests.cs
new file mode 100644
index 00000000..f6be56d1
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/GetScheduledJobHistoryRequestMappingTests.cs
@@ -0,0 +1,36 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Mapping.Scheduling;
+using Lumina.Application.Core.Scheduling.Queries.GetScheduledJobHistory;
+using Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+using Lumina.Contracts.Requests.Scheduling;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Application.UnitTests.Common.Mapping.Scheduling;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetScheduledJobHistoryRequestMappingTests
+{
+ private readonly GetScheduledJobHistoryRequestFixture _requestFixture = new();
+
+ [Fact]
+ public void ToQuery_WhenMappingValidRequest_ShouldMapCorrectly()
+ {
+ // Arrange
+ DateTime from = new(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+ DateTime to = new(2026, 1, 2, 0, 0, 0, DateTimeKind.Utc);
+ GetScheduledJobHistoryRequest request = _requestFixture.Create(from, to);
+
+ // Act
+ GetScheduledJobHistoryQuery result = request.ToQuery();
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(request.From, result.From);
+ Assert.Equal(request.To, result.To);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/RemoveScheduledJobRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/RemoveScheduledJobRequestMappingTests.cs
new file mode 100644
index 00000000..1afa775e
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/RemoveScheduledJobRequestMappingTests.cs
@@ -0,0 +1,34 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Mapping.Scheduling;
+using Lumina.Application.Core.Scheduling.Commands.RemoveScheduledJob;
+using Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+using Lumina.Contracts.Requests.Scheduling;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Application.UnitTests.Common.Mapping.Scheduling;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class RemoveScheduledJobRequestMappingTests
+{
+ private readonly RemoveScheduledJobRequestFixture _requestFixture = new();
+
+ [Fact]
+ public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
+ {
+ // Arrange
+ Guid scheduledJobId = Guid.NewGuid();
+ RemoveScheduledJobRequest request = _requestFixture.Create(scheduledJobId);
+
+ // Act
+ RemoveScheduledJobCommand result = request.ToCommand();
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(request.ScheduledJobId, result.ScheduledJobId);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/ScheduledJobEntityMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/ScheduledJobEntityMappingTests.cs
new file mode 100644
index 00000000..1fa6a60b
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/ScheduledJobEntityMappingTests.cs
@@ -0,0 +1,169 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Scheduling;
+using Lumina.Application.Common.Mapping.Scheduling;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
+using Lumina.Contracts.Responses.Scheduling;
+using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.UnitTests.Common.Mapping.Scheduling;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobEntityMappingTests
+{
+ private readonly ScheduledJobEntityFixture _scheduledJobEntityFixture = new();
+
+ [Fact]
+ public void ToDomainEntity_WhenRepositoryEntityHasIntervalSchedule_ShouldMapToIntervalScheduledJob()
+ {
+ // Arrange
+ ScheduledJobEntity repositoryEntity = _scheduledJobEntityFixture.Create(
+ scheduleType: ScheduleType.WithIntervalInMinutes,
+ status: ScheduledJobStatus.Active);
+
+ // Act
+ Result result = repositoryEntity.ToDomainEntity();
+
+ // Assert
+ Assert.False(result.IsFailure);
+ Assert.Equal(repositoryEntity.Id, result.Value.Id.Value);
+ Assert.Equal(repositoryEntity.Name, result.Value.Name);
+ Assert.Equal(repositoryEntity.TaskType, result.Value.TaskType);
+ Assert.Equal(repositoryEntity.Status, result.Value.Status);
+ Assert.Equal(repositoryEntity.OwnerUserId, result.Value.OwnerUserId.Value);
+ IntervalSchedule intervalSchedule = Assert.IsType(result.Value.Schedule);
+ Assert.Equal(repositoryEntity.IntervalMinutes, intervalSchedule.IntervalMinutes);
+ if (repositoryEntity.LastStartedOnUtc is not null)
+ Assert.Equal(repositoryEntity.LastStartedOnUtc.Value, result.Value.LastStartedOnUtc.Value);
+ if (repositoryEntity.LastCompletedOnUtc is not null)
+ Assert.Equal(repositoryEntity.LastCompletedOnUtc.Value, result.Value.LastCompletedOnUtc.Value);
+ }
+
+ [Fact]
+ public void ToDomainEntity_WhenRepositoryEntityHasDailySchedule_ShouldMapToDailyScheduledJob()
+ {
+ // Arrange
+ ScheduledJobEntity repositoryEntity = _scheduledJobEntityFixture.Create(
+ scheduleType: ScheduleType.DailyAtHourAndMinute,
+ hour: 7,
+ minute: 15);
+
+ // Act
+ Result result = repositoryEntity.ToDomainEntity();
+
+ // Assert
+ Assert.False(result.IsFailure);
+ DailySchedule dailySchedule = Assert.IsType(result.Value.Schedule);
+ Assert.Equal(7, dailySchedule.Hour);
+ Assert.Equal(15, dailySchedule.Minute);
+ }
+
+ [Fact]
+ public void ToDomainEntity_WhenIntervalScheduleHasNonPositiveInterval_ShouldReturnError()
+ {
+ // Arrange
+ ScheduledJobEntity repositoryEntity = _scheduledJobEntityFixture.Create(
+ scheduleType: ScheduleType.WithIntervalInMinutes,
+ intervalMinutes: 0);
+
+ // Act
+ Result result = repositoryEntity.ToDomainEntity();
+
+ // Assert
+ Assert.True(result.IsFailure);
+ Assert.Equal(Lumina.Domain.Common.Errors.Errors.Scheduling.IntervalMinutesMustBePositive, result.FirstError);
+ }
+
+ [Fact]
+ public void ToDomainEntity_WhenDailyScheduleHasOutOfRangeHour_ShouldReturnError()
+ {
+ // Arrange
+ ScheduledJobEntity repositoryEntity = _scheduledJobEntityFixture.Create(
+ scheduleType: ScheduleType.DailyAtHourAndMinute,
+ hour: 30,
+ minute: 0);
+
+ // Act
+ Result result = repositoryEntity.ToDomainEntity();
+
+ // Assert
+ Assert.True(result.IsFailure);
+ }
+
+ [Fact]
+ public void ToDomainEntities_WhenCalledWithCollection_ShouldMapEveryRepositoryEntity()
+ {
+ // Arrange
+ List repositoryEntities =
+ [
+ _scheduledJobEntityFixture.Create(scheduleType: ScheduleType.WithIntervalInMinutes),
+ _scheduledJobEntityFixture.Create(scheduleType: ScheduleType.DailyAtHourAndMinute)
+ ];
+
+ // Act
+ List> results = repositoryEntities.ToDomainEntities().ToList();
+
+ // Assert
+ Assert.Equal(2, results.Count);
+ Assert.All(results, result => Assert.False(result.IsFailure));
+ }
+
+ [Fact]
+ public void ToResponse_WhenRepositoryEntityHasIntervalSchedule_ShouldMapToResponse()
+ {
+ // Arrange
+ ScheduledJobEntity repositoryEntity = _scheduledJobEntityFixture.Create(
+ id: Guid.NewGuid(),
+ scheduleType: ScheduleType.WithIntervalInMinutes,
+ intervalMinutes: 45,
+ status: ScheduledJobStatus.Active);
+
+ // Act
+ ScheduledJobResponse result = repositoryEntity.ToResponse();
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(repositoryEntity.Id, result.Id);
+ Assert.Equal(repositoryEntity.Name, result.Name);
+ Assert.Equal(repositoryEntity.TaskType, result.TaskType);
+ Assert.Equal(ScheduleType.WithIntervalInMinutes, result.ScheduleType);
+ Assert.Equal(45, result.IntervalMinutes);
+ Assert.Null(result.Hour);
+ Assert.Null(result.Minute);
+ Assert.Equal(ScheduledJobStatus.Active, result.Status);
+ Assert.Equal(repositoryEntity.LastStartedOnUtc, result.LastStartedOnUtc);
+ Assert.Equal(repositoryEntity.LastCompletedOnUtc, result.LastCompletedOnUtc);
+ }
+
+ [Fact]
+ public void ToResponse_WhenRepositoryEntityHasDailySchedule_ShouldMapToResponse()
+ {
+ // Arrange
+ ScheduledJobEntity repositoryEntity = _scheduledJobEntityFixture.Create(
+ id: Guid.NewGuid(),
+ scheduleType: ScheduleType.DailyAtHourAndMinute,
+ hour: 6,
+ minute: 30,
+ status: ScheduledJobStatus.Added);
+
+ // Act
+ ScheduledJobResponse result = repositoryEntity.ToResponse();
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(ScheduleType.DailyAtHourAndMinute, result.ScheduleType);
+ Assert.Null(result.IntervalMinutes);
+ Assert.Equal(6, result.Hour);
+ Assert.Equal(30, result.Minute);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/ScheduledJobExecutionEntityMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/ScheduledJobExecutionEntityMappingTests.cs
new file mode 100644
index 00000000..a165bce5
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/ScheduledJobExecutionEntityMappingTests.cs
@@ -0,0 +1,62 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Scheduling;
+using Lumina.Application.Common.Mapping.Scheduling;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
+using Lumina.Contracts.Responses.Scheduling;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Application.UnitTests.Common.Mapping.Scheduling;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobExecutionEntityMappingTests
+{
+ private readonly ScheduledJobExecutionEntityFixture _scheduledJobExecutionEntityFixture = new();
+
+ [Fact]
+ public void ToResponse_WhenRepositoryEntityIsCompleted_ShouldMapToResponse()
+ {
+ // Arrange
+ DateTime startedOnUtc = DateTime.UtcNow.AddMinutes(-10);
+ DateTime completedOnUtc = DateTime.UtcNow;
+ ScheduledJobExecutionEntity repositoryEntity = _scheduledJobExecutionEntityFixture.Create(
+ scheduledJobId: Guid.NewGuid(),
+ isCycleRun: true,
+ startedOnUtc: startedOnUtc,
+ completedOnUtc: completedOnUtc);
+
+ // Act
+ ScheduledJobExecutionResponse result = repositoryEntity.ToResponse();
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(repositoryEntity.Id, result.Id);
+ Assert.Equal(repositoryEntity.ScheduledJobId, result.ScheduledJobId);
+ Assert.Equal(repositoryEntity.TaskType, result.TaskType);
+ Assert.True(result.IsCycleRun);
+ Assert.Equal(startedOnUtc, result.StartedOnUtc);
+ Assert.Equal(completedOnUtc, result.CompletedOnUtc);
+ }
+
+ [Fact]
+ public void ToResponse_WhenRepositoryEntityIsStillRunning_ShouldMapToResponseWithNullCompletionTime()
+ {
+ // Arrange
+ ScheduledJobExecutionEntity repositoryEntity = _scheduledJobExecutionEntityFixture.Create(
+ isCycleRun: false,
+ completedOnUtc: null);
+
+ // Act
+ ScheduledJobExecutionResponse result = repositoryEntity.ToResponse();
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(repositoryEntity.Id, result.Id);
+ Assert.False(result.IsCycleRun);
+ Assert.Null(result.CompletedOnUtc);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/ScheduledJobMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/ScheduledJobMappingTests.cs
new file mode 100644
index 00000000..67abb195
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/ScheduledJobMappingTests.cs
@@ -0,0 +1,117 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Scheduling;
+using Lumina.Application.Common.Mapping.Scheduling;
+using Lumina.Contracts.Responses.Scheduling;
+using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate;
+using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Application.UnitTests.Common.Mapping.Scheduling;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class ScheduledJobMappingTests
+{
+ private readonly ScheduledJobFixture _scheduledJobFixture = new();
+
+ [Fact]
+ public void ToRepositoryEntity_WhenDomainEntityHasIntervalSchedule_ShouldMapToRepositoryEntity()
+ {
+ // Arrange
+ Guid ownerUserId = Guid.NewGuid();
+ Result intervalScheduleResult = IntervalSchedule.Create(30);
+ ScheduledJob domainEntity = _scheduledJobFixture.Create(
+ name: "Interval job",
+ taskType: ScheduledTaskType.ScanMediaLibraries,
+ schedule: intervalScheduleResult.Value,
+ ownerUserId: ownerUserId);
+
+ // Act
+ ScheduledJobEntity result = domainEntity.ToRepositoryEntity();
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(domainEntity.Id.Value, result.Id);
+ Assert.Equal(domainEntity.Name, result.Name);
+ Assert.Equal(domainEntity.TaskType, result.TaskType);
+ Assert.Equal(ScheduleType.WithIntervalInMinutes, result.ScheduleType);
+ Assert.Equal(30, result.IntervalMinutes);
+ Assert.Null(result.Hour);
+ Assert.Null(result.Minute);
+ Assert.Equal(domainEntity.Status, result.Status);
+ Assert.Equal(ownerUserId, result.OwnerUserId);
+ Assert.False(result.LastStartedOnUtc.HasValue);
+ Assert.False(result.LastCompletedOnUtc.HasValue);
+ }
+
+ [Fact]
+ public void ToRepositoryEntity_WhenDomainEntityHasDailySchedule_ShouldMapToRepositoryEntity()
+ {
+ // Arrange
+ Result dailyScheduleResult = DailySchedule.Create(9, 45);
+ ScheduledJob domainEntity = _scheduledJobFixture.Create(
+ name: "Daily job",
+ taskType: ScheduledTaskType.CleanTemporaryFiles,
+ schedule: dailyScheduleResult.Value);
+
+ // Act
+ ScheduledJobEntity result = domainEntity.ToRepositoryEntity();
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(ScheduleType.DailyAtHourAndMinute, result.ScheduleType);
+ Assert.Null(result.IntervalMinutes);
+ Assert.Equal(9, result.Hour);
+ Assert.Equal(45, result.Minute);
+ }
+
+ [Fact]
+ public void ToResponse_WhenDomainEntityHasIntervalSchedule_ShouldMapToResponse()
+ {
+ // Arrange
+ Result intervalScheduleResult = IntervalSchedule.Create(120);
+ ScheduledJob domainEntity = _scheduledJobFixture.Create(
+ name: "Interval job",
+ schedule: intervalScheduleResult.Value);
+
+ // Act
+ ScheduledJobResponse result = domainEntity.ToResponse();
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(domainEntity.Id.Value, result.Id);
+ Assert.Equal(domainEntity.Name, result.Name);
+ Assert.Equal(ScheduleType.WithIntervalInMinutes, result.ScheduleType);
+ Assert.Equal(120, result.IntervalMinutes);
+ Assert.Null(result.Hour);
+ Assert.Null(result.Minute);
+ Assert.Equal(domainEntity.Status, result.Status);
+ }
+
+ [Fact]
+ public void ToResponse_WhenDomainEntityHasDailySchedule_ShouldMapToResponse()
+ {
+ // Arrange
+ Result dailyScheduleResult = DailySchedule.Create(5, 0);
+ ScheduledJob domainEntity = _scheduledJobFixture.Create(
+ name: "Daily job",
+ schedule: dailyScheduleResult.Value);
+
+ // Act
+ ScheduledJobResponse result = domainEntity.ToResponse();
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(ScheduleType.DailyAtHourAndMinute, result.ScheduleType);
+ Assert.Null(result.IntervalMinutes);
+ Assert.Equal(5, result.Hour);
+ Assert.Equal(0, result.Minute);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/SchedulerDisplayPreferencesEntityMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/SchedulerDisplayPreferencesEntityMappingTests.cs
new file mode 100644
index 00000000..4bdd2563
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/SchedulerDisplayPreferencesEntityMappingTests.cs
@@ -0,0 +1,59 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Scheduling;
+using Lumina.Application.Common.Mapping.Scheduling;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.Scheduling;
+using Lumina.Contracts.Responses.Scheduling;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Application.UnitTests.Common.Mapping.Scheduling;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class SchedulerDisplayPreferencesEntityMappingTests
+{
+ private readonly SchedulerDisplayPreferencesEntityFixture _schedulerDisplayPreferencesEntityFixture = new();
+
+ [Fact]
+ public void ToResponse_WhenRepositoryEntityExists_ShouldMapToResponse()
+ {
+ // Arrange
+ Guid userId = Guid.NewGuid();
+ SchedulerDisplayPreferencesEntity repositoryEntity = _schedulerDisplayPreferencesEntityFixture.Create(
+ userId: userId,
+ jobTypeFilter: ScheduledTaskType.CleanTemporaryFiles,
+ displayTimeSpan: 30,
+ displayTimeUnit: SchedulerDisplayTimeUnit.Minutes);
+
+ // Act
+ SchedulerDisplayPreferencesResponse result = repositoryEntity.ToResponse();
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(userId, result.UserId);
+ Assert.Equal(ScheduledTaskType.CleanTemporaryFiles, result.JobTypeFilter);
+ Assert.Equal(30, result.DisplayTimeSpan);
+ Assert.Equal(SchedulerDisplayTimeUnit.Minutes, result.DisplayTimeUnit);
+ }
+
+ [Fact]
+ public void ToDefaultResponse_WhenRepositoryEntityIsNull_ShouldReturnDefaultResponseForTheUser()
+ {
+ // Arrange
+ Guid userId = Guid.NewGuid();
+
+ // Act
+ SchedulerDisplayPreferencesResponse result = ((SchedulerDisplayPreferencesEntity?)null).ToDefaultResponse(userId);
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(userId, result.UserId);
+ Assert.Null(result.JobTypeFilter);
+ Assert.Equal(10, result.DisplayTimeSpan);
+ Assert.Equal(SchedulerDisplayTimeUnit.Minutes, result.DisplayTimeUnit);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/StartScheduledJobRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/StartScheduledJobRequestMappingTests.cs
new file mode 100644
index 00000000..374c6a6b
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/StartScheduledJobRequestMappingTests.cs
@@ -0,0 +1,34 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Mapping.Scheduling;
+using Lumina.Application.Core.Scheduling.Commands.StartScheduledJob;
+using Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+using Lumina.Contracts.Requests.Scheduling;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Application.UnitTests.Common.Mapping.Scheduling;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class StartScheduledJobRequestMappingTests
+{
+ private readonly StartScheduledJobRequestFixture _requestFixture = new();
+
+ [Fact]
+ public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
+ {
+ // Arrange
+ Guid scheduledJobId = Guid.NewGuid();
+ StartScheduledJobRequest request = _requestFixture.Create(scheduledJobId);
+
+ // Act
+ StartScheduledJobCommand result = request.ToCommand();
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(request.ScheduledJobId, result.ScheduledJobId);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/StopScheduledJobRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/StopScheduledJobRequestMappingTests.cs
new file mode 100644
index 00000000..d67d254f
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/StopScheduledJobRequestMappingTests.cs
@@ -0,0 +1,34 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Mapping.Scheduling;
+using Lumina.Application.Core.Scheduling.Commands.StopScheduledJob;
+using Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+using Lumina.Contracts.Requests.Scheduling;
+using System;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Application.UnitTests.Common.Mapping.Scheduling;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class StopScheduledJobRequestMappingTests
+{
+ private readonly StopScheduledJobRequestFixture _requestFixture = new();
+
+ [Fact]
+ public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
+ {
+ // Arrange
+ Guid scheduledJobId = Guid.NewGuid();
+ StopScheduledJobRequest request = _requestFixture.Create(scheduledJobId);
+
+ // Act
+ StopScheduledJobCommand result = request.ToCommand();
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(request.ScheduledJobId, result.ScheduledJobId);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/UpdateSchedulerDisplayPreferencesRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/UpdateSchedulerDisplayPreferencesRequestMappingTests.cs
new file mode 100644
index 00000000..3b09a096
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Scheduling/UpdateSchedulerDisplayPreferencesRequestMappingTests.cs
@@ -0,0 +1,38 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Mapping.Scheduling;
+using Lumina.Application.Core.Scheduling.Commands.UpdateSchedulerDisplayPreferences;
+using Lumina.Contracts.Fixtures.Core.Requests.Scheduling;
+using Lumina.Contracts.Requests.Scheduling;
+using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Application.UnitTests.Common.Mapping.Scheduling;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class UpdateSchedulerDisplayPreferencesRequestMappingTests
+{
+ private readonly UpdateSchedulerDisplayPreferencesRequestFixture _requestFixture = new();
+
+ [Fact]
+ public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
+ {
+ // Arrange
+ UpdateSchedulerDisplayPreferencesRequest request = _requestFixture.Create(
+ jobTypeFilter: ScheduledTaskType.CleanTemporaryFiles,
+ displayTimeSpan: 15,
+ displayTimeUnit: SchedulerDisplayTimeUnit.Hours);
+
+ // Act
+ UpdateSchedulerDisplayPreferencesCommand result = request.ToCommand();
+
+ // Assert
+ Assert.NotNull(result);
+ Assert.Equal(request.JobTypeFilter, result.JobTypeFilter);
+ Assert.Equal(request.DisplayTimeSpan, result.DisplayTimeSpan);
+ Assert.Equal(request.DisplayTimeUnit, result.DisplayTimeUnit);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryDeletedDomainEventHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryDeletedDomainEventHandlerTests.cs
index 93451f92..293a41b1 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryDeletedDomainEventHandlerTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryDeletedDomainEventHandlerTests.cs
@@ -10,6 +10,7 @@ using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.File
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
using Microsoft.Extensions.Options;
using NSubstitute;
using System;
@@ -31,6 +32,7 @@ public class LibraryDeletedDomainEventHandlerTests
private readonly IPathService _mockPathService;
private readonly LibraryDeletedDomainEventHandler _sut;
private readonly LibraryFixture _libraryFixture = new();
+ private readonly LibraryDeletedDomainEventFixture _libraryDeletedDomainEventFixture = new();
private readonly MediaSettingsDtoFixture _mediaSettingsDtoFixture = new();
///
@@ -64,7 +66,7 @@ public class LibraryDeletedDomainEventHandlerTests
// Arrange
Guid libraryId = Guid.NewGuid();
Library library = _libraryFixture.Create(id: libraryId);
- LibraryDeletedDomainEvent domainEvent = new(Guid.NewGuid(), library, DateTime.UtcNow);
+ LibraryDeletedDomainEvent domainEvent = _libraryDeletedDomainEventFixture.Create(library: library);
// Act
await _sut.HandleAsync(domainEvent, CancellationToken.None);
@@ -80,7 +82,7 @@ public class LibraryDeletedDomainEventHandlerTests
// Arrange
Guid libraryId = Guid.NewGuid();
Library library = _libraryFixture.Create(id: libraryId);
- LibraryDeletedDomainEvent domainEvent = new(Guid.NewGuid(), library, DateTime.UtcNow);
+ LibraryDeletedDomainEvent domainEvent = _libraryDeletedDomainEventFixture.Create(library: library);
Error error = Error.Failure(description: "Failed to delete library directory");
_mockDirectoryProviderService.DeleteDirectory(Arg.Any()).Returns(error);
@@ -98,7 +100,7 @@ public class LibraryDeletedDomainEventHandlerTests
// Arrange
Guid libraryId = Guid.NewGuid();
Library library = _libraryFixture.Create(id: libraryId);
- LibraryDeletedDomainEvent domainEvent = new(Guid.NewGuid(), library, DateTime.UtcNow);
+ LibraryDeletedDomainEvent domainEvent = _libraryDeletedDomainEventFixture.Create(library: library);
Error error = Error.Failure(description: "Failed to combine path");
_mockPathService.CombinePath(Arg.Any(), Arg.Any()).Returns(error);
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryMediaItemDeletedDomainEventHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryMediaItemDeletedDomainEventHandlerTests.cs
index f0d866f7..aec3802f 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryMediaItemDeletedDomainEventHandlerTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryMediaItemDeletedDomainEventHandlerTests.cs
@@ -12,10 +12,8 @@ using Lumina.Domain.Common.Exceptions;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
-using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
-using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
-using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Microsoft.Extensions.Logging;
using NSubstitute;
using System;
@@ -40,10 +38,9 @@ public class LibraryMediaItemDeletedDomainEventHandlerTests
private readonly ILogger _mockLogger;
private readonly LibraryMediaItemDeletedDomainEventHandler _sut;
private readonly LibraryIdFixture _libraryIdFixture = new();
- private readonly ScanIdFixture _scanIdFixture = new();
- private readonly UserIdFixture _userIdFixture = new();
private readonly BookEntityFixture _bookEntityFixture = new();
private readonly LibraryEntityFixture _libraryEntityFixture = new();
+ private readonly LibraryMediaItemDeletedDomainEventFixture _libraryMediaItemDeletedDomainEventFixture = new();
///
/// Initializes a new instance of the class.
@@ -81,12 +78,7 @@ public class LibraryMediaItemDeletedDomainEventHandlerTests
.Returns(Result.Deleted);
_mockUnitOfWork.SaveChangesAsync(Arg.Any()).Returns(Task.CompletedTask);
- LibraryMediaItemDeletedDomainEvent domainEvent = new(
- Guid.NewGuid(),
- libraryId,
- MediaLibraryScanCompositeId.Create(_scanIdFixture.Create(), _userIdFixture.Create()),
- book.Path,
- DateTime.UtcNow);
+ LibraryMediaItemDeletedDomainEvent domainEvent = _libraryMediaItemDeletedDomainEventFixture.Create(libraryId: libraryId, path: book.Path);
// Act
await _sut.HandleAsync(domainEvent, CancellationToken.None);
@@ -105,12 +97,7 @@ public class LibraryMediaItemDeletedDomainEventHandlerTests
_mockBookRepository.GetByPathAsync(libraryId.Value, "/books/deleted.epub", Arg.Any())
.Returns(Result.From(null));
- LibraryMediaItemDeletedDomainEvent domainEvent = new(
- Guid.NewGuid(),
- libraryId,
- MediaLibraryScanCompositeId.Create(_scanIdFixture.Create(), _userIdFixture.Create()),
- "/books/deleted.epub",
- DateTime.UtcNow);
+ LibraryMediaItemDeletedDomainEvent domainEvent = _libraryMediaItemDeletedDomainEventFixture.Create(libraryId: libraryId, path: "/books/deleted.epub");
// Act
await _sut.HandleAsync(domainEvent, CancellationToken.None);
@@ -140,12 +127,7 @@ public class LibraryMediaItemDeletedDomainEventHandlerTests
.Returns(Result.From(Result.Deleted));
_mockUnitOfWork.SaveChangesAsync(Arg.Any()).Returns(Task.CompletedTask);
- LibraryMediaItemDeletedDomainEvent domainEvent = new(
- Guid.NewGuid(),
- libraryId,
- MediaLibraryScanCompositeId.Create(_scanIdFixture.Create(), _userIdFixture.Create()),
- book.Path,
- DateTime.UtcNow);
+ LibraryMediaItemDeletedDomainEvent domainEvent = _libraryMediaItemDeletedDomainEventFixture.Create(libraryId: libraryId, path: book.Path);
// Act
await _sut.HandleAsync(domainEvent, CancellationToken.None);
@@ -165,12 +147,7 @@ public class LibraryMediaItemDeletedDomainEventHandlerTests
_mockBookRepository.GetByPathAsync(libraryId.Value, "/books/deleted.epub", Arg.Any())
.Returns(error);
- LibraryMediaItemDeletedDomainEvent domainEvent = new(
- Guid.NewGuid(),
- libraryId,
- MediaLibraryScanCompositeId.Create(_scanIdFixture.Create(), _userIdFixture.Create()),
- "/books/deleted.epub",
- DateTime.UtcNow);
+ LibraryMediaItemDeletedDomainEvent domainEvent = _libraryMediaItemDeletedDomainEventFixture.Create(libraryId: libraryId, path: "/books/deleted.epub");
// Act
EventualConsistencyException exception = await Assert.ThrowsAsync(
@@ -200,12 +177,7 @@ public class LibraryMediaItemDeletedDomainEventHandlerTests
_mockBookRepository.DeleteAsync(book.Id, Arg.Any())
.Returns(error);
- LibraryMediaItemDeletedDomainEvent domainEvent = new(
- Guid.NewGuid(),
- libraryId,
- MediaLibraryScanCompositeId.Create(_scanIdFixture.Create(), _userIdFixture.Create()),
- book.Path,
- DateTime.UtcNow);
+ LibraryMediaItemDeletedDomainEvent domainEvent = _libraryMediaItemDeletedDomainEventFixture.Create(libraryId: libraryId, path: book.Path);
// Act
EventualConsistencyException exception = await Assert.ThrowsAsync(
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibrarySavedDomainEventHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibrarySavedDomainEventHandlerTests.cs
index 267c59ec..b156d8c5 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibrarySavedDomainEventHandlerTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibrarySavedDomainEventHandlerTests.cs
@@ -15,6 +15,7 @@ using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Library
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
using Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
using Microsoft.Extensions.Options;
using NSubstitute;
@@ -43,6 +44,7 @@ public class LibrarySavedDomainEventHandlerTests
private readonly IPathService _mockPathService;
private readonly LibrarySavedDomainEventHandler _sut;
private readonly LibraryFixture _libraryFixture = new();
+ private readonly LibrarySavedDomainEventFixture _librarySavedDomainEventFixture = new();
private readonly LibraryEntityFixture _libraryEntityFixture = new();
private readonly FileSystemPathIdFixture _fileSystemPathIdFixture = new();
private readonly MediaSettingsDtoFixture _mediaSettingsDtoFixture = new();
@@ -97,14 +99,14 @@ public class LibrarySavedDomainEventHandlerTests
// Arrange
Guid libraryId = Guid.NewGuid();
Library library = _libraryFixture.Create(id: libraryId, coverImage: "C:/Users/user/cover.jpg");
- LibrarySavedDomainEvent domainEvent = new(Guid.NewGuid(), library, DateTime.UtcNow);
+ LibrarySavedDomainEvent domainEvent = _librarySavedDomainEventFixture.Create(library: library);
LibraryEntity updatedLibrary = _libraryEntityFixture.Create(id: libraryId);
// Act
await _sut.HandleAsync(domainEvent, CancellationToken.None);
// Assert
- Assert.NotNull(library.CoverImage);
+ Assert.NotNull(domainEvent.Library.CoverImage);
await _mockLibraryRepository.Received(1).UpdateAsync(Arg.Any(), Arg.Any());
await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any());
}
@@ -115,7 +117,7 @@ public class LibrarySavedDomainEventHandlerTests
// Arrange
Guid libraryId = Guid.NewGuid();
Library library = _libraryFixture.Create(id: libraryId, coverImage: "C:/Users/user/cover.jpg");
- LibrarySavedDomainEvent domainEvent = new(Guid.NewGuid(), library, DateTime.UtcNow);
+ LibrarySavedDomainEvent domainEvent = _librarySavedDomainEventFixture.Create(library: library);
_mockDirectoryProviderService.DirectoryExists(Arg.Any()).Returns(Result.From(true));
_mockFileProviderService.GetFilePaths(Arg.Any(), true)
.Returns(Result.From>(
@@ -140,7 +142,7 @@ public class LibrarySavedDomainEventHandlerTests
// Arrange
Guid libraryId = Guid.NewGuid();
Library library = _libraryFixture.Create(id: libraryId, includeCoverImage: false);
- LibrarySavedDomainEvent domainEvent = new(Guid.NewGuid(), library, DateTime.UtcNow);
+ LibrarySavedDomainEvent domainEvent = _librarySavedDomainEventFixture.Create(library: library);
_mockFileProviderService.GetFilePaths(Arg.Any(), true)
.Returns(Result.From>(
[
@@ -162,7 +164,7 @@ public class LibrarySavedDomainEventHandlerTests
// Arrange
Guid libraryId = Guid.NewGuid();
Library library = _libraryFixture.Create(id: libraryId, coverImage: "/Media/Libraries/guid/cover.png");
- LibrarySavedDomainEvent domainEvent = new(Guid.NewGuid(), library, DateTime.UtcNow);
+ LibrarySavedDomainEvent domainEvent = _librarySavedDomainEventFixture.Create(library: library);
// mirror the real CombinePath behavior, which treats the combined name as a directory segment and appends a trailing
// separator; the internal cover path resolution must still yield the file path without that trailing separator
_mockPathService.CombinePath(Arg.Any(), Arg.Any())
@@ -175,7 +177,7 @@ public class LibrarySavedDomainEventHandlerTests
await _sut.HandleAsync(domainEvent, CancellationToken.None);
// Assert
- Assert.Equal("/Media/Libraries/guid/cover.png", library.CoverImage);
+ Assert.Equal("/Media/Libraries/guid/cover.png", domainEvent.Library.CoverImage);
_mockFileProviderService.DidNotReceive().CopyFile(Arg.Any(), Arg.Any(), Arg.Any());
await _mockLibraryRepository.Received(1).UpdateAsync(Arg.Any(), Arg.Any());
}
@@ -186,7 +188,7 @@ public class LibrarySavedDomainEventHandlerTests
// Arrange
Guid libraryId = Guid.NewGuid();
Library library = _libraryFixture.Create(id: libraryId, coverImage: "C:/Users/user/cover.jpg");
- LibrarySavedDomainEvent domainEvent = new(Guid.NewGuid(), library, DateTime.UtcNow);
+ LibrarySavedDomainEvent domainEvent = _librarySavedDomainEventFixture.Create(library: library);
_mockFileProviderService.FileExists(Arg.Any()).Returns(Result.From(false));
// Act
@@ -204,7 +206,7 @@ public class LibrarySavedDomainEventHandlerTests
// Arrange
Guid libraryId = Guid.NewGuid();
Library library = _libraryFixture.Create(id: libraryId, coverImage: "C:/Users/user/cover.jpg");
- LibrarySavedDomainEvent domainEvent = new(Guid.NewGuid(), library, DateTime.UtcNow);
+ LibrarySavedDomainEvent domainEvent = _librarySavedDomainEventFixture.Create(library: library);
_mockFileTypeService.GetImageTypeAsync(Arg.Any(), Arg.Any())
.Returns(Result.From(ImageType.None));
@@ -223,7 +225,7 @@ public class LibrarySavedDomainEventHandlerTests
// Arrange
Guid libraryId = Guid.NewGuid();
Library library = _libraryFixture.Create(id: libraryId, coverImage: "C:/Users/user/cover.jpg");
- LibrarySavedDomainEvent domainEvent = new(Guid.NewGuid(), library, DateTime.UtcNow);
+ LibrarySavedDomainEvent domainEvent = _librarySavedDomainEventFixture.Create(library: library);
Error error = Error.Failure(description: "Failed to copy cover file");
_mockFileProviderService.CopyFile(Arg.Any(), Arg.Any(), true)
.Returns(error);
@@ -243,7 +245,7 @@ public class LibrarySavedDomainEventHandlerTests
// Arrange
Guid libraryId = Guid.NewGuid();
Library library = _libraryFixture.Create(id: libraryId, includeCoverImage: false);
- LibrarySavedDomainEvent domainEvent = new(Guid.NewGuid(), library, DateTime.UtcNow);
+ LibrarySavedDomainEvent domainEvent = _librarySavedDomainEventFixture.Create(library: library);
Error error = Error.Failure(description: "Failed to combine path");
_mockPathService.CombinePath(Arg.Any(), Arg.Any()).Returns(error);
@@ -262,7 +264,7 @@ public class LibrarySavedDomainEventHandlerTests
// Arrange
Guid libraryId = Guid.NewGuid();
Library library = _libraryFixture.Create(id: libraryId, coverImage: "C:/Users/user/cover.jpg");
- LibrarySavedDomainEvent domainEvent = new(Guid.NewGuid(), library, DateTime.UtcNow);
+ LibrarySavedDomainEvent domainEvent = _librarySavedDomainEventFixture.Create(library: library);
Error error = Error.Failure(description: "Failed to update library");
_mockLibraryRepository.UpdateAsync(Arg.Any(), Arg.Any())
.Returns(error);
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanCancelledDomainEventHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanCancelledDomainEventHandlerTests.cs
index 8833f45b..0930c15e 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanCancelledDomainEventHandlerTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanCancelledDomainEventHandlerTests.cs
@@ -12,8 +12,7 @@ using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Library
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Cancellation;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
-using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
-using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using DomainErrors = Lumina.Domain.Common.Errors.Errors;
using NSubstitute;
using System;
@@ -39,8 +38,7 @@ public class LibraryScanCancelledDomainEventHandlerTests
private readonly IMediaLibrariesScanCancellationTracker _mockMediaLibrariesScanCancellationTracker;
private readonly LibraryScanCancelledDomainEventHandler _sut;
private readonly LibraryScanEntityFixture _libraryScanEntityFixture = new();
- private readonly ScanIdFixture _scanIdFixture = new();
- private readonly LibraryIdFixture _libraryIdFixture = new();
+ private readonly LibraryScanCancelledDomainEventFixture _libraryScanCancelledDomainEventFixture = new();
///
/// Initializes a new instance of the class.
@@ -68,8 +66,10 @@ public class LibraryScanCancelledDomainEventHandlerTests
public async Task HandleAsync_WhenScanExists_ShouldCancelScanAndCleanupResources()
{
// Arrange
- LibraryScanEntity scan = _libraryScanEntityFixture.Create();
- LibraryScanCancelledDomainEvent domainEvent = new(Guid.NewGuid(), _scanIdFixture.Create(value: scan.Id), _libraryIdFixture.Create(value: scan.LibraryId), DateTime.UtcNow);
+ LibraryScanCancelledDomainEvent domainEvent = _libraryScanCancelledDomainEventFixture.Create();
+ LibraryScanEntity scan = _libraryScanEntityFixture.Create(
+ id: domainEvent.ScanId.Value,
+ libraryId: domainEvent.LibraryId.Value);
_mockLibraryScanRepository.GetByIdAsync(scan.Id, Arg.Any())
.Returns(Result.From(scan));
@@ -87,7 +87,7 @@ public class LibraryScanCancelledDomainEventHandlerTests
public async Task HandleAsync_WhenGetByIdFails_ShouldThrowEventualConsistencyException()
{
// Arrange
- LibraryScanCancelledDomainEvent domainEvent = new(Guid.NewGuid(), _scanIdFixture.Create(), _libraryIdFixture.Create(), DateTime.UtcNow);
+ LibraryScanCancelledDomainEvent domainEvent = _libraryScanCancelledDomainEventFixture.Create();
Error error = Error.Failure(description: "Failed to get library scan");
_mockLibraryScanRepository.GetByIdAsync(Arg.Any(), Arg.Any())
.Returns(error);
@@ -105,7 +105,7 @@ public class LibraryScanCancelledDomainEventHandlerTests
public async Task HandleAsync_WhenScanDoesNotExist_ShouldThrowEventualConsistencyExceptionWithNotFoundError()
{
// Arrange
- LibraryScanCancelledDomainEvent domainEvent = new(Guid.NewGuid(), _scanIdFixture.Create(), _libraryIdFixture.Create(), DateTime.UtcNow);
+ LibraryScanCancelledDomainEvent domainEvent = _libraryScanCancelledDomainEventFixture.Create();
_mockLibraryScanRepository.GetByIdAsync(Arg.Any(), Arg.Any())
.Returns(Result.Success(null));
@@ -122,8 +122,10 @@ public class LibraryScanCancelledDomainEventHandlerTests
public async Task HandleAsync_WhenCancelScanFails_ShouldThrowEventualConsistencyException()
{
// Arrange
- LibraryScanEntity scan = _libraryScanEntityFixture.Create();
- LibraryScanCancelledDomainEvent domainEvent = new(Guid.NewGuid(), _scanIdFixture.Create(value: scan.Id), _libraryIdFixture.Create(value: scan.LibraryId), DateTime.UtcNow);
+ LibraryScanCancelledDomainEvent domainEvent = _libraryScanCancelledDomainEventFixture.Create();
+ LibraryScanEntity scan = _libraryScanEntityFixture.Create(
+ id: domainEvent.ScanId.Value,
+ libraryId: domainEvent.LibraryId.Value);
_mockLibraryScanRepository.GetByIdAsync(scan.Id, Arg.Any())
.Returns(Result.From(scan));
Error error = Error.Failure(description: "Failed to cancel scan");
@@ -143,8 +145,10 @@ public class LibraryScanCancelledDomainEventHandlerTests
public async Task HandleAsync_WhenClearForScanFails_ShouldThrowEventualConsistencyException()
{
// Arrange
- LibraryScanEntity scan = _libraryScanEntityFixture.Create();
- LibraryScanCancelledDomainEvent domainEvent = new(Guid.NewGuid(), _scanIdFixture.Create(value: scan.Id), _libraryIdFixture.Create(value: scan.LibraryId), DateTime.UtcNow);
+ LibraryScanCancelledDomainEvent domainEvent = _libraryScanCancelledDomainEventFixture.Create();
+ LibraryScanEntity scan = _libraryScanEntityFixture.Create(
+ id: domainEvent.ScanId.Value,
+ libraryId: domainEvent.LibraryId.Value);
_mockLibraryScanRepository.GetByIdAsync(scan.Id, Arg.Any())
.Returns(Result.From(scan));
Error error = Error.Failure(description: "Failed to clear staging results");
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanFailedDomainEventHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanFailedDomainEventHandlerTests.cs
index aa5de98a..1d6d4e17 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanFailedDomainEventHandlerTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanFailedDomainEventHandlerTests.cs
@@ -12,9 +12,7 @@ using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Library
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Cancellation;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
-using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
-using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
-using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using DomainErrors = Lumina.Domain.Common.Errors.Errors;
using NSubstitute;
@@ -41,10 +39,7 @@ public class LibraryScanFailedDomainEventHandlerTests
private readonly IMediaLibraryScanProgressNotifier _mockDebouncedLibraryScanProgressNotifier;
private readonly LibraryScanFailedDomainEventHandler _sut;
private readonly LibraryScanEntityFixture _libraryScanEntityFixture = new();
- private readonly ScanIdFixture _scanIdFixture = new();
- private readonly UserIdFixture _userIdFixture = new();
- private readonly LibraryIdFixture _libraryIdFixture = new();
- private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
+ private readonly LibraryScanFailedDomainEventFixture _libraryScanFailedDomainEventFixture = new();
///
/// Initializes a new instance of the class.
@@ -73,11 +68,11 @@ public class LibraryScanFailedDomainEventHandlerTests
public async Task HandleAsync_WhenScanIsRunning_ShouldFailScanAndCleanupResources()
{
// Arrange
- LibraryScanEntity scan = _libraryScanEntityFixture.Create();
- MediaLibraryScanCompositeId compositeId = _mediaLibraryScanCompositeIdFixture.Create(
- scanId: _scanIdFixture.Create(value: scan.Id),
- userId: _userIdFixture.Create(value: scan.UserId));
- LibraryScanFailedDomainEvent domainEvent = new(Guid.NewGuid(), _libraryIdFixture.Create(value: scan.LibraryId), compositeId, DateTime.UtcNow);
+ LibraryScanFailedDomainEvent domainEvent = _libraryScanFailedDomainEventFixture.Create();
+ MediaLibraryScanCompositeId compositeId = domainEvent.MediaLibraryScanCompositeId;
+ LibraryScanEntity scan = _libraryScanEntityFixture.Create(
+ id: compositeId.ScanId.Value,
+ userId: compositeId.UserId.Value);
_mockLibraryScanRepository.GetByIdAsync(scan.Id, Arg.Any())
.Returns(Result.From(scan));
@@ -97,11 +92,12 @@ public class LibraryScanFailedDomainEventHandlerTests
public async Task HandleAsync_WhenScanIsNotRunning_ShouldSkipPersistenceButStillCleanupResources()
{
// Arrange
- LibraryScanEntity scan = _libraryScanEntityFixture.Create(status: LibraryScanJobStatus.Failed);
- MediaLibraryScanCompositeId compositeId = _mediaLibraryScanCompositeIdFixture.Create(
- scanId: _scanIdFixture.Create(value: scan.Id),
- userId: _userIdFixture.Create(value: scan.UserId));
- LibraryScanFailedDomainEvent domainEvent = new(Guid.NewGuid(), _libraryIdFixture.Create(value: scan.LibraryId), compositeId, DateTime.UtcNow);
+ LibraryScanFailedDomainEvent domainEvent = _libraryScanFailedDomainEventFixture.Create();
+ MediaLibraryScanCompositeId compositeId = domainEvent.MediaLibraryScanCompositeId;
+ LibraryScanEntity scan = _libraryScanEntityFixture.Create(
+ id: compositeId.ScanId.Value,
+ userId: compositeId.UserId.Value,
+ status: LibraryScanJobStatus.Failed);
_mockLibraryScanRepository.GetByIdAsync(scan.Id, Arg.Any())
.Returns(Result.From(scan));
@@ -121,8 +117,7 @@ public class LibraryScanFailedDomainEventHandlerTests
public async Task HandleAsync_WhenGetByIdFails_ShouldThrowEventualConsistencyException()
{
// Arrange
- MediaLibraryScanCompositeId compositeId = _mediaLibraryScanCompositeIdFixture.Create();
- LibraryScanFailedDomainEvent domainEvent = new(Guid.NewGuid(), _libraryIdFixture.Create(), compositeId, DateTime.UtcNow);
+ LibraryScanFailedDomainEvent domainEvent = _libraryScanFailedDomainEventFixture.Create();
Error error = Error.Failure(description: "Failed to get library scan");
_mockLibraryScanRepository.GetByIdAsync(Arg.Any(), Arg.Any())
.Returns(error);
@@ -140,8 +135,7 @@ public class LibraryScanFailedDomainEventHandlerTests
public async Task HandleAsync_WhenScanDoesNotExist_ShouldThrowEventualConsistencyExceptionWithNotFoundError()
{
// Arrange
- MediaLibraryScanCompositeId compositeId = _mediaLibraryScanCompositeIdFixture.Create();
- LibraryScanFailedDomainEvent domainEvent = new(Guid.NewGuid(), _libraryIdFixture.Create(), compositeId, DateTime.UtcNow);
+ LibraryScanFailedDomainEvent domainEvent = _libraryScanFailedDomainEventFixture.Create();
_mockLibraryScanRepository.GetByIdAsync(Arg.Any(), Arg.Any())
.Returns(Result.Success(null));
@@ -158,11 +152,11 @@ public class LibraryScanFailedDomainEventHandlerTests
public async Task HandleAsync_WhenUpdateFails_ShouldThrowEventualConsistencyException()
{
// Arrange
- LibraryScanEntity scan = _libraryScanEntityFixture.Create();
- MediaLibraryScanCompositeId compositeId = _mediaLibraryScanCompositeIdFixture.Create(
- scanId: _scanIdFixture.Create(value: scan.Id),
- userId: _userIdFixture.Create(value: scan.UserId));
- LibraryScanFailedDomainEvent domainEvent = new(Guid.NewGuid(), _libraryIdFixture.Create(value: scan.LibraryId), compositeId, DateTime.UtcNow);
+ LibraryScanFailedDomainEvent domainEvent = _libraryScanFailedDomainEventFixture.Create();
+ MediaLibraryScanCompositeId compositeId = domainEvent.MediaLibraryScanCompositeId;
+ LibraryScanEntity scan = _libraryScanEntityFixture.Create(
+ id: compositeId.ScanId.Value,
+ userId: compositeId.UserId.Value);
_mockLibraryScanRepository.GetByIdAsync(scan.Id, Arg.Any())
.Returns(Result.From(scan));
Error error = Error.Failure(description: "Failed to update library scan");
@@ -182,11 +176,11 @@ public class LibraryScanFailedDomainEventHandlerTests
public async Task HandleAsync_WhenClearForScanFails_ShouldThrowEventualConsistencyException()
{
// Arrange
- LibraryScanEntity scan = _libraryScanEntityFixture.Create();
- MediaLibraryScanCompositeId compositeId = _mediaLibraryScanCompositeIdFixture.Create(
- scanId: _scanIdFixture.Create(value: scan.Id),
- userId: _userIdFixture.Create(value: scan.UserId));
- LibraryScanFailedDomainEvent domainEvent = new(Guid.NewGuid(), _libraryIdFixture.Create(value: scan.LibraryId), compositeId, DateTime.UtcNow);
+ LibraryScanFailedDomainEvent domainEvent = _libraryScanFailedDomainEventFixture.Create();
+ MediaLibraryScanCompositeId compositeId = domainEvent.MediaLibraryScanCompositeId;
+ LibraryScanEntity scan = _libraryScanEntityFixture.Create(
+ id: compositeId.ScanId.Value,
+ userId: compositeId.UserId.Value);
_mockLibraryScanRepository.GetByIdAsync(scan.Id, Arg.Any())
.Returns(Result.From(scan));
Error error = Error.Failure(description: "Failed to clear staging results");
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanFinishedDomainEventHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanFinishedDomainEventHandlerTests.cs
index c73d7af9..8b7c7292 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanFinishedDomainEventHandlerTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanFinishedDomainEventHandlerTests.cs
@@ -8,14 +8,11 @@ using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Manage
using Lumina.Domain.Common.Exceptions;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
-using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Cancellation;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
-using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
-using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
-using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using DomainErrors = Lumina.Domain.Common.Errors.Errors;
using NSubstitute;
@@ -41,10 +38,7 @@ public class LibraryScanFinishedDomainEventHandlerTests
private readonly IMediaLibraryScanProgressNotifier _mockDebouncedLibraryScanProgressNotifier;
private readonly LibraryScanFinishedDomainEventHandler _sut;
private readonly LibraryScanEntityFixture _libraryScanEntityFixture = new();
- private readonly ScanIdFixture _scanIdFixture = new();
- private readonly UserIdFixture _userIdFixture = new();
- private readonly LibraryIdFixture _libraryIdFixture = new();
- private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
+ private readonly LibraryScanFinishedDomainEventFixture _libraryScanFinishedDomainEventFixture = new();
///
/// Initializes a new instance of the class.
@@ -69,11 +63,11 @@ public class LibraryScanFinishedDomainEventHandlerTests
public async Task HandleAsync_WhenScanIsRunning_ShouldFinishScanAndNotifyClients()
{
// Arrange
- LibraryScanEntity scan = _libraryScanEntityFixture.Create();
- MediaLibraryScanCompositeId compositeId = _mediaLibraryScanCompositeIdFixture.Create(
- scanId: _scanIdFixture.Create(value: scan.Id),
- userId: _userIdFixture.Create(value: scan.UserId));
- LibraryScanFinishedDomainEvent domainEvent = new(Guid.NewGuid(), compositeId, DateTime.UtcNow);
+ LibraryScanFinishedDomainEvent domainEvent = _libraryScanFinishedDomainEventFixture.Create();
+ MediaLibraryScanCompositeId compositeId = domainEvent.MediaLibraryScanCompositeId;
+ LibraryScanEntity scan = _libraryScanEntityFixture.Create(
+ id: compositeId.ScanId.Value,
+ userId: compositeId.UserId.Value);
_mockLibraryScanRepository.GetByIdAsync(scan.Id, Arg.Any())
.Returns(Result.From(scan));
_mockMediaLibrariesScanProgressTracker.UpdateScanProgress(Arg.Any(), compositeId).Returns(Result.Updated);
@@ -93,8 +87,7 @@ public class LibraryScanFinishedDomainEventHandlerTests
public async Task HandleAsync_WhenGetByIdFails_ShouldThrowEventualConsistencyException()
{
// Arrange
- MediaLibraryScanCompositeId compositeId = _mediaLibraryScanCompositeIdFixture.Create();
- LibraryScanFinishedDomainEvent domainEvent = new(Guid.NewGuid(), compositeId, DateTime.UtcNow);
+ LibraryScanFinishedDomainEvent domainEvent = _libraryScanFinishedDomainEventFixture.Create();
Error error = Error.Failure(description: "Failed to get library scan");
_mockLibraryScanRepository.GetByIdAsync(Arg.Any(), Arg.Any())
.Returns(error);
@@ -112,8 +105,7 @@ public class LibraryScanFinishedDomainEventHandlerTests
public async Task HandleAsync_WhenScanDoesNotExist_ShouldThrowEventualConsistencyExceptionWithNotFoundError()
{
// Arrange
- MediaLibraryScanCompositeId compositeId = _mediaLibraryScanCompositeIdFixture.Create();
- LibraryScanFinishedDomainEvent domainEvent = new(Guid.NewGuid(), compositeId, DateTime.UtcNow);
+ LibraryScanFinishedDomainEvent domainEvent = _libraryScanFinishedDomainEventFixture.Create();
_mockLibraryScanRepository.GetByIdAsync(Arg.Any(), Arg.Any())
.Returns(Result.Success(null));
@@ -130,11 +122,12 @@ public class LibraryScanFinishedDomainEventHandlerTests
public async Task HandleAsync_WhenScanIsNotRunning_ShouldThrowEventualConsistencyException()
{
// Arrange
- LibraryScanEntity scan = _libraryScanEntityFixture.Create(status: LibraryScanJobStatus.Pending);
- MediaLibraryScanCompositeId compositeId = _mediaLibraryScanCompositeIdFixture.Create(
- scanId: _scanIdFixture.Create(value: scan.Id),
- userId: _userIdFixture.Create(value: scan.UserId));
- LibraryScanFinishedDomainEvent domainEvent = new(Guid.NewGuid(), compositeId, DateTime.UtcNow);
+ LibraryScanFinishedDomainEvent domainEvent = _libraryScanFinishedDomainEventFixture.Create();
+ MediaLibraryScanCompositeId compositeId = domainEvent.MediaLibraryScanCompositeId;
+ LibraryScanEntity scan = _libraryScanEntityFixture.Create(
+ id: compositeId.ScanId.Value,
+ userId: compositeId.UserId.Value,
+ status: LibraryScanJobStatus.Pending);
_mockLibraryScanRepository.GetByIdAsync(scan.Id, Arg.Any())
.Returns(Result.From(scan));
@@ -152,11 +145,11 @@ public class LibraryScanFinishedDomainEventHandlerTests
public async Task HandleAsync_WhenUpdateFails_ShouldThrowEventualConsistencyException()
{
// Arrange
- LibraryScanEntity scan = _libraryScanEntityFixture.Create();
- MediaLibraryScanCompositeId compositeId = _mediaLibraryScanCompositeIdFixture.Create(
- scanId: _scanIdFixture.Create(value: scan.Id),
- userId: _userIdFixture.Create(value: scan.UserId));
- LibraryScanFinishedDomainEvent domainEvent = new(Guid.NewGuid(), compositeId, DateTime.UtcNow);
+ LibraryScanFinishedDomainEvent domainEvent = _libraryScanFinishedDomainEventFixture.Create();
+ MediaLibraryScanCompositeId compositeId = domainEvent.MediaLibraryScanCompositeId;
+ LibraryScanEntity scan = _libraryScanEntityFixture.Create(
+ id: compositeId.ScanId.Value,
+ userId: compositeId.UserId.Value);
_mockLibraryScanRepository.GetByIdAsync(scan.Id, Arg.Any())
.Returns(Result.From(scan));
Error error = Error.Failure(description: "Failed to update library scan");
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanJobProgressChangedDomainEventHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanJobProgressChangedDomainEventHandlerTests.cs
index 2ae13b83..ba8553d3 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanJobProgressChangedDomainEventHandlerTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanJobProgressChangedDomainEventHandlerTests.cs
@@ -6,7 +6,7 @@ using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Library
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
-using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using NSubstitute;
using System;
@@ -26,9 +26,8 @@ public class LibraryScanJobProgressChangedDomainEventHandlerTests
private readonly IMediaLibrariesScanProgressTracker _mockMediaLibrariesScanProgressTracker;
private readonly IMediaLibraryScanProgressNotifier _mockDebouncedLibraryScanProgressNotifier;
private readonly LibraryScanJobProgressChangedDomainEventHandler _sut;
- private readonly LibraryIdFixture _libraryIdFixture = new();
- private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
private readonly MediaLibraryScanJobProgressFixture _mediaLibraryScanJobProgressFixture = new();
+ private readonly LibraryScanJobProgressChangedDomainEventFixture _libraryScanJobProgressChangedDomainEventFixture = new();
///
/// Initializes a new instance of the class.
@@ -45,10 +44,10 @@ public class LibraryScanJobProgressChangedDomainEventHandlerTests
public async Task HandleAsync_WhenScanJobProgressChanges_ShouldUpdateTrackerAndNotifySignalRClients()
{
// Arrange
- LibraryId libraryId = _libraryIdFixture.Create();
- MediaLibraryScanCompositeId compositeId = _mediaLibraryScanCompositeIdFixture.Create();
MediaLibraryScanJobProgress progress = _mediaLibraryScanJobProgressFixture.Create(completedItems: 5, totalItems: 10, currentOperation: "Hashing");
- LibraryScanJobProgressChangedDomainEvent domainEvent = new(Guid.NewGuid(), libraryId, compositeId, progress, DateTime.UtcNow);
+ LibraryScanJobProgressChangedDomainEvent domainEvent = _libraryScanJobProgressChangedDomainEventFixture.Create(progress: progress);
+ LibraryId libraryId = domainEvent.LibraryId;
+ MediaLibraryScanCompositeId compositeId = domainEvent.MediaLibraryScanCompositeId;
_mockMediaLibrariesScanProgressTracker.UpdateScanJobProgress(libraryId, compositeId, progress).Returns(Result.Updated);
// Act
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanProgressChangedDomainEventHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanProgressChangedDomainEventHandlerTests.cs
index a3d0bc71..45ec9aee 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanProgressChangedDomainEventHandlerTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanProgressChangedDomainEventHandlerTests.cs
@@ -6,8 +6,7 @@ using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Library
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
-using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
-using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using NSubstitute;
using System;
using System.Diagnostics.CodeAnalysis;
@@ -26,8 +25,7 @@ public class LibraryScanProgressChangedDomainEventHandlerTests
private readonly IMediaLibrariesScanProgressTracker _mockMediaLibrariesScanProgressTracker;
private readonly IMediaLibraryScanProgressNotifier _mockDebouncedLibraryScanProgressNotifier;
private readonly LibraryScanProgressChangedDomainEventHandler _sut;
- private readonly LibraryIdFixture _libraryIdFixture = new();
- private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
+ private readonly LibraryScanProgressChangedDomainEventFixture _libraryScanProgressChangedDomainEventFixture = new();
///
/// Initializes a new instance of the class.
@@ -44,9 +42,9 @@ public class LibraryScanProgressChangedDomainEventHandlerTests
public async Task HandleAsync_WhenScanProgressChanges_ShouldUpdateTrackerAndNotifySignalRClients()
{
// Arrange
- LibraryId libraryId = _libraryIdFixture.Create();
- MediaLibraryScanCompositeId compositeId = _mediaLibraryScanCompositeIdFixture.Create();
- LibraryScanProgressChangedDomainEvent domainEvent = new(Guid.NewGuid(), libraryId, compositeId, DateTime.UtcNow);
+ LibraryScanProgressChangedDomainEvent domainEvent = _libraryScanProgressChangedDomainEventFixture.Create();
+ LibraryId libraryId = domainEvent.LibraryId;
+ MediaLibraryScanCompositeId compositeId = domainEvent.MediaLibraryScanCompositeId;
_mockMediaLibrariesScanProgressTracker.UpdateScanProgress(libraryId, compositeId).Returns(Result.Updated);
// Act
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanQueuedDomainEventHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanQueuedDomainEventHandlerTests.cs
index 03ef4f4e..7a868cf1 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanQueuedDomainEventHandlerTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Events/LibraryScanQueuedDomainEventHandlerTests.cs
@@ -11,8 +11,7 @@ using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services;
-using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
-using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using NSubstitute;
using System;
@@ -36,8 +35,7 @@ public class LibraryScanQueuedDomainEventHandlerTests
private readonly IDomainEventsQueue _mockDomainEventsQueue;
private readonly LibraryScanQueuedDomainEventHandler _sut;
private readonly LibraryScanEntityFixture _libraryScanEntityFixture = new();
- private readonly ScanIdFixture _scanIdFixture = new();
- private readonly LibraryIdFixture _libraryIdFixture = new();
+ private readonly LibraryScanQueuedDomainEventFixture _libraryScanQueuedDomainEventFixture = new();
///
/// Initializes a new instance of the class.
@@ -61,8 +59,10 @@ public class LibraryScanQueuedDomainEventHandlerTests
public async Task HandleAsync_WhenScanExists_ShouldStartTheScan()
{
// Arrange
- LibraryScanEntity scan = _libraryScanEntityFixture.Create();
- LibraryScanQueuedDomainEvent domainEvent = new(Guid.NewGuid(), _scanIdFixture.Create(value: scan.Id), _libraryIdFixture.Create(value: scan.LibraryId), DateTime.UtcNow);
+ LibraryScanQueuedDomainEvent domainEvent = _libraryScanQueuedDomainEventFixture.Create();
+ LibraryScanEntity scan = _libraryScanEntityFixture.Create(
+ id: domainEvent.ScanId.Value,
+ libraryId: domainEvent.LibraryId.Value);
_mockLibraryScanRepository.GetByIdAsync(scan.Id, Arg.Any())
.Returns(Result.From