mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 06:11:10 +00:00
78 lines
3.8 KiB
C#
78 lines
3.8 KiB
C#
#region ========================================================================= USING =====================================================================================
|
|
using Bogus;
|
|
using Lumina.Presentation.Web.Common.DTO.Themes;
|
|
using Lumina.Presentation.Web.Common.Enums.Themes;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
#endregion
|
|
|
|
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
|
|
|
|
/// <summary>
|
|
/// Fixture class for generating <see cref="ThemeResponseDto"/> test data.
|
|
/// </summary>
|
|
[ExcludeFromCodeCoverage]
|
|
public class ThemeResponseDtoFixture
|
|
{
|
|
private readonly Faker _faker = new();
|
|
|
|
/// <summary>
|
|
/// Creates a new <see cref="ThemeResponseDto"/> instance with randomized test data.
|
|
/// </summary>
|
|
/// <param name="id">Optional database identifier of the theme.</param>
|
|
/// <param name="themeId">Optional manifest id of the theme.</param>
|
|
/// <param name="name">Optional display name of the theme.</param>
|
|
/// <param name="description">Optional description of the theme.</param>
|
|
/// <param name="author">Optional author of the theme.</param>
|
|
/// <param name="version">Optional semantic version of the theme.</param>
|
|
/// <param name="previewPath">Optional preview image path of the theme, or <see langword="null"/> when the theme has no preview.</param>
|
|
/// <param name="installSource">Optional source the theme was installed from.</param>
|
|
/// <param name="isCurrent">Optional value indicating whether the theme is the active one.</param>
|
|
/// <param name="installedAtUtc">Optional UTC timestamp at which the theme was installed.</param>
|
|
/// <param name="isDeleted">Optional value indicating whether the theme was deleted by the user.</param>
|
|
/// <param name="includePreviewPath">Whether the preview path should be included, or forced to <see langword="null"/>.</param>
|
|
/// <param name="includeIsCurrent">Whether the currently active flag should be included, or forced to <see langword="null"/>.</param>
|
|
/// <returns>A configured <see cref="ThemeResponseDto"/> instance.</returns>
|
|
public ThemeResponseDto Create(
|
|
Guid? id = null,
|
|
string? themeId = null,
|
|
string? name = null,
|
|
string? description = null,
|
|
string? author = null,
|
|
string? version = null,
|
|
string? previewPath = null,
|
|
ThemeInstallSource? installSource = null,
|
|
bool? isCurrent = null,
|
|
DateTime? installedAtUtc = null,
|
|
bool? isDeleted = null,
|
|
bool includePreviewPath = false,
|
|
bool includeIsCurrent = false)
|
|
{
|
|
return new ThemeResponseDto(
|
|
Id: id ?? Guid.NewGuid(),
|
|
ThemeId: themeId ?? _faker.Lorem.Word(),
|
|
Name: name ?? _faker.Commerce.ProductName(),
|
|
Description: description ?? _faker.Lorem.Sentence(),
|
|
Author: author ?? _faker.Name.FullName(),
|
|
Version: version ?? _faker.System.Semver(),
|
|
PreviewPath: includePreviewPath ? (previewPath ?? (_faker.Random.Bool() ? _faker.System.FilePath() : null)) : null,
|
|
InstallSource: installSource ?? ThemeInstallSource.Uploaded,
|
|
IsCurrent: includeIsCurrent ? (isCurrent ?? (_faker.Random.Bool() ? true : null)) : null,
|
|
InstalledAtUtc: installedAtUtc ?? _faker.Date.Recent(),
|
|
IsDeleted: isDeleted ?? _faker.Random.Bool()
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates multiple <see cref="ThemeResponseDto"/> instances with randomized test data.
|
|
/// </summary>
|
|
/// <param name="count">Number of instances to create.</param>
|
|
/// <returns>List of configured <see cref="ThemeResponseDto"/> instances.</returns>
|
|
public List<ThemeResponseDto> CreateMany(int count = 3)
|
|
{
|
|
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
|
}
|
|
}
|