mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 11:11:10 +00:00
Adds the scheduling module tests and centralizes domain event test fixtures
This commit is contained in:
1 parent
237be9e2c8
commit
99a6159f7f
135 files changed
+10203
-165
No files matched your search
+103
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScheduledJobEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the scheduled job.</param>
|
||||
/// <param name="name">Optional. The name of the scheduled job.</param>
|
||||
/// <param name="taskType">Optional. The type of the task executed by the scheduled job.</param>
|
||||
/// <param name="scheduleType">Optional. The type of the schedule of the scheduled job.</param>
|
||||
/// <param name="intervalMinutes">Optional. The interval in minutes of the schedule.</param>
|
||||
/// <param name="hour">Optional. The hour of the schedule.</param>
|
||||
/// <param name="minute">Optional. The minute of the schedule.</param>
|
||||
/// <param name="status">Optional. The status of the scheduled job.</param>
|
||||
/// <param name="ownerUserId">Optional. The Id of the user that owns the scheduled job.</param>
|
||||
/// <param name="lastStartedOnUtc">Optional. The last start time of the scheduled job.</param>
|
||||
/// <param name="lastCompletedOnUtc">Optional. The last completion time of the scheduled job.</param>
|
||||
/// <returns>The created <see cref="ScheduledJobEntity"/>.</returns>
|
||||
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<ScheduledJobEntity>()
|
||||
.CustomInstantiator(f =>
|
||||
{
|
||||
ScheduleType resolvedScheduleType = scheduleType ?? f.PickRandom<ScheduleType>();
|
||||
if (resolvedScheduleType == ScheduleType.WithIntervalInMinutes)
|
||||
{
|
||||
return new ScheduledJobEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
Name = name ?? f.Commerce.ProductName(),
|
||||
TaskType = taskType ?? f.PickRandom<ScheduledTaskType>(),
|
||||
ScheduleType = resolvedScheduleType,
|
||||
IntervalMinutes = intervalMinutes ?? f.Random.Int(1, 1440),
|
||||
Hour = null,
|
||||
Minute = null,
|
||||
Status = status ?? f.PickRandom<ScheduledJobStatus>(),
|
||||
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<ScheduledTaskType>(),
|
||||
ScheduleType = resolvedScheduleType,
|
||||
IntervalMinutes = null,
|
||||
Hour = hour ?? f.Random.Int(0, 23),
|
||||
Minute = minute ?? f.Random.Int(0, 59),
|
||||
Status = status ?? f.PickRandom<ScheduledJobStatus>(),
|
||||
OwnerUserId = ownerUserId ?? Guid.NewGuid(),
|
||||
LastStartedOnUtc = lastStartedOnUtc,
|
||||
LastCompletedOnUtc = lastCompletedOnUtc,
|
||||
CreatedOnUtc = DateTime.UtcNow,
|
||||
CreatedBy = Guid.NewGuid(),
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
};
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ScheduledJobEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ScheduledJobEntity"/> instances.</returns>
|
||||
public List<ScheduledJobEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+63
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobExecutionEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobExecutionEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScheduledJobExecutionEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the execution.</param>
|
||||
/// <param name="scheduledJobId">Optional. The Id of the scheduled job whose task was executed.</param>
|
||||
/// <param name="taskType">Optional. The type of the task that was executed.</param>
|
||||
/// <param name="isCycleRun">Optional. Whether the execution was a cycle run.</param>
|
||||
/// <param name="startedOnUtc">Optional. The start time of the execution.</param>
|
||||
/// <param name="completedOnUtc">Optional. The completion time of the execution.</param>
|
||||
/// <returns>The created <see cref="ScheduledJobExecutionEntity"/>.</returns>
|
||||
public ScheduledJobExecutionEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? scheduledJobId = null,
|
||||
ScheduledTaskType? taskType = null,
|
||||
bool? isCycleRun = null,
|
||||
DateTime? startedOnUtc = null,
|
||||
DateTime? completedOnUtc = null)
|
||||
{
|
||||
return new Faker<ScheduledJobExecutionEntity>()
|
||||
.CustomInstantiator(f => new ScheduledJobExecutionEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
ScheduledJobId = scheduledJobId ?? Guid.NewGuid(),
|
||||
TaskType = taskType ?? f.PickRandom<ScheduledTaskType>(),
|
||||
IsCycleRun = isCycleRun ?? f.Random.Bool(),
|
||||
StartedOnUtc = startedOnUtc ?? DateTime.UtcNow,
|
||||
CompletedOnUtc = completedOnUtc,
|
||||
CreatedOnUtc = DateTime.UtcNow,
|
||||
CreatedBy = Guid.NewGuid(),
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ScheduledJobExecutionEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ScheduledJobExecutionEntity"/> instances.</returns>
|
||||
public List<ScheduledJobExecutionEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+60
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="SchedulerDisplayPreferencesEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SchedulerDisplayPreferencesEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="SchedulerDisplayPreferencesEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the display preferences.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the display preferences.</param>
|
||||
/// <param name="jobTypeFilter">Optional. The type of the scheduled job tasks whose executions are shown.</param>
|
||||
/// <param name="displayTimeSpan">Optional. The displayed time span.</param>
|
||||
/// <param name="displayTimeUnit">Optional. The unit of the displayed time span.</param>
|
||||
/// <returns>The created <see cref="SchedulerDisplayPreferencesEntity"/>.</returns>
|
||||
public SchedulerDisplayPreferencesEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? userId = null,
|
||||
ScheduledTaskType? jobTypeFilter = null,
|
||||
int? displayTimeSpan = null,
|
||||
SchedulerDisplayTimeUnit? displayTimeUnit = null)
|
||||
{
|
||||
return new Faker<SchedulerDisplayPreferencesEntity>()
|
||||
.CustomInstantiator(f => new SchedulerDisplayPreferencesEntity
|
||||
{
|
||||
Id = id ?? Guid.NewGuid(),
|
||||
UserId = userId ?? Guid.NewGuid(),
|
||||
JobTypeFilter = jobTypeFilter ?? (f.Random.Bool() ? f.PickRandom<ScheduledTaskType>() : null),
|
||||
DisplayTimeSpan = displayTimeSpan ?? f.Random.Int(1, 24 * 60),
|
||||
DisplayTimeUnit = displayTimeUnit ?? f.PickRandom<SchedulerDisplayTimeUnit>(),
|
||||
CreatedOnUtc = DateTime.UtcNow,
|
||||
CreatedBy = Guid.NewGuid(),
|
||||
UpdatedOnUtc = null,
|
||||
UpdatedBy = null
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="SchedulerDisplayPreferencesEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="SchedulerDisplayPreferencesEntity"/> instances.</returns>
|
||||
public List<SchedulerDisplayPreferencesEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+70
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddScheduledJobCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddScheduledJobCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid command to add a scheduled job.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The name of the scheduled job.</param>
|
||||
/// <param name="taskType">Optional. The type of the task executed by the scheduled job.</param>
|
||||
/// <param name="scheduleType">Optional. The type of the schedule of the scheduled job.</param>
|
||||
/// <param name="intervalMinutes">Optional. The interval in minutes of the schedule.</param>
|
||||
/// <param name="hour">Optional. The hour of the schedule.</param>
|
||||
/// <param name="minute">Optional. The minute of the schedule.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public AddScheduledJobCommand Create(
|
||||
string? name = null,
|
||||
ScheduledTaskType? taskType = null,
|
||||
ScheduleType? scheduleType = null,
|
||||
int? intervalMinutes = null,
|
||||
int? hour = null,
|
||||
int? minute = null)
|
||||
{
|
||||
return new Faker<AddScheduledJobCommand>()
|
||||
.CustomInstantiator(f =>
|
||||
{
|
||||
ScheduleType resolvedScheduleType = scheduleType ?? f.PickRandom<ScheduleType>();
|
||||
if (resolvedScheduleType == ScheduleType.WithIntervalInMinutes)
|
||||
{
|
||||
return new AddScheduledJobCommand(
|
||||
name ?? f.Commerce.ProductName(),
|
||||
taskType ?? f.PickRandom<ScheduledTaskType>(),
|
||||
resolvedScheduleType,
|
||||
intervalMinutes ?? f.Random.Int(1, 1440),
|
||||
null,
|
||||
null);
|
||||
}
|
||||
return new AddScheduledJobCommand(
|
||||
name ?? f.Commerce.ProductName(),
|
||||
taskType ?? f.PickRandom<ScheduledTaskType>(),
|
||||
resolvedScheduleType,
|
||||
null,
|
||||
hour ?? f.Random.Int(0, 23),
|
||||
minute ?? f.Random.Int(0, 59));
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AddScheduledJobCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<AddScheduledJobCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+40
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FireScheduledJobCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FireScheduledJobCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid command to fire the task of a scheduled job once.
|
||||
/// </summary>
|
||||
/// <param name="scheduledJobId">Optional. The Id of the scheduled job whose task is fired.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public FireScheduledJobCommand Create(
|
||||
Guid? scheduledJobId = null)
|
||||
{
|
||||
return new Faker<FireScheduledJobCommand>()
|
||||
.CustomInstantiator(f => new FireScheduledJobCommand(scheduledJobId ?? Guid.NewGuid()))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="FireScheduledJobCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<FireScheduledJobCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+40
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="RemoveScheduledJobCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RemoveScheduledJobCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid command to remove a scheduled job.
|
||||
/// </summary>
|
||||
/// <param name="scheduledJobId">Optional. The Id of the scheduled job to remove.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public RemoveScheduledJobCommand Create(
|
||||
Guid? scheduledJobId = null)
|
||||
{
|
||||
return new Faker<RemoveScheduledJobCommand>()
|
||||
.CustomInstantiator(f => new RemoveScheduledJobCommand(scheduledJobId ?? Guid.NewGuid()))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="RemoveScheduledJobCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<RemoveScheduledJobCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+40
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="StartScheduledJobCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class StartScheduledJobCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid command to start the execution cycle of a scheduled job.
|
||||
/// </summary>
|
||||
/// <param name="scheduledJobId">Optional. The Id of the scheduled job whose execution cycle is started.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public StartScheduledJobCommand Create(
|
||||
Guid? scheduledJobId = null)
|
||||
{
|
||||
return new Faker<StartScheduledJobCommand>()
|
||||
.CustomInstantiator(f => new StartScheduledJobCommand(scheduledJobId ?? Guid.NewGuid()))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="StartScheduledJobCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<StartScheduledJobCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+40
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="StopScheduledJobCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class StopScheduledJobCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid command to stop the execution cycle of a scheduled job.
|
||||
/// </summary>
|
||||
/// <param name="scheduledJobId">Optional. The Id of the scheduled job whose execution cycle is stopped.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public StopScheduledJobCommand Create(
|
||||
Guid? scheduledJobId = null)
|
||||
{
|
||||
return new Faker<StopScheduledJobCommand>()
|
||||
.CustomInstantiator(f => new StopScheduledJobCommand(scheduledJobId ?? Guid.NewGuid()))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="StopScheduledJobCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<StopScheduledJobCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UpdateSchedulerDisplayPreferencesCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdateSchedulerDisplayPreferencesCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid command to update the display preferences of the scheduler page of the current user.
|
||||
/// </summary>
|
||||
/// <param name="jobTypeFilter">Optional. The type of the scheduled job tasks whose executions are shown.</param>
|
||||
/// <param name="displayTimeSpan">Optional. The displayed time span.</param>
|
||||
/// <param name="displayTimeUnit">Optional. The unit of the displayed time span.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public UpdateSchedulerDisplayPreferencesCommand Create(
|
||||
ScheduledTaskType? jobTypeFilter = null,
|
||||
int? displayTimeSpan = null,
|
||||
SchedulerDisplayTimeUnit? displayTimeUnit = null)
|
||||
{
|
||||
return new Faker<UpdateSchedulerDisplayPreferencesCommand>()
|
||||
.CustomInstantiator(f => new UpdateSchedulerDisplayPreferencesCommand(
|
||||
jobTypeFilter ?? (f.Random.Bool() ? f.PickRandom<ScheduledTaskType>() : null),
|
||||
displayTimeSpan ?? f.Random.Int(1, 24 * 60),
|
||||
displayTimeUnit ?? f.PickRandom<SchedulerDisplayTimeUnit>()))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UpdateSchedulerDisplayPreferencesCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<UpdateSchedulerDisplayPreferencesCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+53
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetScheduledJobHistoryQuery"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetScheduledJobHistoryQueryFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid query to get the history of the executions of the tasks of scheduled jobs.
|
||||
/// </summary>
|
||||
/// <param name="from">Optional. The inclusive lower bound of the requested interval.</param>
|
||||
/// <param name="to">Optional. The inclusive upper bound of the requested interval.</param>
|
||||
/// <param name="includeFrom">Whether to include the lower bound in the query. When false, the lower bound is left unset.</param>
|
||||
/// <param name="includeTo">Whether to include the upper bound in the query. When false, the upper bound is left unset.</param>
|
||||
/// <returns>The created query.</returns>
|
||||
public GetScheduledJobHistoryQuery Create(
|
||||
DateTime? from = null,
|
||||
DateTime? to = null,
|
||||
bool includeFrom = true,
|
||||
bool includeTo = true)
|
||||
{
|
||||
return new Faker<GetScheduledJobHistoryQuery>()
|
||||
.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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetScheduledJobHistoryQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetScheduledJobHistoryQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+70
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddScheduledJobRequest"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddScheduledJobRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid request to add a scheduled job.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The name of the scheduled job.</param>
|
||||
/// <param name="taskType">Optional. The type of the task executed by the scheduled job.</param>
|
||||
/// <param name="scheduleType">Optional. The type of the schedule of the scheduled job.</param>
|
||||
/// <param name="intervalMinutes">Optional. The interval in minutes of the schedule.</param>
|
||||
/// <param name="hour">Optional. The hour of the schedule.</param>
|
||||
/// <param name="minute">Optional. The minute of the schedule.</param>
|
||||
/// <returns>The created request.</returns>
|
||||
public AddScheduledJobRequest Create(
|
||||
string? name = null,
|
||||
ScheduledTaskType? taskType = null,
|
||||
ScheduleType? scheduleType = null,
|
||||
int? intervalMinutes = null,
|
||||
int? hour = null,
|
||||
int? minute = null)
|
||||
{
|
||||
return new Faker<AddScheduledJobRequest>()
|
||||
.CustomInstantiator(f =>
|
||||
{
|
||||
ScheduleType resolvedScheduleType = scheduleType ?? f.PickRandom<ScheduleType>();
|
||||
if (resolvedScheduleType == ScheduleType.WithIntervalInMinutes)
|
||||
{
|
||||
return new AddScheduledJobRequest(
|
||||
name ?? f.Commerce.ProductName(),
|
||||
taskType ?? f.PickRandom<ScheduledTaskType>(),
|
||||
resolvedScheduleType,
|
||||
intervalMinutes ?? f.Random.Int(1, 1440),
|
||||
null,
|
||||
null);
|
||||
}
|
||||
return new AddScheduledJobRequest(
|
||||
name ?? f.Commerce.ProductName(),
|
||||
taskType ?? f.PickRandom<ScheduledTaskType>(),
|
||||
resolvedScheduleType,
|
||||
null,
|
||||
hour ?? f.Random.Int(0, 23),
|
||||
minute ?? f.Random.Int(0, 59));
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AddScheduledJobRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<AddScheduledJobRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+40
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FireScheduledJobRequest"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FireScheduledJobRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid request to fire the task of a scheduled job once.
|
||||
/// </summary>
|
||||
/// <param name="scheduledJobId">Optional. The Id of the scheduled job whose task is fired.</param>
|
||||
/// <returns>The created request.</returns>
|
||||
public FireScheduledJobRequest Create(
|
||||
Guid? scheduledJobId = null)
|
||||
{
|
||||
return new Faker<FireScheduledJobRequest>()
|
||||
.CustomInstantiator(f => new FireScheduledJobRequest(scheduledJobId ?? Guid.NewGuid()))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="FireScheduledJobRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<FireScheduledJobRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetScheduledJobHistoryRequest"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetScheduledJobHistoryRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid request to get the history of the executions of the tasks of scheduled jobs.
|
||||
/// </summary>
|
||||
/// <param name="from">Optional. The inclusive lower bound of the requested interval.</param>
|
||||
/// <param name="to">Optional. The inclusive upper bound of the requested interval.</param>
|
||||
/// <returns>The created request.</returns>
|
||||
public GetScheduledJobHistoryRequest Create(
|
||||
DateTime? from = null,
|
||||
DateTime? to = null)
|
||||
{
|
||||
return new Faker<GetScheduledJobHistoryRequest>()
|
||||
.CustomInstantiator(f =>
|
||||
{
|
||||
DateTime resolvedFrom = from ?? f.Date.Recent(30);
|
||||
DateTime resolvedTo = to ?? f.Date.Soon(1, resolvedFrom);
|
||||
return new GetScheduledJobHistoryRequest(resolvedFrom, resolvedTo);
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetScheduledJobHistoryRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetScheduledJobHistoryRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+40
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="RemoveScheduledJobRequest"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RemoveScheduledJobRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid request to remove a scheduled job.
|
||||
/// </summary>
|
||||
/// <param name="scheduledJobId">Optional. The Id of the scheduled job to remove.</param>
|
||||
/// <returns>The created request.</returns>
|
||||
public RemoveScheduledJobRequest Create(
|
||||
Guid? scheduledJobId = null)
|
||||
{
|
||||
return new Faker<RemoveScheduledJobRequest>()
|
||||
.CustomInstantiator(f => new RemoveScheduledJobRequest(scheduledJobId ?? Guid.NewGuid()))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="RemoveScheduledJobRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<RemoveScheduledJobRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+40
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="StartScheduledJobRequest"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class StartScheduledJobRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid request to start the execution cycle of a scheduled job.
|
||||
/// </summary>
|
||||
/// <param name="scheduledJobId">Optional. The Id of the scheduled job whose execution cycle is started.</param>
|
||||
/// <returns>The created request.</returns>
|
||||
public StartScheduledJobRequest Create(
|
||||
Guid? scheduledJobId = null)
|
||||
{
|
||||
return new Faker<StartScheduledJobRequest>()
|
||||
.CustomInstantiator(f => new StartScheduledJobRequest(scheduledJobId ?? Guid.NewGuid()))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="StartScheduledJobRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<StartScheduledJobRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+40
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="StopScheduledJobRequest"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class StopScheduledJobRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid request to stop the execution cycle of a scheduled job.
|
||||
/// </summary>
|
||||
/// <param name="scheduledJobId">Optional. The Id of the scheduled job whose execution cycle is stopped.</param>
|
||||
/// <returns>The created request.</returns>
|
||||
public StopScheduledJobRequest Create(
|
||||
Guid? scheduledJobId = null)
|
||||
{
|
||||
return new Faker<StopScheduledJobRequest>()
|
||||
.CustomInstantiator(f => new StopScheduledJobRequest(scheduledJobId ?? Guid.NewGuid()))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="StopScheduledJobRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<StopScheduledJobRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UpdateSchedulerDisplayPreferencesRequest"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdateSchedulerDisplayPreferencesRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid request to update the display preferences of the scheduler page of the current user.
|
||||
/// </summary>
|
||||
/// <param name="jobTypeFilter">Optional. The type of the scheduled job tasks whose executions are shown.</param>
|
||||
/// <param name="displayTimeSpan">Optional. The displayed time span.</param>
|
||||
/// <param name="displayTimeUnit">Optional. The unit of the displayed time span.</param>
|
||||
/// <returns>The created request.</returns>
|
||||
public UpdateSchedulerDisplayPreferencesRequest Create(
|
||||
ScheduledTaskType? jobTypeFilter = null,
|
||||
int? displayTimeSpan = null,
|
||||
SchedulerDisplayTimeUnit? displayTimeUnit = null)
|
||||
{
|
||||
return new Faker<UpdateSchedulerDisplayPreferencesRequest>()
|
||||
.CustomInstantiator(f => new UpdateSchedulerDisplayPreferencesRequest(
|
||||
jobTypeFilter ?? (f.Random.Bool() ? f.PickRandom<ScheduledTaskType>() : null),
|
||||
displayTimeSpan ?? f.Random.Int(1, 24 * 60),
|
||||
displayTimeUnit ?? f.PickRandom<SchedulerDisplayTimeUnit>()))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UpdateSchedulerDisplayPreferencesRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<UpdateSchedulerDisplayPreferencesRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+57
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobExecutionResponse"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobExecutionResponseFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScheduledJobExecutionResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the execution.</param>
|
||||
/// <param name="scheduledJobId">Optional. The Id of the scheduled job whose task was executed.</param>
|
||||
/// <param name="taskType">Optional. The type of the task that was executed.</param>
|
||||
/// <param name="isCycleRun">Optional. Whether the execution was a cycle run.</param>
|
||||
/// <param name="startedOnUtc">Optional. The start time of the execution.</param>
|
||||
/// <param name="completedOnUtc">Optional. The completion time of the execution.</param>
|
||||
/// <returns>The created <see cref="ScheduledJobExecutionResponse"/>.</returns>
|
||||
public ScheduledJobExecutionResponse Create(
|
||||
Guid? id = null,
|
||||
Guid? scheduledJobId = null,
|
||||
ScheduledTaskType? taskType = null,
|
||||
bool? isCycleRun = null,
|
||||
DateTime? startedOnUtc = null,
|
||||
DateTime? completedOnUtc = null)
|
||||
{
|
||||
return new Faker<ScheduledJobExecutionResponse>()
|
||||
.CustomInstantiator(f => new ScheduledJobExecutionResponse(
|
||||
id ?? Guid.NewGuid(),
|
||||
scheduledJobId ?? Guid.NewGuid(),
|
||||
taskType ?? f.PickRandom<ScheduledTaskType>(),
|
||||
isCycleRun ?? f.Random.Bool(),
|
||||
startedOnUtc ?? DateTime.UtcNow,
|
||||
completedOnUtc))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ScheduledJobExecutionResponse"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ScheduledJobExecutionResponse"/> instances.</returns>
|
||||
public List<ScheduledJobExecutionResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+87
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobResponse"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobResponseFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScheduledJobResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the scheduled job.</param>
|
||||
/// <param name="name">Optional. The name of the scheduled job.</param>
|
||||
/// <param name="taskType">Optional. The type of the task executed by the scheduled job.</param>
|
||||
/// <param name="scheduleType">Optional. The type of the schedule of the scheduled job.</param>
|
||||
/// <param name="intervalMinutes">Optional. The interval in minutes of the schedule.</param>
|
||||
/// <param name="hour">Optional. The hour of the schedule.</param>
|
||||
/// <param name="minute">Optional. The minute of the schedule.</param>
|
||||
/// <param name="status">Optional. The status of the scheduled job.</param>
|
||||
/// <param name="lastStartedOnUtc">Optional. The last start time of the scheduled job.</param>
|
||||
/// <param name="lastCompletedOnUtc">Optional. The last completion time of the scheduled job.</param>
|
||||
/// <returns>The created <see cref="ScheduledJobResponse"/>.</returns>
|
||||
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<ScheduledJobResponse>()
|
||||
.CustomInstantiator(f =>
|
||||
{
|
||||
ScheduleType resolvedScheduleType = scheduleType ?? f.PickRandom<ScheduleType>();
|
||||
if (resolvedScheduleType == ScheduleType.WithIntervalInMinutes)
|
||||
{
|
||||
return new ScheduledJobResponse(
|
||||
id ?? Guid.NewGuid(),
|
||||
name ?? f.Commerce.ProductName(),
|
||||
taskType ?? f.PickRandom<ScheduledTaskType>(),
|
||||
resolvedScheduleType,
|
||||
intervalMinutes ?? f.Random.Int(1, 1440),
|
||||
null,
|
||||
null,
|
||||
status ?? f.PickRandom<ScheduledJobStatus>(),
|
||||
lastStartedOnUtc,
|
||||
lastCompletedOnUtc);
|
||||
}
|
||||
return new ScheduledJobResponse(
|
||||
id ?? Guid.NewGuid(),
|
||||
name ?? f.Commerce.ProductName(),
|
||||
taskType ?? f.PickRandom<ScheduledTaskType>(),
|
||||
resolvedScheduleType,
|
||||
null,
|
||||
hour ?? f.Random.Int(0, 23),
|
||||
minute ?? f.Random.Int(0, 59),
|
||||
status ?? f.PickRandom<ScheduledJobStatus>(),
|
||||
lastStartedOnUtc,
|
||||
lastCompletedOnUtc);
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ScheduledJobResponse"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ScheduledJobResponse"/> instances.</returns>
|
||||
public List<ScheduledJobResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+51
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="SchedulerDisplayPreferencesResponse"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SchedulerDisplayPreferencesResponseFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="SchedulerDisplayPreferencesResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the display preferences.</param>
|
||||
/// <param name="jobTypeFilter">Optional. The type of the scheduled job tasks whose executions are shown.</param>
|
||||
/// <param name="displayTimeSpan">Optional. The displayed time span.</param>
|
||||
/// <param name="displayTimeUnit">Optional. The unit of the displayed time span.</param>
|
||||
/// <returns>The created <see cref="SchedulerDisplayPreferencesResponse"/>.</returns>
|
||||
public SchedulerDisplayPreferencesResponse Create(
|
||||
Guid? userId = null,
|
||||
ScheduledTaskType? jobTypeFilter = null,
|
||||
int? displayTimeSpan = null,
|
||||
SchedulerDisplayTimeUnit? displayTimeUnit = null)
|
||||
{
|
||||
return new Faker<SchedulerDisplayPreferencesResponse>()
|
||||
.CustomInstantiator(f => new SchedulerDisplayPreferencesResponse(
|
||||
userId ?? Guid.NewGuid(),
|
||||
jobTypeFilter ?? (f.Random.Bool() ? f.PickRandom<ScheduledTaskType>() : null),
|
||||
displayTimeSpan ?? f.Random.Int(1, 24 * 60),
|
||||
displayTimeUnit ?? f.PickRandom<SchedulerDisplayTimeUnit>()))
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="SchedulerDisplayPreferencesResponse"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="SchedulerDisplayPreferencesResponse"/> instances.</returns>
|
||||
public List<SchedulerDisplayPreferencesResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+33
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryDeletedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryDeletedDomainEventFixture
|
||||
{
|
||||
private readonly LibraryFixture _libraryFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryDeletedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="library">Optional. The library that was deleted.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibraryDeletedDomainEvent"/>.</returns>
|
||||
public LibraryDeletedDomainEvent Create(Guid? id = null, Library? library = null, DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new LibraryDeletedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
library ?? _libraryFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+47
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryMediaItemDeletedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryMediaItemDeletedDomainEventFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryMediaItemDeletedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="libraryId">Optional. The unique identifier of the library to which the deleted media library item belonged.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Optional. The composite identifier of the media library scan during which the item deletion was detected.</param>
|
||||
/// <param name="path">Optional. The path of the media library item that was deleted.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibraryMediaItemDeletedDomainEvent"/>.</returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
+42
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanCancelledDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanCancelledDomainEventFixture
|
||||
{
|
||||
private readonly ScanIdFixture _scanIdFixture = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryScanCancelledDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="scanId">Optional. The unique identifier of the cancelled media library scan.</param>
|
||||
/// <param name="libraryId">Optional. The unique identifier of the library whose scan was cancelled.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibraryScanCancelledDomainEvent"/>.</returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
+49
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanFailedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanFailedDomainEventFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryScanFailedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="libraryId">Optional. The unique identifier of the library whose scan has failed.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Optional. The composite identifier of the media library scan that has failed.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <param name="errorMessage">Optional. The descriptive message of the failure.</param>
|
||||
/// <param name="includeErrorMessage">Whether to include an error message in the domain event. When false, the error message is left unset.</param>
|
||||
/// <returns>The created <see cref="LibraryScanFailedDomainEvent"/>.</returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
+36
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanFinishedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanFinishedDomainEventFixture
|
||||
{
|
||||
private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryScanFinishedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Optional. The composite identifier of the media library scan that was finished.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibraryScanFinishedDomainEvent"/>.</returns>
|
||||
public LibraryScanFinishedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
MediaLibraryScanCompositeId? mediaLibraryScanCompositeId = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new LibraryScanFinishedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+46
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanJobProgressChangedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanJobProgressChangedDomainEventFixture
|
||||
{
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
|
||||
private readonly MediaLibraryScanJobProgressFixture _mediaLibraryScanJobProgressFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryScanJobProgressChangedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="libraryId">Optional. The unique identifier of the library being scanned.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Optional. The composite identifier of the media library scan whose job progress changed.</param>
|
||||
/// <param name="progress">Optional. The new media library scan job progress.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibraryScanJobProgressChangedDomainEvent"/>.</returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
+42
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanProgressChangedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanProgressChangedDomainEventFixture
|
||||
{
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryScanProgressChangedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="libraryId">Optional. The unique identifier of the library being scanned.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Optional. The composite identifier of the media library scan whose progress changed.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibraryScanProgressChangedDomainEvent"/>.</returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
+42
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanQueuedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanQueuedDomainEventFixture
|
||||
{
|
||||
private readonly ScanIdFixture _scanIdFixture = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryScanQueuedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="scanId">Optional. The unique identifier of the queued media library scan.</param>
|
||||
/// <param name="libraryId">Optional. The unique identifier of the library whose scan was queued.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibraryScanQueuedDomainEvent"/>.</returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
+33
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanStartedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanStartedDomainEventFixture
|
||||
{
|
||||
private readonly LibraryScanFixture _libraryScanFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryScanStartedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="libraryScan">Optional. The library scan that was started.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibraryScanStartedDomainEvent"/>.</returns>
|
||||
public LibraryScanStartedDomainEvent Create(Guid? id = null, LibraryScan? libraryScan = null, DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new LibraryScanStartedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
libraryScan ?? _libraryScanFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+37
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UserId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UserId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the user Id.</param>
|
||||
/// <returns>The created <see cref="UserId"/>.</returns>
|
||||
public UserId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return UserId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UserId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="UserId"/> instances.</returns>
|
||||
public List<UserId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobAddedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobAddedDomainEventFixture
|
||||
{
|
||||
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScheduledJobAddedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="scheduledJobId">Optional. The unique identifier of the scheduled job that was added.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="ScheduledJobAddedDomainEvent"/>.</returns>
|
||||
public ScheduledJobAddedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
ScheduledJobId? scheduledJobId = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new ScheduledJobAddedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
scheduledJobId ?? _scheduledJobIdFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+36
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobCycleStartedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobCycleStartedDomainEventFixture
|
||||
{
|
||||
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScheduledJobCycleStartedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="scheduledJobId">Optional. The unique identifier of the scheduled job whose execution cycle was started.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="ScheduledJobCycleStartedDomainEvent"/>.</returns>
|
||||
public ScheduledJobCycleStartedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
ScheduledJobId? scheduledJobId = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new ScheduledJobCycleStartedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
scheduledJobId ?? _scheduledJobIdFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+36
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobCycleStoppedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobCycleStoppedDomainEventFixture
|
||||
{
|
||||
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScheduledJobCycleStoppedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="scheduledJobId">Optional. The unique identifier of the scheduled job whose execution cycle was stopped.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="ScheduledJobCycleStoppedDomainEvent"/>.</returns>
|
||||
public ScheduledJobCycleStoppedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
ScheduledJobId? scheduledJobId = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new ScheduledJobCycleStoppedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
scheduledJobId ?? _scheduledJobIdFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+46
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobExecutionCompletedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobExecutionCompletedDomainEventFixture
|
||||
{
|
||||
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScheduledJobExecutionCompletedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="scheduledJobId">Optional. The unique identifier of the scheduled job whose task completed its execution.</param>
|
||||
/// <param name="runId">Optional. The unique identifier of the current execution of the task of the scheduled job.</param>
|
||||
/// <param name="taskType">The type of the task that completed its execution.</param>
|
||||
/// <param name="isCycleRun">Whether the execution was triggered by the execution cycle of the scheduled job.</param>
|
||||
/// <param name="completedOnUtc">Optional. The date and time when the execution completed.</param>
|
||||
/// <returns>The created <see cref="ScheduledJobExecutionCompletedDomainEvent"/>.</returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
+46
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobExecutionStartedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobExecutionStartedDomainEventFixture
|
||||
{
|
||||
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScheduledJobExecutionStartedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="scheduledJobId">Optional. The unique identifier of the scheduled job whose task started executing.</param>
|
||||
/// <param name="runId">Optional. The unique identifier of the current execution of the task of the scheduled job.</param>
|
||||
/// <param name="taskType">The type of the task that started executing.</param>
|
||||
/// <param name="isCycleRun">Whether the execution was triggered by the execution cycle of the scheduled job.</param>
|
||||
/// <param name="startedOnUtc">Optional. The date and time when the execution started.</param>
|
||||
/// <returns>The created <see cref="ScheduledJobExecutionStartedDomainEvent"/>.</returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
+36
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobExecutionStoppedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobExecutionStoppedDomainEventFixture
|
||||
{
|
||||
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScheduledJobExecutionStoppedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="scheduledJobId">Optional. The unique identifier of the scheduled job whose running execution was stopped.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="ScheduledJobExecutionStoppedDomainEvent"/>.</returns>
|
||||
public ScheduledJobExecutionStoppedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
ScheduledJobId? scheduledJobId = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new ScheduledJobExecutionStoppedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
scheduledJobId ?? _scheduledJobIdFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+36
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobFiredDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobFiredDomainEventFixture
|
||||
{
|
||||
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScheduledJobFiredDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="scheduledJobId">Optional. The unique identifier of the scheduled job whose task was fired.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="ScheduledJobFiredDomainEvent"/>.</returns>
|
||||
public ScheduledJobFiredDomainEvent Create(
|
||||
Guid? id = null,
|
||||
ScheduledJobId? scheduledJobId = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new ScheduledJobFiredDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
scheduledJobId ?? _scheduledJobIdFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+36
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobRemovedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobRemovedDomainEventFixture
|
||||
{
|
||||
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScheduledJobRemovedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="scheduledJobId">Optional. The unique identifier of the scheduled job that was removed.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="ScheduledJobRemovedDomainEvent"/>.</returns>
|
||||
public ScheduledJobRemovedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
ScheduledJobId? scheduledJobId = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new ScheduledJobRemovedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
scheduledJobId ?? _scheduledJobIdFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+83
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJob"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobFixture
|
||||
{
|
||||
private readonly IntervalScheduleFixture _intervalScheduleFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScheduledJob"/> domain aggregate.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the scheduled job. When provided, the aggregate is created with pre-existing data.</param>
|
||||
/// <param name="name">Optional. The name of the scheduled job.</param>
|
||||
/// <param name="taskType">Optional. The type of the task executed by the scheduled job.</param>
|
||||
/// <param name="schedule">Optional. The schedule of the scheduled job. Defaults to an interval schedule of 60 minutes.</param>
|
||||
/// <param name="ownerUserId">Optional. The Id of the user that owns the scheduled job.</param>
|
||||
/// <param name="status">Optional. The status of the scheduled job. Only applied when <paramref name="id"/> is provided.</param>
|
||||
/// <param name="lastStartedOnUtc">Optional. The last start time of the scheduled job. Only applied when <paramref name="id"/> is provided.</param>
|
||||
/// <param name="lastCompletedOnUtc">Optional. The last completion time of the scheduled job. Only applied when <paramref name="id"/> is provided.</param>
|
||||
/// <returns>The created <see cref="ScheduledJob"/>.</returns>
|
||||
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<ScheduledTaskType>();
|
||||
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<ScheduledJob> 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<ScheduledJob> createWithIdResult = ScheduledJob.Create(
|
||||
ScheduledJobId.Create(id ?? Guid.NewGuid()),
|
||||
resolvedName,
|
||||
resolvedTaskType,
|
||||
resolvedSchedule,
|
||||
resolvedOwnerUserId,
|
||||
resolvedStatus,
|
||||
Optional<DateTime>.FromNullable(lastStartedOnUtc),
|
||||
Optional<DateTime>.FromNullable(lastCompletedOnUtc));
|
||||
return createWithIdResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ScheduledJob"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ScheduledJob"/> instances.</returns>
|
||||
public List<ScheduledJob> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+41
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DailySchedule"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DailyScheduleFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="DailySchedule"/>.
|
||||
/// </summary>
|
||||
/// <param name="hour">Optional. The hour of the day at which the task runs.</param>
|
||||
/// <param name="minute">Optional. The minute of the hour at which the task runs.</param>
|
||||
/// <returns>The created <see cref="DailySchedule"/>.</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="DailySchedule"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DailySchedule"/> instances.</returns>
|
||||
public List<DailySchedule> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+38
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="IntervalSchedule"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class IntervalScheduleFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="IntervalSchedule"/>.
|
||||
/// </summary>
|
||||
/// <param name="intervalMinutes">Optional. The number of minutes between each execution.</param>
|
||||
/// <returns>The created <see cref="IntervalSchedule"/>.</returns>
|
||||
public IntervalSchedule Create(int? intervalMinutes = null)
|
||||
{
|
||||
Faker faker = new();
|
||||
return IntervalSchedule.Create(intervalMinutes ?? faker.Random.Int(1, 1440)).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="IntervalSchedule"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="IntervalSchedule"/> instances.</returns>
|
||||
public List<IntervalSchedule> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScheduledJobId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScheduledJobIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScheduledJobId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the scheduled job Id.</param>
|
||||
/// <returns>The created <see cref="ScheduledJobId"/>.</returns>
|
||||
public ScheduledJobId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return ScheduledJobId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ScheduledJobId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ScheduledJobId"/> instances.</returns>
|
||||
public List<ScheduledJobId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user