mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 03:11:10 +00:00
Renames project paths from Lumina to Nemera
This commit is contained in:
1 parent
ce6fddb4c9
commit
0f659a4877
6450 files changed
No files matched your search
+61
@@ -0,0 +1,61 @@
|
||||
#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.Fixtures.Common.DTO.Configuration;
|
||||
using Lumina.Presentation.Web.UnitTests.Common.Setup;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.UnitTests.Common.Validators;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="EncryptionSettingsDtoValidator"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class EncryptionSettingsModelValidatorTests
|
||||
{
|
||||
private const string VALID_BASE64_KEY = "FLYO0QRo6u2VzoFOgNkkEwYNGtqhJ3QGZd7iAHNEJeM=";
|
||||
private readonly EncryptionSettingsDtoFixture _encryptionSettingsDtoFixture = new();
|
||||
private readonly EncryptionSettingsDtoValidator _validator = new();
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenSecretKeyIsEmpty_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
EncryptionSettingsDto settings = _encryptionSettingsDtoFixture.Create(secretKey: string.Empty);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(settings);
|
||||
|
||||
// Assert
|
||||
result.ShouldHaveValidationError(Error.Validation(description: "Encryption secret key cannot be empty!"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenSecretKeyIsNotBase64_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
EncryptionSettingsDto settings = _encryptionSettingsDtoFixture.Create(secretKey: "not-base64-key!");
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(settings);
|
||||
|
||||
// Assert
|
||||
result.ShouldHaveValidationError(Error.Validation(description: "Encryption secret key must be a base64 string!"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenSecretKeyIsValidBase64_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
EncryptionSettingsDto settings = _encryptionSettingsDtoFixture.Create(secretKey: VALID_BASE64_KEY);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(settings);
|
||||
|
||||
// Assert
|
||||
result.ShouldNotHaveAnyValidationErrors();
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
#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.Fixtures.Common.DTO.Configuration;
|
||||
using Lumina.Presentation.Web.UnitTests.Common.Setup;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.UnitTests.Common.Validators;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ServerConfigurationDtoValidator"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ServerConfigurationModelValidatorTests
|
||||
{
|
||||
private readonly ServerConfigurationDtoFixture _serverConfigurationDtoFixture = new();
|
||||
private readonly ServerConfigurationDtoValidator _validator = new();
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenBaseAddressIsEmpty_ShouldHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
ServerConfigurationDto configuration = _serverConfigurationDtoFixture.Create(apiVersion: '1', baseAddress: string.Empty, port: 5214);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(configuration);
|
||||
|
||||
// Assert
|
||||
result.ShouldHaveValidationError(Error.Validation(description: "Base address cannot be empty!"));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((ushort)0)] // Minimum allowed value.
|
||||
[InlineData((ushort)65535)] // Maximum allowed value.
|
||||
public void Validate_WhenPortIsAtBoundary_ShouldNotHaveValidationError(ushort port)
|
||||
{
|
||||
// Arrange
|
||||
ServerConfigurationDto configuration = _serverConfigurationDtoFixture.Create(apiVersion: '1', baseAddress: "http://localhost", port: port);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(configuration);
|
||||
|
||||
// Assert
|
||||
result.ShouldNotHaveAnyValidationErrors();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((char)0)] // Minimum allowed API version.
|
||||
[InlineData((char)255)] // Maximum allowed API version.
|
||||
public void Validate_WhenApiVersionIsAtBoundary_ShouldNotHaveValidationError(char apiVersion)
|
||||
{
|
||||
// Arrange
|
||||
ServerConfigurationDto configuration = _serverConfigurationDtoFixture.Create(apiVersion: apiVersion, baseAddress: "http://localhost", port: 5214);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(configuration);
|
||||
|
||||
// Assert
|
||||
result.ShouldNotHaveAnyValidationErrors();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_WhenConfigurationIsValid_ShouldNotHaveValidationError()
|
||||
{
|
||||
// Arrange
|
||||
ServerConfigurationDto configuration = _serverConfigurationDtoFixture.Create(apiVersion: '1', baseAddress: "http://localhost", port: 5214);
|
||||
|
||||
// Act
|
||||
List<Error> result = _validator.TestValidate(configuration);
|
||||
|
||||
// Assert
|
||||
result.ShouldNotHaveAnyValidationErrors();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user