mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 17:11:10 +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
+38
@@ -0,0 +1,38 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.Themes;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DeleteThemeRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeleteThemeRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="DeleteThemeRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="themeId">Optional. The manifest id of the theme to delete.</param>
|
||||
/// <returns>The created <see cref="DeleteThemeRequest"/>.</returns>
|
||||
public DeleteThemeRequest Create(string? themeId = null)
|
||||
{
|
||||
return new DeleteThemeRequest(themeId ?? _faker.Lorem.Slug(2));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="DeleteThemeRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<DeleteThemeRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.Themes;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetThemeArchiveRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetThemeArchiveRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetThemeArchiveRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="themeId">Optional. The manifest id of the theme.</param>
|
||||
/// <returns>The created <see cref="GetThemeArchiveRequest"/>.</returns>
|
||||
public GetThemeArchiveRequest Create(string? themeId = null)
|
||||
{
|
||||
return new GetThemeArchiveRequest(themeId ?? _faker.Lorem.Slug(2));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetThemeArchiveRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetThemeArchiveRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.Themes;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetThemeAssetRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetThemeAssetRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetThemeAssetRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="themeId">Optional. The manifest id of the theme.</param>
|
||||
/// <param name="assetPath">Optional. The asset path relative to the theme pack root.</param>
|
||||
/// <returns>The created <see cref="GetThemeAssetRequest"/>.</returns>
|
||||
public GetThemeAssetRequest Create(string? themeId = null, string? assetPath = null)
|
||||
{
|
||||
return new GetThemeAssetRequest(
|
||||
themeId ?? _faker.Lorem.Slug(2),
|
||||
assetPath ?? _faker.System.FilePath());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetThemeAssetRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetThemeAssetRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.Themes;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetThemeTemplateRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetThemeTemplateRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetThemeTemplateRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="themeId">Optional. The manifest id of the theme.</param>
|
||||
/// <param name="pageKey">Optional. The page key that selects the template.</param>
|
||||
/// <returns>The created <see cref="GetThemeTemplateRequest"/>.</returns>
|
||||
public GetThemeTemplateRequest Create(string? themeId = null, string? pageKey = null)
|
||||
{
|
||||
return new GetThemeTemplateRequest(
|
||||
themeId ?? _faker.Lorem.Slug(2),
|
||||
pageKey ?? _faker.Lorem.Word());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetThemeTemplateRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<GetThemeTemplateRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.Themes;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="SetCurrentThemeRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SetCurrentThemeRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="SetCurrentThemeRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="themeId">Optional. The manifest id of the theme to activate.</param>
|
||||
/// <returns>The created <see cref="SetCurrentThemeRequest"/>.</returns>
|
||||
public SetCurrentThemeRequest Create(string? themeId = null)
|
||||
{
|
||||
return new SetCurrentThemeRequest(themeId ?? _faker.Lorem.Slug(2));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="SetCurrentThemeRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<SetCurrentThemeRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Themes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ThemeArchiveResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ThemeArchiveResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ThemeArchiveResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Optional. The bytes of the ZIP archive.</param>
|
||||
/// <param name="fileName">Optional. The file name to expose when downloading the archive.</param>
|
||||
/// <param name="contentType">Optional. The MIME content type of the archive.</param>
|
||||
/// <returns>The created <see cref="ThemeArchiveResponse"/>.</returns>
|
||||
public ThemeArchiveResponse Create(byte[]? bytes = null, string? fileName = null, string? contentType = null)
|
||||
{
|
||||
return new ThemeArchiveResponse(
|
||||
bytes ?? Encoding.UTF8.GetBytes(_faker.Lorem.Paragraph()),
|
||||
fileName ?? $"{_faker.Lorem.Word()}.zip",
|
||||
contentType ?? _faker.System.MimeType());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ThemeArchiveResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ThemeArchiveResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Themes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ThemeAssetResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ThemeAssetResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ThemeAssetResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="bytes">Optional. The bytes of the asset file.</param>
|
||||
/// <param name="contentType">Optional. The MIME content type of the asset file.</param>
|
||||
/// <returns>The created <see cref="ThemeAssetResponse"/>.</returns>
|
||||
public ThemeAssetResponse Create(byte[]? bytes = null, string? contentType = null)
|
||||
{
|
||||
return new ThemeAssetResponse(
|
||||
bytes ?? Encoding.UTF8.GetBytes(_faker.Lorem.Paragraph()),
|
||||
contentType ?? _faker.System.MimeType());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ThemeAssetResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ThemeAssetResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Themes;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Themes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ThemeResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ThemeResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ThemeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the theme.</param>
|
||||
/// <param name="themeId">Optional. The manifest id of the theme.</param>
|
||||
/// <param name="name">Optional. The display name of the theme.</param>
|
||||
/// <param name="description">Optional. The description of the theme.</param>
|
||||
/// <param name="author">Optional. The author of the theme.</param>
|
||||
/// <param name="version">Optional. The version of the theme.</param>
|
||||
/// <param name="previewPath">Optional. The preview image path of the theme, or <see langword="null"/> when the theme has no preview.</param>
|
||||
/// <param name="includePreviewPath">Whether to set <paramref name="previewPath"/>, or <see langword="null"/> when <see langword="false"/>.</param>
|
||||
/// <param name="installSource">Optional. The source the theme was installed from.</param>
|
||||
/// <param name="isCurrent">Optional. Whether the theme is the currently active one.</param>
|
||||
/// <param name="includeIsCurrent">Whether to set <paramref name="isCurrent"/>, or <see langword="null"/> when <see langword="false"/>.</param>
|
||||
/// <param name="installedAtUtc">Optional. The UTC timestamp when the theme was installed.</param>
|
||||
/// <returns>The created <see cref="ThemeResponse"/>.</returns>
|
||||
public ThemeResponse Create(
|
||||
Guid? id = null,
|
||||
string? themeId = null,
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
string? author = null,
|
||||
string? version = null,
|
||||
string? previewPath = null,
|
||||
bool includePreviewPath = false,
|
||||
ThemeInstallSource? installSource = null,
|
||||
bool? isCurrent = null,
|
||||
bool includeIsCurrent = false,
|
||||
DateTime? installedAtUtc = null)
|
||||
{
|
||||
return new ThemeResponse(
|
||||
id ?? Guid.NewGuid(),
|
||||
themeId ?? _faker.Lorem.Slug(2),
|
||||
name ?? _faker.Commerce.ProductName(),
|
||||
description ?? _faker.Lorem.Sentence(),
|
||||
author ?? _faker.Name.FullName(),
|
||||
version ?? _faker.System.Semver(),
|
||||
includePreviewPath ? (previewPath ?? (_faker.Random.Bool() ? _faker.System.FilePath() : null)) : null,
|
||||
installSource ?? _faker.PickRandom<ThemeInstallSource>(),
|
||||
includeIsCurrent ? (isCurrent ?? (_faker.Random.Bool() ? true : null)) : null,
|
||||
installedAtUtc ?? _faker.Date.Recent().ToUniversalTime());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ThemeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ThemeResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Themes;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ThemeSettingsResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ThemeSettingsResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ThemeSettingsResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="maxArchiveBytes">Optional. The maximum allowed size of a theme archive, in bytes.</param>
|
||||
/// <param name="allowThemeScripts">Optional. Whether theme templates may contain script elements.</param>
|
||||
/// <param name="defaultThemeId">Optional. The identifier of the default theme.</param>
|
||||
/// <returns>The created <see cref="ThemeSettingsResponse"/>.</returns>
|
||||
public ThemeSettingsResponse Create(
|
||||
long? maxArchiveBytes = null,
|
||||
bool? allowThemeScripts = null,
|
||||
string? defaultThemeId = null)
|
||||
{
|
||||
return new ThemeSettingsResponse(
|
||||
maxArchiveBytes ?? _faker.Random.Long(1_000_000, 100_000_000),
|
||||
allowThemeScripts ?? _faker.Random.Bool(),
|
||||
defaultThemeId ?? _faker.Lorem.Slug(2));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ThemeSettingsResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ThemeSettingsResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Themes;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ThemeTemplateResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ThemeTemplateResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly ThemeResponseFixture _themeResponseFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ThemeTemplateResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="theme">Optional. The theme the template belongs to.</param>
|
||||
/// <param name="template">Optional. The sanitized content of the template.</param>
|
||||
/// <returns>The created <see cref="ThemeTemplateResponse"/>.</returns>
|
||||
public ThemeTemplateResponse Create(ThemeResponse? theme = null, string? template = null)
|
||||
{
|
||||
return new ThemeTemplateResponse(
|
||||
theme ?? _themeResponseFixture.Create(),
|
||||
template ?? _faker.Lorem.Paragraph());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ThemeTemplateResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ThemeTemplateResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user