mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 19:21:10 +00:00
Implements tests for commit f777af07cf
This commit is contained in:
1 parent
99fc721d8c
commit
54b468855a
54 files changed
+10681
-17
No files matched your search
+44
@@ -0,0 +1,44 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Commands.ClearConsumptionHistory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.ClearConsumptionHistory;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ClearConsumptionHistoryCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ClearConsumptionHistoryCommandFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ClearConsumptionHistoryCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="targetUserId">Optional. The Id of the user whose consumption history is cleared. Defaults to a random user Id.</param>
|
||||
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/> so that the current user is targeted.</param>
|
||||
/// <returns>The created <see cref="ClearConsumptionHistoryCommand"/>.</returns>
|
||||
public ClearConsumptionHistoryCommand Create(
|
||||
string? targetUserId = null,
|
||||
bool includeTargetUserId = true)
|
||||
{
|
||||
string? resolvedTargetUserId = includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null;
|
||||
|
||||
return new ClearConsumptionHistoryCommand(resolvedTargetUserId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ClearConsumptionHistoryCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ClearConsumptionHistoryCommand"/> instances.</returns>
|
||||
public List<ClearConsumptionHistoryCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Commands.ClearResumePoints;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.ClearResumePoints;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ClearResumePointsCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ClearResumePointsCommandFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ClearResumePointsCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="targetUserId">Optional. The Id of the user whose resume points are cleared. Defaults to a random user Id.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the deletion is restricted to. Defaults to a random library Id.</param>
|
||||
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/> so that the current user is targeted.</param>
|
||||
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/> so that every library is cleared.</param>
|
||||
/// <returns>The created <see cref="ClearResumePointsCommand"/>.</returns>
|
||||
public ClearResumePointsCommand Create(
|
||||
string? targetUserId = null,
|
||||
string? libraryId = null,
|
||||
bool includeTargetUserId = true,
|
||||
bool includeLibraryId = true)
|
||||
{
|
||||
string? resolvedTargetUserId = includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null;
|
||||
string? resolvedLibraryId = includeLibraryId ? libraryId ?? _faker.Random.Guid().ToString() : null;
|
||||
|
||||
return new ClearResumePointsCommand(resolvedTargetUserId, resolvedLibraryId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ClearResumePointsCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ClearResumePointsCommand"/> instances.</returns>
|
||||
public List<ClearResumePointsCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaConsumption.Commands.DeleteConsumptionRecord;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaConsumption.Commands.DeleteConsumptionRecord;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DeleteConsumptionRecordCommand"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeleteConsumptionRecordCommandFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="DeleteConsumptionRecordCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="consumptionRecordId">Optional. The Id of the consumption record to delete, taken from the route. Defaults to a random Id.</param>
|
||||
/// <param name="targetUserId">Optional. The Id of the user the record must belong to. Defaults to a random user Id.</param>
|
||||
/// <param name="includeConsumptionRecordId">Whether the consumption record Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeTargetUserId">Whether the target user Id should be included, or forced to <see langword="null"/> so that the current user is targeted.</param>
|
||||
/// <returns>The created <see cref="DeleteConsumptionRecordCommand"/>.</returns>
|
||||
public DeleteConsumptionRecordCommand Create(
|
||||
string? consumptionRecordId = null,
|
||||
string? targetUserId = null,
|
||||
bool includeConsumptionRecordId = true,
|
||||
bool includeTargetUserId = true)
|
||||
{
|
||||
string? resolvedConsumptionRecordId = includeConsumptionRecordId ? consumptionRecordId ?? _faker.Random.Guid().ToString() : null;
|
||||
string? resolvedTargetUserId = includeTargetUserId ? targetUserId ?? _faker.Random.Guid().ToString() : null;
|
||||
|
||||
return new DeleteConsumptionRecordCommand(resolvedConsumptionRecordId, resolvedTargetUserId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="DeleteConsumptionRecordCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DeleteConsumptionRecordCommand"/> instances.</returns>
|
||||
public List<DeleteConsumptionRecordCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user