Hardens test assertions and adds missing test coverage.

This commit is contained in:
BinaryAlley committed 2026-08-18 08:28:16 -07:00
1 parent 6b86fd5805
commit 1189bbaf36
489 files changed
+39982 -512

No files matched your search

@@ -0,0 +1,67 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Plugins;
using Lumina.Domain.SharedKernel.Common.Enums.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Plugins;
/// <summary>
/// Fixture class for the <see cref="PluginResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PluginResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PluginResponse"/>.
/// </summary>
/// <param name="id">Optional. The Id of the plugin.</param>
/// <param name="name">Optional. The display name of the plugin.</param>
/// <param name="author">Optional. The author of the plugin.</param>
/// <param name="version">Optional. The version of the plugin.</param>
/// <param name="description">Optional. The description of the plugin.</param>
/// <param name="loadStatus">Optional. The load status of the plugin.</param>
/// <param name="loadError">Optional. The error message when the plugin failed to load.</param>
/// <param name="settings">Optional. The settings of the plugin.</param>
/// <returns>The created <see cref="PluginResponse"/>.</returns>
public PluginResponse Create(
Guid? id = null,
string? name = null,
string? author = null,
string? version = null,
string? description = null,
PluginLoadStatus? loadStatus = null,
string? loadError = null,
IReadOnlyDictionary<string, string>? settings = null)
{
return new PluginResponse(
id ?? Guid.NewGuid(),
name ?? _faker.Commerce.ProductName(),
author ?? _faker.Company.CompanyName(),
version ?? _faker.System.Semver(),
description ?? _faker.Lorem.Sentence(),
loadStatus ?? _faker.PickRandom<PluginLoadStatus>(),
loadError,
settings ?? new Dictionary<string, string>
{
[_faker.Lorem.Word()] = _faker.Lorem.Word()
}
);
}
/// <summary>
/// Creates a list of <see cref="PluginResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<PluginResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,54 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Plugins;
using Lumina.Domain.SharedKernel.Common.Enums.Plugins;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Plugins;
/// <summary>
/// Fixture class for the <see cref="PluginSettingDescriptorResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PluginSettingDescriptorResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PluginSettingDescriptorResponse"/>.
/// </summary>
/// <param name="key">Optional. The unique key of the setting.</param>
/// <param name="label">Optional. The display label of the setting.</param>
/// <param name="type">Optional. The type of the setting.</param>
/// <param name="defaultValue">Optional. The default value of the setting.</param>
/// <param name="allowedValues">Optional. The list of allowed values, when the setting is a selection.</param>
/// <returns>The created <see cref="PluginSettingDescriptorResponse"/>.</returns>
public PluginSettingDescriptorResponse Create(
string? key = null,
string? label = null,
PluginSettingType? type = null,
string? defaultValue = null,
IReadOnlyList<string>? allowedValues = null)
{
return new PluginSettingDescriptorResponse(
key ?? _faker.Lorem.Word(),
label ?? _faker.Lorem.Word(),
type ?? _faker.PickRandom<PluginSettingType>(),
defaultValue,
allowedValues ?? [_faker.Lorem.Word(), _faker.Lorem.Word()]
);
}
/// <summary>
/// Creates a list of <see cref="PluginSettingDescriptorResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<PluginSettingDescriptorResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,52 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.Plugins;
/// <summary>
/// Fixture class for the <see cref="PluginSettingsResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PluginSettingsResponseFixture
{
private readonly Faker _faker = new();
private readonly PluginSettingDescriptorResponseFixture _pluginSettingDescriptorResponseFixture = new();
/// <summary>
/// Creates a random valid <see cref="PluginSettingsResponse"/>.
/// </summary>
/// <param name="pluginId">Optional. The Id of the plugin.</param>
/// <param name="schema">Optional. The schema of the plugin settings.</param>
/// <param name="settings">Optional. The current values of the plugin settings.</param>
/// <returns>The created <see cref="PluginSettingsResponse"/>.</returns>
public PluginSettingsResponse Create(
Guid? pluginId = null,
IReadOnlyList<PluginSettingDescriptorResponse>? schema = null,
IReadOnlyDictionary<string, string>? settings = null)
{
return new PluginSettingsResponse(
pluginId ?? Guid.NewGuid(),
schema ?? _pluginSettingDescriptorResponseFixture.CreateMany(3),
settings ?? new Dictionary<string, string>
{
[_faker.Lorem.Word()] = _faker.Lorem.Word()
}
);
}
/// <summary>
/// Creates a list of <see cref="PluginSettingsResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<PluginSettingsResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}