Adds the server-side theme repository and reworks the web theme engine onto it

This commit is contained in:
BinaryAlley committed 2026-08-19 22:50:07 -07:00
1 parent 85928f7c3c
commit bf8faba24d
136 files changed
+6942 -1197

No files matched your search

@@ -1,61 +0,0 @@
#region ========================================================================= USING =====================================================================================
using AutoFixture;
using AutoFixture.AutoNSubstitute;
using Lumina.Domain.Common.Primitives;
using Lumina.Infrastructure.Common.Errors;
using Lumina.Infrastructure.Common.Models.DTO.Configuration;
using Lumina.Infrastructure.Common.Validators;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Infrastructure.UnitTests.Common.Validators;
/// <summary>
/// Contains unit tests for the <see cref="CommonSettingsDtoValidator"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class CommonSettingsDtoValidatorTests
{
private readonly CommonSettingsDtoValidator _validator = new();
private readonly IFixture _fixture;
/// <summary>
/// Initializes a new instance of the <see cref="CommonSettingsDtoValidatorTests"/> class.
/// </summary>
public CommonSettingsDtoValidatorTests()
{
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
}
[Fact]
public void Validate_WhenThemeProvided_ShouldNotHaveValidationError()
{
// Arrange
CommonSettingsDto model = _fixture.Build<CommonSettingsDto>()
.With(x => x.Theme, "Dark")
.Create();
// Act
List<Error> result = _validator.Validate(model);
// Assert
Assert.Empty(result);
}
[Fact]
public void Validate_WhenThemeNotProvided_ShouldNotHaveValidationError()
{
// Arrange
CommonSettingsDto model = _fixture.Build<CommonSettingsDto>()
.With(x => x.Theme, string.Empty)
.Create();
// Act
List<Error> result = _validator.Validate(model);
// Assert
Assert.Single(result);
Assert.Equal(Errors.Configuration.ApplicationThemeCannotBeEmpty.Description, result[0].Description);
}
}
@@ -12,7 +12,7 @@ using System.Diagnostics.CodeAnalysis;
namespace Lumina.Infrastructure.UnitTests.Common.Validators;
/// <summary>
/// Contains unit tests for the <see cref="CommonSettingsDtoValidator"/> class.
/// Contains unit tests for the <see cref="DatabaseSettingsDtoValidator"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class DatabaseSettingsDtoValidatorTests
@@ -21,7 +21,7 @@ public class DatabaseSettingsDtoValidatorTests
private readonly IFixture _fixture;
/// <summary>
/// Initializes a new instance of the <see cref="CommonSettingsDtoValidatorTests"/> class.
/// Initializes a new instance of the <see cref="DatabaseSettingsDtoValidatorTests"/> class.
/// </summary>
public DatabaseSettingsDtoValidatorTests()
{
@@ -0,0 +1,138 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Primitives;
using Lumina.Infrastructure.Common.Errors;
using Lumina.Infrastructure.Common.Models.DTO.Configuration;
using Lumina.Infrastructure.Common.Validators;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Infrastructure.UnitTests.Common.Validators;
/// <summary>
/// Contains unit tests for the <see cref="ThemeEngineOptionsDtoValidator"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class ThemeEngineOptionsDtoValidatorTests
{
private readonly ThemeEngineOptionsDtoValidator _validator = new();
[Fact]
public void Validate_WhenAllPropertiesValid_ShouldNotHaveValidationError()
{
// Arrange
ThemeEngineOptionsDto options = new();
// Act
List<Error> result = _validator.Validate(options);
// Assert
Assert.Empty(result);
}
[Fact]
public void Validate_WhenStoragePathIsEmpty_ShouldHaveValidationError()
{
// Arrange
ThemeEngineOptionsDto options = new() { StoragePath = string.Empty };
// Act
List<Error> result = _validator.Validate(options);
// Assert
Assert.Single(result);
Assert.Equal(Errors.Configuration.ThemeStoragePathCannotBeEmpty.Description, result[0].Description);
}
[Fact]
public void Validate_WhenBundledThemesPathIsEmpty_ShouldHaveValidationError()
{
// Arrange
ThemeEngineOptionsDto options = new() { BundledThemesPath = string.Empty };
// Act
List<Error> result = _validator.Validate(options);
// Assert
Assert.Single(result);
Assert.Equal(Errors.Configuration.ThemeBundledThemesPathCannotBeEmpty.Description, result[0].Description);
}
[Fact]
public void Validate_WhenDefaultThemeIdIsEmpty_ShouldHaveValidationError()
{
// Arrange
ThemeEngineOptionsDto options = new() { DefaultThemeId = string.Empty };
// Act
List<Error> result = _validator.Validate(options);
// Assert
Assert.Single(result);
Assert.Equal(Errors.Configuration.ThemeDefaultThemeIdCannotBeEmpty.Description, result[0].Description);
}
[Theory]
[InlineData(0L)] // zero, not positive
[InlineData(-1L)] // negative
public void Validate_WhenMaxArchiveBytesIsNotPositive_ShouldHaveValidationError(long maxArchiveBytes)
{
// Arrange
ThemeEngineOptionsDto options = new() { MaxArchiveBytes = maxArchiveBytes };
// Act
List<Error> result = _validator.Validate(options);
// Assert
Assert.Single(result);
Assert.Equal(Errors.Configuration.ThemeMaxArchiveBytesMustBePositive.Description, result[0].Description);
}
[Theory]
[InlineData(0L)] // zero, not positive
[InlineData(-1L)] // negative
public void Validate_WhenMaxExpandedBytesIsNotPositive_ShouldHaveValidationError(long maxExpandedBytes)
{
// Arrange
ThemeEngineOptionsDto options = new() { MaxExpandedBytes = maxExpandedBytes };
// Act
List<Error> result = _validator.Validate(options);
// Assert
Assert.Single(result);
Assert.Equal(Errors.Configuration.ThemeMaxExpandedBytesMustBePositive.Description, result[0].Description);
}
[Theory]
[InlineData(0L)] // zero, not positive
[InlineData(-1L)] // negative
public void Validate_WhenMaxSingleFileBytesIsNotPositive_ShouldHaveValidationError(long maxSingleFileBytes)
{
// Arrange
ThemeEngineOptionsDto options = new() { MaxSingleFileBytes = maxSingleFileBytes };
// Act
List<Error> result = _validator.Validate(options);
// Assert
Assert.Single(result);
Assert.Equal(Errors.Configuration.ThemeMaxSingleFileBytesMustBePositive.Description, result[0].Description);
}
[Theory]
[InlineData(0)] // zero, not positive
[InlineData(-1)] // negative
public void Validate_WhenMaxEntriesIsNotPositive_ShouldHaveValidationError(int maxEntries)
{
// Arrange
ThemeEngineOptionsDto options = new() { MaxEntries = maxEntries };
// Act
List<Error> result = _validator.Validate(options);
// Assert
Assert.Single(result);
Assert.Equal(Errors.Configuration.ThemeMaxEntriesMustBePositive.Description, result[0].Description);
}
}