mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 05:01:10 +00:00
139 lines
4.5 KiB
C#
139 lines
4.5 KiB
C#
#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);
|
|
}
|
|
}
|