mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 23:11:10 +00:00
Adds the server-side theme repository and reworks the web theme engine onto it
This commit is contained in:
1 parent
85928f7c3c
commit
bf8faba24d
136 files changed
+6942
-1197
No files matched your search
-61
@@ -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);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -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()
|
||||
{
|
||||
|
||||
+41
-34
@@ -1,13 +1,13 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Configuration;
|
||||
using Lumina.Presentation.Web.Common.Primitives;
|
||||
using Lumina.Presentation.Web.Common.Validators;
|
||||
using Lumina.Presentation.Web.UnitTests.Common.Setup;
|
||||
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.Presentation.Web.UnitTests.Common.Validators;
|
||||
namespace Lumina.Infrastructure.UnitTests.Common.Validators;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ThemeEngineOptionsDtoValidator"/> class.
|
||||
@@ -17,6 +17,19 @@ 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()
|
||||
{
|
||||
@@ -24,23 +37,25 @@ public class ThemeEngineOptionsDtoValidatorTests
|
||||
ThemeEngineOptionsDto options = new() { StoragePath = string.Empty };
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(options);
|
||||
List<Error> result = _validator.Validate(options);
|
||||
|
||||
// Assert
|
||||
result.ShouldHaveValidationError(Error.Validation(description: "Theme storage path cannot be empty!"));
|
||||
Assert.Single(result);
|
||||
Assert.Equal(Errors.Configuration.ThemeStoragePathCannotBeEmpty.Description, result[0].Description);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenSettingsPathIsEmpty_ShouldHaveValidationError()
|
||||
public void Validate_WhenBundledThemesPathIsEmpty_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
ThemeEngineOptionsDto options = new() { SettingsPath = string.Empty };
|
||||
ThemeEngineOptionsDto options = new() { BundledThemesPath = string.Empty };
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(options);
|
||||
List<Error> result = _validator.Validate(options);
|
||||
|
||||
// Assert
|
||||
result.ShouldHaveValidationError(Error.Validation(description: "Theme settings path cannot be empty!"));
|
||||
Assert.Single(result);
|
||||
Assert.Equal(Errors.Configuration.ThemeBundledThemesPathCannotBeEmpty.Description, result[0].Description);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -50,10 +65,11 @@ public class ThemeEngineOptionsDtoValidatorTests
|
||||
ThemeEngineOptionsDto options = new() { DefaultThemeId = string.Empty };
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(options);
|
||||
List<Error> result = _validator.Validate(options);
|
||||
|
||||
// Assert
|
||||
result.ShouldHaveValidationError(Error.Validation(description: "Default theme Id cannot be empty!"));
|
||||
Assert.Single(result);
|
||||
Assert.Equal(Errors.Configuration.ThemeDefaultThemeIdCannotBeEmpty.Description, result[0].Description);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -65,10 +81,11 @@ public class ThemeEngineOptionsDtoValidatorTests
|
||||
ThemeEngineOptionsDto options = new() { MaxArchiveBytes = maxArchiveBytes };
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(options);
|
||||
List<Error> result = _validator.Validate(options);
|
||||
|
||||
// Assert
|
||||
result.ShouldHaveValidationError(Error.Validation(description: "Maximum archive size must be greater than 0!"));
|
||||
Assert.Single(result);
|
||||
Assert.Equal(Errors.Configuration.ThemeMaxArchiveBytesMustBePositive.Description, result[0].Description);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -80,10 +97,11 @@ public class ThemeEngineOptionsDtoValidatorTests
|
||||
ThemeEngineOptionsDto options = new() { MaxExpandedBytes = maxExpandedBytes };
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(options);
|
||||
List<Error> result = _validator.Validate(options);
|
||||
|
||||
// Assert
|
||||
result.ShouldHaveValidationError(Error.Validation(description: "Maximum expanded size must be greater than 0!"));
|
||||
Assert.Single(result);
|
||||
Assert.Equal(Errors.Configuration.ThemeMaxExpandedBytesMustBePositive.Description, result[0].Description);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -95,10 +113,11 @@ public class ThemeEngineOptionsDtoValidatorTests
|
||||
ThemeEngineOptionsDto options = new() { MaxSingleFileBytes = maxSingleFileBytes };
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(options);
|
||||
List<Error> result = _validator.Validate(options);
|
||||
|
||||
// Assert
|
||||
result.ShouldHaveValidationError(Error.Validation(description: "Maximum single file size must be greater than 0!"));
|
||||
Assert.Single(result);
|
||||
Assert.Equal(Errors.Configuration.ThemeMaxSingleFileBytesMustBePositive.Description, result[0].Description);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -110,22 +129,10 @@ public class ThemeEngineOptionsDtoValidatorTests
|
||||
ThemeEngineOptionsDto options = new() { MaxEntries = maxEntries };
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(options);
|
||||
List<Error> result = _validator.Validate(options);
|
||||
|
||||
// Assert
|
||||
result.ShouldHaveValidationError(Error.Validation(description: "Maximum entries count must be greater than 0!"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenOptionsAreValid_ShouldNotHaveAnyValidationErrors()
|
||||
{
|
||||
// Arrange
|
||||
ThemeEngineOptionsDto options = new();
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(options);
|
||||
|
||||
// Assert
|
||||
result.ShouldNotHaveAnyValidationErrors();
|
||||
Assert.Single(result);
|
||||
Assert.Equal(Errors.Configuration.ThemeMaxEntriesMustBePositive.Description, result[0].Description);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user