mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:13:42 +00:00
Adds the shared fixtures for the theming feature tests
This commit is contained in:
1 parent
07bc20a9e6
commit
9c83e5dfa7
34 files changed
+1710
No files matched your search
+63
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Infrastructure.Common.Models.DTO.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Fixtures.Common.Models.DTO.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ThemeEngineOptionsDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ThemeEngineOptionsDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ThemeEngineOptionsDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="storagePath">Optional directory where installed theme packs are stored.</param>
|
||||
/// <param name="bundledThemesPath">Optional directory where the shipped theme pack archives are located.</param>
|
||||
/// <param name="defaultThemeId">Optional identifier of the default theme.</param>
|
||||
/// <param name="maxArchiveBytes">Optional maximum size of an uploaded theme archive, in bytes.</param>
|
||||
/// <param name="maxExpandedBytes">Optional maximum total size of an extracted theme pack, in bytes.</param>
|
||||
/// <param name="maxSingleFileBytes">Optional maximum size of a single file within a theme pack, in bytes.</param>
|
||||
/// <param name="maxEntries">Optional maximum number of entries in a theme pack archive.</param>
|
||||
/// <param name="allowThemeScripts">Optional value indicating whether script elements are allowed.</param>
|
||||
/// <returns>A configured <see cref="ThemeEngineOptionsDto"/> instance.</returns>
|
||||
public ThemeEngineOptionsDto Create(
|
||||
string? storagePath = null,
|
||||
string? bundledThemesPath = null,
|
||||
string? defaultThemeId = null,
|
||||
long? maxArchiveBytes = null,
|
||||
long? maxExpandedBytes = null,
|
||||
long? maxSingleFileBytes = null,
|
||||
int? maxEntries = null,
|
||||
bool? allowThemeScripts = null)
|
||||
{
|
||||
Faker faker = new();
|
||||
return new ThemeEngineOptionsDto
|
||||
{
|
||||
StoragePath = storagePath ?? faker.System.DirectoryPath(),
|
||||
BundledThemesPath = bundledThemesPath ?? faker.System.DirectoryPath(),
|
||||
DefaultThemeId = defaultThemeId ?? faker.Lorem.Word(),
|
||||
MaxArchiveBytes = maxArchiveBytes ?? faker.Random.Long(1_000_000, 100_000_000),
|
||||
MaxExpandedBytes = maxExpandedBytes ?? faker.Random.Long(10_000_000, 500_000_000),
|
||||
MaxSingleFileBytes = maxSingleFileBytes ?? faker.Random.Long(1_000_000, 50_000_000),
|
||||
MaxEntries = maxEntries ?? faker.Random.Int(1, 1000),
|
||||
AllowThemeScripts = allowThemeScripts ?? faker.Random.Bool()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ThemeEngineOptionsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ThemeEngineOptionsDto"/> instances.</returns>
|
||||
public List<ThemeEngineOptionsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user