mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 19:21: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
+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())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user