mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 08: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
+144
@@ -0,0 +1,144 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.Common;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GenreDtoMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GenreDtoMappingTests
|
||||
{
|
||||
private readonly GenreDtoFixture _genreDtoFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToDomainValueObject_WhenMappingValidGenreDto_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GenreDto genreDto = _genreDtoFixture.Create(name: "Rock");
|
||||
|
||||
// Act
|
||||
Result<Genre> result = genreDto.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal("rock", result.Value.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Rock")]
|
||||
[InlineData("Jazz")]
|
||||
[InlineData("Classical")]
|
||||
[InlineData("Pop")]
|
||||
public void ToDomainValueObject_WhenMappingDifferentValidGenreDtos_ShouldMapCorrectly(string name)
|
||||
{
|
||||
// Arrange
|
||||
GenreDto genreDto = _genreDtoFixture.Create(name: name);
|
||||
|
||||
// Act
|
||||
Result<Genre> result = genreDto.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(name.ToLowerInvariant(), result.Value.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainValueObject_WhenGenreNameHasSurroundingWhitespaceAndMixedCase_ShouldStoreTheTrimmedLowercaseInvariantName()
|
||||
{
|
||||
// Arrange
|
||||
GenreDto genreDto = _genreDtoFixture.Create(name: " ÉLECTRO ");
|
||||
|
||||
// Act
|
||||
Result<Genre> result = genreDto.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal("électro", result.Value.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData(null)]
|
||||
public void ToDomainValueObject_WhenMappingInvalidGenreDto_ShouldReturnError(string? invalidName)
|
||||
{
|
||||
// Arrange
|
||||
GenreDto genreDto = _genreDtoFixture.Create(name: invalidName, includeName: invalidName is not null);
|
||||
|
||||
// Act
|
||||
Result<Genre> result = genreDto.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainModels_WhenMappingMultipleValidGenreDtos_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<GenreDto> genreDtos =
|
||||
[
|
||||
_genreDtoFixture.Create(name: "Rock"),
|
||||
_genreDtoFixture.Create(name: "Jazz"),
|
||||
_genreDtoFixture.Create(name: "Classical"),
|
||||
_genreDtoFixture.Create(name: "Pop")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<Result<Genre>> results = genreDtos.ToDomainValueObjects();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(genreDtos.Count, results.Count());
|
||||
|
||||
List<Result<Genre>> resultList = results.ToList();
|
||||
for (int i = 0; i < genreDtos.Count; i++)
|
||||
{
|
||||
Assert.False(resultList[i].IsFailure);
|
||||
Assert.Equal(genreDtos[i].Name!.ToLowerInvariant(), resultList[i].Value.Name);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainModels_WhenMappingMixedValidAndInvalidGenreDtos_ShouldReturnMixedResults()
|
||||
{
|
||||
// Arrange
|
||||
List<GenreDto> genreDtos =
|
||||
[
|
||||
_genreDtoFixture.Create(name: "Rock"),
|
||||
_genreDtoFixture.Create(name: ""),
|
||||
_genreDtoFixture.Create(name: "Jazz"),
|
||||
_genreDtoFixture.Create(name: " ")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<Result<Genre>> results = genreDtos.ToDomainValueObjects();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(genreDtos.Count, results.Count());
|
||||
|
||||
List<Result<Genre>> resultList = results.ToList();
|
||||
Assert.False(resultList[0].IsFailure);
|
||||
Assert.Equal("rock", resultList[0].Value.Name);
|
||||
|
||||
Assert.True(resultList[1].IsFailure);
|
||||
|
||||
Assert.False(resultList[2].IsFailure);
|
||||
Assert.Equal("jazz", resultList[2].Value.Name);
|
||||
|
||||
Assert.True(resultList[3].IsFailure);
|
||||
}
|
||||
}
|
||||
+169
@@ -0,0 +1,169 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GenreEntityMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GenreEntityMappingTests
|
||||
{
|
||||
private readonly GenreEntityFixture _genreEntityFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToResponse_WhenMappingValidGenreEntity_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GenreEntity entity = _genreEntityFixture.Create(name: "Fiction");
|
||||
|
||||
// Act
|
||||
GenreDto result = entity.ToResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(entity.Name, result.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Fiction")]
|
||||
[InlineData("Science Fiction")]
|
||||
[InlineData("Mystery")]
|
||||
[InlineData("Romance")]
|
||||
public void ToResponse_WhenMappingDifferentValidGenreEntities_ShouldMapCorrectly(string name)
|
||||
{
|
||||
// Arrange
|
||||
GenreEntity entity = _genreEntityFixture.Create(name: name);
|
||||
|
||||
// Act
|
||||
GenreDto result = entity.ToResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(entity.Name, result.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData(null)]
|
||||
public void ToResponse_WhenMappingInvalidGenreEntity_ShouldMapToDefault(string? invalidName)
|
||||
{
|
||||
// Arrange
|
||||
GenreEntity entity = _genreEntityFixture.Create(name: invalidName, includeName: invalidName is not null);
|
||||
|
||||
// Act
|
||||
GenreDto result = entity.ToResponse();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(invalidName, result.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainValueObject_WhenMappingValidGenreEntity_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GenreEntity entity = _genreEntityFixture.Create(name: "Fiction");
|
||||
|
||||
// Act
|
||||
Result<Genre> result = entity.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal("fiction", result.Value.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainValueObject_WhenGenreNameHasSurroundingWhitespaceAndMixedCase_ShouldStoreTheTrimmedLowercaseInvariantName()
|
||||
{
|
||||
// Arrange
|
||||
GenreEntity entity = _genreEntityFixture.Create(name: " ÉLECTRO ");
|
||||
|
||||
// Act
|
||||
Result<Genre> result = entity.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal("électro", result.Value.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData(null)]
|
||||
public void ToDomainValueObject_WhenMappingInvalidGenreEntity_ShouldMapToDefault(string? invalidName)
|
||||
{
|
||||
// Arrange
|
||||
GenreEntity entity = _genreEntityFixture.Create(name: invalidName, includeName: invalidName is not null);
|
||||
|
||||
// Act
|
||||
Result<Genre> result = entity.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Metadata.GenreNameCannotBeEmpty, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainValueObjects_WhenMappingMultipleValidGenreEntities_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<GenreEntity> entities =
|
||||
[
|
||||
_genreEntityFixture.Create(name: "Fiction"),
|
||||
_genreEntityFixture.Create(name: "Mystery"),
|
||||
_genreEntityFixture.Create(name: "Romance"),
|
||||
_genreEntityFixture.Create(name: "Thriller")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<Result<Genre>> results = entities.ToDomainValueObjects();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(entities.Count, results.Count());
|
||||
|
||||
List<Result<Genre>> resultList = [.. results];
|
||||
for (int i = 0; i < entities.Count; i++)
|
||||
{
|
||||
Assert.False(resultList[i].IsFailure);
|
||||
Assert.Equal(entities[i].Name!.ToLowerInvariant(), resultList[i].Value.Name);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToResponses_WhenMappingMultipleValidGenreEntities_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<GenreEntity> entities =
|
||||
[
|
||||
_genreEntityFixture.Create(name: "Fiction"),
|
||||
_genreEntityFixture.Create(name: "Mystery"),
|
||||
_genreEntityFixture.Create(name: "Romance"),
|
||||
_genreEntityFixture.Create(name: "Thriller")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<GenreDto> results = entities.ToResponses();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(entities.Count, results.Count());
|
||||
|
||||
List<GenreDto> resultList = [.. results];
|
||||
for (int i = 0; i < entities.Count; i++)
|
||||
Assert.Equal(entities[i].Name, resultList[i].Name);
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Fixtures.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GenreMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GenreMappingTests
|
||||
{
|
||||
private readonly GenreFixture _genreFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToRepositoryEntity_WhenMappingGenre_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
Genre genre = _genreFixture.Create("Rock");
|
||||
|
||||
// Act
|
||||
GenreEntity result = genre.ToRepositoryEntity();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(genre.Name, result.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Rock")]
|
||||
[InlineData("Jazz")]
|
||||
[InlineData("Classical")]
|
||||
[InlineData("Pop")]
|
||||
public void ToRepositoryEntity_WhenMappingDifferentGenres_ShouldMapCorrectly(string name)
|
||||
{
|
||||
// Arrange
|
||||
Genre genre = _genreFixture.Create(name);
|
||||
|
||||
// Act
|
||||
GenreEntity result = genre.ToRepositoryEntity();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(genre.Name, result.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToRepositoryEntities_WhenMappingMultipleGenres_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<Genre> genres =
|
||||
[
|
||||
_genreFixture.Create("Rock"),
|
||||
_genreFixture.Create("Jazz"),
|
||||
_genreFixture.Create("Classical"),
|
||||
_genreFixture.Create("Pop")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<GenreEntity> results = genres.ToRepositoryEntities();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(genres.Count, results.Count());
|
||||
List<GenreEntity> resultList = results.ToList();
|
||||
for (int i = 0; i < genres.Count; i++)
|
||||
Assert.Equal(genres[i].Name, resultList[i].Name);
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.Common;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="LanguageInfoDtoMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LanguageInfoDtoMappingTests
|
||||
{
|
||||
private readonly LanguageInfoDtoFixture _languageInfoDtoFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToDomainValueObject_WhenMappingCompleteLanguageInfoDto_ShouldMapAllPropertiesCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
LanguageInfoDto dto = _languageInfoDtoFixture.Create(languageCode: "EN", languageName: "English", nativeName: "English");
|
||||
|
||||
// Act
|
||||
Result<LanguageInfo> result = dto.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal("en", result.Value.LanguageCode);
|
||||
Assert.Equal(dto.LanguageName, result.Value.LanguageName);
|
||||
Assert.True(result.Value.NativeName.HasValue);
|
||||
Assert.Equal(dto.NativeName, result.Value.NativeName.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainValueObject_WhenNativeNameIsMissing_ShouldMapWithoutNativeName()
|
||||
{
|
||||
// Arrange
|
||||
LanguageInfoDto dto = _languageInfoDtoFixture.Create(includeNativeName: false);
|
||||
|
||||
// Act
|
||||
Result<LanguageInfo> result = dto.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(dto.LanguageCode!.ToLowerInvariant(), result.Value.LanguageCode);
|
||||
Assert.Equal(dto.LanguageName, result.Value.LanguageName);
|
||||
Assert.False(result.Value.NativeName.HasValue);
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.Common;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ReleaseInfoDtoMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReleaseInfoDtoMappingTests
|
||||
{
|
||||
private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToDomainValueObject_WhenMappingCompleteReleaseInfoDto_ShouldMapAllPropertiesCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
ReleaseInfoDto dto = _releaseInfoDtoFixture.Create(
|
||||
originalReleaseDate: new DateOnly(2000, 1, 1),
|
||||
originalReleaseYear: 2000,
|
||||
reReleaseDate: new DateOnly(2010, 1, 1),
|
||||
reReleaseYear: 2010,
|
||||
releaseCountry: ReleaseCountry.AD,
|
||||
releaseVersion: "Director's Cut");
|
||||
|
||||
// Act
|
||||
Result<ReleaseInfo> result = dto.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.True(result.Value.OriginalReleaseDate.HasValue);
|
||||
Assert.Equal(dto.OriginalReleaseDate!.Value, result.Value.OriginalReleaseDate.Value);
|
||||
Assert.True(result.Value.OriginalReleaseYear.HasValue);
|
||||
Assert.Equal(dto.OriginalReleaseYear!.Value, result.Value.OriginalReleaseYear.Value);
|
||||
Assert.True(result.Value.ReReleaseDate.HasValue);
|
||||
Assert.Equal(dto.ReReleaseDate!.Value, result.Value.ReReleaseDate.Value);
|
||||
Assert.True(result.Value.ReReleaseYear.HasValue);
|
||||
Assert.Equal(dto.ReReleaseYear!.Value, result.Value.ReReleaseYear.Value);
|
||||
Assert.True(result.Value.ReleaseCountry.HasValue);
|
||||
Assert.Equal(dto.ReleaseCountry!.Value, result.Value.ReleaseCountry.Value);
|
||||
Assert.True(result.Value.ReleaseVersion.HasValue);
|
||||
Assert.Equal(dto.ReleaseVersion, result.Value.ReleaseVersion.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainValueObject_WhenOptionalValuesAreMissing_ShouldMapWithoutOptionalValues()
|
||||
{
|
||||
// Arrange
|
||||
ReleaseInfoDto dto = _releaseInfoDtoFixture.Create();
|
||||
|
||||
// Act
|
||||
Result<ReleaseInfo> result = dto.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.False(result.Value.OriginalReleaseDate.HasValue);
|
||||
Assert.False(result.Value.OriginalReleaseYear.HasValue);
|
||||
Assert.False(result.Value.ReReleaseDate.HasValue);
|
||||
Assert.False(result.Value.ReReleaseYear.HasValue);
|
||||
Assert.False(result.Value.ReleaseCountry.HasValue);
|
||||
Assert.False(result.Value.ReleaseVersion.HasValue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainValueObject_WhenOriginalReleaseDateAndYearDoNotMatch_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
ReleaseInfoDto dto = _releaseInfoDtoFixture.Create(
|
||||
originalReleaseDate: new DateOnly(2025, 1, 1),
|
||||
originalReleaseYear: 2024);
|
||||
|
||||
// Act
|
||||
Result<ReleaseInfo> result = dto.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainValueObject_WhenReReleaseDateAndYearDoNotMatch_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
ReleaseInfoDto dto = _releaseInfoDtoFixture.Create(
|
||||
reReleaseDate: new DateOnly(2025, 1, 1),
|
||||
reReleaseYear: 2024);
|
||||
|
||||
// Act
|
||||
Result<ReleaseInfo> result = dto.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
}
|
||||
}
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.Common;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="TagDtoMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TagDtoMappingTests
|
||||
{
|
||||
private readonly TagDtoFixture _tagDtoFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToDomainValueObject_WhenMappingValidTagDto_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
TagDto tagDto = _tagDtoFixture.Create(name: "Indie");
|
||||
|
||||
// Act
|
||||
Result<Tag> result = tagDto.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal("indie", result.Value.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Indie")]
|
||||
[InlineData("Electronic")]
|
||||
[InlineData("Instrumental")]
|
||||
[InlineData("Live")]
|
||||
[InlineData("Acoustic")]
|
||||
public void ToDomainValueObject_WhenMappingDifferentValidTagDtos_ShouldMapCorrectly(string name)
|
||||
{
|
||||
// Arrange
|
||||
TagDto tagDto = _tagDtoFixture.Create(name: name);
|
||||
|
||||
// Act
|
||||
Result<Tag> result = tagDto.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal(name.ToLowerInvariant(), result.Value.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainValueObject_WhenTagNameHasSurroundingWhitespaceAndMixedCase_ShouldStoreTheTrimmedLowercaseInvariantName()
|
||||
{
|
||||
// Arrange
|
||||
TagDto tagDto = _tagDtoFixture.Create(name: " InDiE ");
|
||||
|
||||
// Act
|
||||
Result<Tag> result = tagDto.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal("indie", result.Value.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData(null)]
|
||||
public void ToDomainValueObject_WhenMappingInvalidTagDto_ShouldReturnError(string? invalidName)
|
||||
{
|
||||
// Arrange
|
||||
TagDto tagDto = _tagDtoFixture.Create(name: invalidName, includeName: invalidName is not null);
|
||||
|
||||
// Act
|
||||
Result<Tag> result = tagDto.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainModels_WhenMappingMultipleValidTagDtos_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<TagDto> tagDtos =
|
||||
[
|
||||
_tagDtoFixture.Create(name: "Indie"),
|
||||
_tagDtoFixture.Create(name: "Electronic"),
|
||||
_tagDtoFixture.Create(name: "Instrumental"),
|
||||
_tagDtoFixture.Create(name: "Live")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<Result<Tag>> results = tagDtos.ToDomainValueObjects();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(tagDtos.Count, results.Count());
|
||||
|
||||
List<Result<Tag>> resultList = [.. results];
|
||||
for (int i = 0; i < tagDtos.Count; i++)
|
||||
{
|
||||
Assert.False(resultList[i].IsFailure);
|
||||
Assert.Equal(tagDtos[i].Name!.ToLowerInvariant(), resultList[i].Value.Name);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainModels_WhenMappingMixedValidAndInvalidTagDtos_ShouldReturnMixedResults()
|
||||
{
|
||||
// Arrange
|
||||
List<TagDto> tagDtos =
|
||||
[
|
||||
_tagDtoFixture.Create(name: "Indie"),
|
||||
_tagDtoFixture.Create(name: ""),
|
||||
_tagDtoFixture.Create(name: "Electronic"),
|
||||
_tagDtoFixture.Create(name: " ")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<Result<Tag>> results = tagDtos.ToDomainValueObjects();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(tagDtos.Count, results.Count());
|
||||
|
||||
List<Result<Tag>> resultList = [.. results];
|
||||
Assert.False(resultList[0].IsFailure);
|
||||
Assert.Equal("indie", resultList[0].Value.Name);
|
||||
|
||||
Assert.True(resultList[1].IsFailure);
|
||||
|
||||
Assert.False(resultList[2].IsFailure);
|
||||
Assert.Equal("electronic", resultList[2].Value.Name);
|
||||
|
||||
Assert.True(resultList[3].IsFailure);
|
||||
}
|
||||
}
|
||||
+169
@@ -0,0 +1,169 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="TagEntityMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TagEntityMappingTests
|
||||
{
|
||||
private readonly TagEntityFixture _tagEntityFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToResponse_WhenMappingValidTagEntity_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
TagEntity entity = _tagEntityFixture.Create(name: "Fantasy");
|
||||
|
||||
// Act
|
||||
TagDto result = entity.ToResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(entity.Name, result.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Fantasy")]
|
||||
[InlineData("Young Adult")]
|
||||
[InlineData("Historical")]
|
||||
[InlineData("Coming of Age")]
|
||||
public void ToResponse_WhenMappingDifferentValidTagEntities_ShouldMapCorrectly(string name)
|
||||
{
|
||||
// Arrange
|
||||
TagEntity entity = _tagEntityFixture.Create(name: name);
|
||||
|
||||
// Act
|
||||
TagDto result = entity.ToResponse();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(entity.Name, result.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData(null)]
|
||||
public void ToResponse_WhenMappingInvalidTagEntity_ShouldMapToDefault(string? invalidName)
|
||||
{
|
||||
// Arrange
|
||||
TagEntity entity = _tagEntityFixture.Create(name: invalidName, includeName: invalidName is not null);
|
||||
|
||||
// Act
|
||||
TagDto result = entity.ToResponse();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(invalidName, result.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainValueObject_WhenMappingValidTagEntity_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
TagEntity entity = _tagEntityFixture.Create(name: "Fantasy");
|
||||
|
||||
// Act
|
||||
Result<Tag> result = entity.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal("fantasy", result.Value.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainValueObject_WhenTagNameHasSurroundingWhitespaceAndMixedCase_ShouldStoreTheTrimmedLowercaseInvariantName()
|
||||
{
|
||||
// Arrange
|
||||
TagEntity entity = _tagEntityFixture.Create(name: " InDiE ");
|
||||
|
||||
// Act
|
||||
Result<Tag> result = entity.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.NotNull(result.Value);
|
||||
Assert.Equal("indie", result.Value.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData(null)]
|
||||
public void ToDomainValueObject_WhenMappingInvalidTagEntity_ShouldMapToDefault(string? invalidName)
|
||||
{
|
||||
// Arrange
|
||||
TagEntity entity = _tagEntityFixture.Create(name: invalidName, includeName: invalidName is not null);
|
||||
|
||||
// Act
|
||||
Result<Tag> result = entity.ToDomainValueObject();
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Metadata.TagNameCannotBeEmpty, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainValueObjects_WhenMappingMultipleValidTagEntities_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<TagEntity> entities =
|
||||
[
|
||||
_tagEntityFixture.Create(name: "Fantasy"),
|
||||
_tagEntityFixture.Create(name: "Young Adult"),
|
||||
_tagEntityFixture.Create(name: "Historical"),
|
||||
_tagEntityFixture.Create(name: "Coming of Age")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<Result<Tag>> results = entities.ToDomainValueObjects();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(entities.Count, results.Count());
|
||||
|
||||
List<Result<Tag>> resultList = [.. results];
|
||||
for (int i = 0; i < entities.Count; i++)
|
||||
{
|
||||
Assert.False(resultList[i].IsFailure);
|
||||
Assert.Equal(entities[i].Name!.ToLowerInvariant(), resultList[i].Value.Name);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToResponses_WhenMappingMultipleValidTagEntities_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<TagEntity> entities =
|
||||
[
|
||||
_tagEntityFixture.Create(name: "Fantasy"),
|
||||
_tagEntityFixture.Create(name: "Young Adult"),
|
||||
_tagEntityFixture.Create(name: "Historical"),
|
||||
_tagEntityFixture.Create(name: "Coming of Age")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<TagDto> results = entities.ToResponses();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(entities.Count, results.Count());
|
||||
|
||||
List<TagDto> resultList = [.. results];
|
||||
for (int i = 0; i < entities.Count; i++)
|
||||
Assert.Equal(entities[i].Name, resultList[i].Name);
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Fixtures.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="TagMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TagMappingTests
|
||||
{
|
||||
private readonly TagFixture _tagFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToRepositoryEntity_WhenMappingTag_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
Tag tag = _tagFixture.Create("indie");
|
||||
|
||||
// Act
|
||||
TagEntity result = tag.ToRepositoryEntity();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(tag.Name, result.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("indie")]
|
||||
[InlineData("electronic")]
|
||||
[InlineData("instrumental")]
|
||||
[InlineData("live")]
|
||||
[InlineData("acoustic")]
|
||||
public void ToRepositoryEntity_WhenMappingDifferentTags_ShouldMapCorrectly(string name)
|
||||
{
|
||||
// Arrange
|
||||
Tag tag = _tagFixture.Create(name);
|
||||
|
||||
// Act
|
||||
TagEntity result = tag.ToRepositoryEntity();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(tag.Name, result.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToRepositoryEntities_WhenMappingMultipleTags_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<Tag> tags =
|
||||
[
|
||||
_tagFixture.Create("indie"),
|
||||
_tagFixture.Create("electronic"),
|
||||
_tagFixture.Create("instrumental"),
|
||||
_tagFixture.Create("live"),
|
||||
_tagFixture.Create("acoustic")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<TagEntity> results = tags.ToRepositoryEntities();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
Assert.Equal(tags.Count, results.Count());
|
||||
List<TagEntity> resultList = [.. results];
|
||||
for (int i = 0; i < tags.Count; i++)
|
||||
Assert.Equal(tags[i].Name, resultList[i].Name);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user