mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 06: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
@@ -0,0 +1,140 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using DomainErrors = Lumina.Domain.Common.Errors.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Fixtures.Common.ValueObjects.Metadata;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.UnitTests.Common.ValueObjects.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="Genre"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GenreTests
|
||||
{
|
||||
private readonly GenreFixture _genreFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalledWithValidName_ShouldCreateGenreWithTrimmedLowercaseInvariantName()
|
||||
{
|
||||
// Act
|
||||
Result<Genre> result = Genre.Create(" Science FICTION ");
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal("science fiction", result.Value.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(" Science FICTION ", "science fiction")] // ASCII mixed case with surrounding whitespace.
|
||||
[InlineData("ÉLECTRO", "électro")] // Non-ASCII Latin uppercase.
|
||||
[InlineData("ЖАНР", "жанр")] // Non-Latin uppercase.
|
||||
[InlineData(" indie ", "indie")] // Surrounding whitespace.
|
||||
public void Create_WhenNameHasMixedCaseOrSurroundingWhitespace_ShouldNormalizeIt(string name, string expectedName)
|
||||
{
|
||||
// Act
|
||||
Result<Genre> result = Genre.Create(name);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(expectedName, result.Value.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCurrentCultureIsTurkish_ShouldLowercaseWithTheInvariantCulture()
|
||||
{
|
||||
CultureInfo originalCulture = CultureInfo.CurrentCulture;
|
||||
CultureInfo originalUiCulture = CultureInfo.CurrentUICulture;
|
||||
try
|
||||
{
|
||||
// Arrange
|
||||
CultureInfo.CurrentCulture = new CultureInfo("tr-TR");
|
||||
CultureInfo.CurrentUICulture = new CultureInfo("tr-TR");
|
||||
|
||||
// Act
|
||||
Result<Genre> result = Genre.Create("INDIE");
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
// The Turkish culture maps an uppercase I to a dotless lowercase i, so this proves the invariant culture is used.
|
||||
Assert.Equal("indie", result.Value.Name);
|
||||
}
|
||||
finally
|
||||
{
|
||||
CultureInfo.CurrentCulture = originalCulture;
|
||||
CultureInfo.CurrentUICulture = originalUiCulture;
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // Null name.
|
||||
[InlineData("")] // Empty name.
|
||||
[InlineData(" ")] // Whitespace name.
|
||||
public void Create_WhenNameIsNullOrWhitespace_ShouldReturnError(string? name)
|
||||
{
|
||||
// Act
|
||||
Result<Genre> result = Genre.Create(name!);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(DomainErrors.Metadata.GenreNameCannotBeEmpty, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equals_WithSameName_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
Genre firstGenre = _genreFixture.Create(name: "Science Fiction");
|
||||
Genre secondGenre = _genreFixture.Create(name: "Science Fiction");
|
||||
|
||||
// Act
|
||||
bool result = firstGenre.Equals(secondGenre);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equals_WithNamesDifferingOnlyByCasing_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
Genre firstGenre = _genreFixture.Create(name: "Science Fiction");
|
||||
Genre secondGenre = _genreFixture.Create(name: "science fiction");
|
||||
|
||||
// Act
|
||||
bool result = firstGenre.Equals(secondGenre);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equals_WithDifferentName_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
Genre firstGenre = _genreFixture.Create(name: "Science Fiction");
|
||||
Genre secondGenre = _genreFixture.Create(name: "Fantasy");
|
||||
|
||||
// Act
|
||||
bool result = firstGenre.Equals(secondGenre);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToString_WhenCalled_ShouldReturnName()
|
||||
{
|
||||
// Arrange
|
||||
Genre genre = _genreFixture.Create(name: "Science Fiction");
|
||||
|
||||
// Act
|
||||
string result = genre.ToString();
|
||||
|
||||
// Assert
|
||||
Assert.Equal("science fiction", result);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user