mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 15:11:10 +00:00
Moves repository entities to Application layer for joint access
This commit is contained in:
1 parent
baf9854355
commit
7321fb89e2
120 files changed
+2606
-784
No files matched your search
+32
-32
@@ -2,7 +2,7 @@
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -12,24 +12,24 @@ using System.Linq;
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GenreEntityMapping"/> class.
|
||||
/// Contains unit tests for the <see cref="GenreDtoMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GenreModelMappingTests
|
||||
public class GenreDtoMappingTests
|
||||
{
|
||||
[Fact]
|
||||
public void ToDomainModel_WhenMappingValidGenreEntity_ShouldMapCorrectly()
|
||||
public void ToDomainEntity_WhenMappingValidGenreDto_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GenreEntity genreEntity = new("Rock");
|
||||
GenreDto genreDto = new("Rock");
|
||||
|
||||
// Act
|
||||
ErrorOr<Genre> result = genreEntity.ToDomainEntity();
|
||||
ErrorOr<Genre> result = genreDto.ToDomainEntity();
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().NotBeNull();
|
||||
result.Value.Name.Should().Be(genreEntity.Name);
|
||||
result.Value.Name.Should().Be(genreDto.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -37,81 +37,81 @@ public class GenreModelMappingTests
|
||||
[InlineData("Jazz")]
|
||||
[InlineData("Classical")]
|
||||
[InlineData("Pop")]
|
||||
public void ToDomainModel_WhenMappingDifferentValidGenreEntities_ShouldMapCorrectly(string name)
|
||||
public void ToDomainEntity_WhenMappingDifferentValidGenreDtos_ShouldMapCorrectly(string name)
|
||||
{
|
||||
// Arrange
|
||||
GenreEntity genreEntity = new(name);
|
||||
GenreDto genreDto = new(name);
|
||||
|
||||
// Act
|
||||
ErrorOr<Genre> result = genreEntity.ToDomainEntity();
|
||||
ErrorOr<Genre> result = genreDto.ToDomainEntity();
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().NotBeNull();
|
||||
result.Value.Name.Should().Be(genreEntity.Name);
|
||||
result.Value.Name.Should().Be(genreDto.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData(null)]
|
||||
public void ToDomainModel_WhenMappingInvalidGenreEntity_ShouldReturnError(string? invalidName)
|
||||
public void ToDomainEntity_WhenMappingInvalidGenreDto_ShouldReturnError(string? invalidName)
|
||||
{
|
||||
// Arrange
|
||||
GenreEntity genreEntity = new(invalidName);
|
||||
GenreDto genreDto = new(invalidName);
|
||||
|
||||
// Act
|
||||
ErrorOr<Genre> result = genreEntity.ToDomainEntity();
|
||||
ErrorOr<Genre> result = genreDto.ToDomainEntity();
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainModels_WhenMappingMultipleValidGenreEntities_ShouldMapAllCorrectly()
|
||||
public void ToDomainModels_WhenMappingMultipleValidGenreDtos_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<GenreEntity> genreEntities =
|
||||
List<GenreDto> genreDtos =
|
||||
[
|
||||
new GenreEntity("Rock"),
|
||||
new GenreEntity("Jazz"),
|
||||
new GenreEntity("Classical"),
|
||||
new GenreEntity("Pop")
|
||||
new GenreDto("Rock"),
|
||||
new GenreDto("Jazz"),
|
||||
new GenreDto("Classical"),
|
||||
new GenreDto("Pop")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<ErrorOr<Genre>> results = genreEntities.ToDomainEntities();
|
||||
IEnumerable<ErrorOr<Genre>> results = genreDtos.ToDomainEntities();
|
||||
|
||||
// Assert
|
||||
results.Should().NotBeNull();
|
||||
results.Should().HaveCount(genreEntities.Count);
|
||||
results.Should().HaveCount(genreDtos.Count);
|
||||
|
||||
List<ErrorOr<Genre>> resultList = results.ToList();
|
||||
for (int i = 0; i < genreEntities.Count; i++)
|
||||
for (int i = 0; i < genreDtos.Count; i++)
|
||||
{
|
||||
resultList[i].IsError.Should().BeFalse();
|
||||
resultList[i].Value.Name.Should().Be(genreEntities[i].Name);
|
||||
resultList[i].Value.Name.Should().Be(genreDtos[i].Name);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainModels_WhenMappingMixedValidAndInvalidGenreEntities_ShouldReturnMixedResults()
|
||||
public void ToDomainModels_WhenMappingMixedValidAndInvalidGenreDtos_ShouldReturnMixedResults()
|
||||
{
|
||||
// Arrange
|
||||
List<GenreEntity> genreEntities =
|
||||
List<GenreDto> genreDtos =
|
||||
[
|
||||
new GenreEntity("Rock"),
|
||||
new GenreEntity(""),
|
||||
new GenreEntity("Jazz"),
|
||||
new GenreEntity(" ")
|
||||
new GenreDto("Rock"),
|
||||
new GenreDto(""),
|
||||
new GenreDto("Jazz"),
|
||||
new GenreDto(" ")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<ErrorOr<Genre>> results = genreEntities.ToDomainEntities();
|
||||
IEnumerable<ErrorOr<Genre>> results = genreDtos.ToDomainEntities();
|
||||
|
||||
// Assert
|
||||
results.Should().NotBeNull();
|
||||
results.Should().HaveCount(genreEntities.Count);
|
||||
results.Should().HaveCount(genreDtos.Count);
|
||||
|
||||
List<ErrorOr<Genre>> resultList = results.ToList();
|
||||
resultList[0].IsError.Should().BeFalse();
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GenreEntityMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GenreEntityMappingTests
|
||||
{
|
||||
[Fact]
|
||||
public void ToResponse_WhenMappingValidGenreEntity_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GenreEntity entity = new("Fiction");
|
||||
|
||||
// Act
|
||||
GenreDto result = entity.ToResponse();
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Name.Should().Be(entity.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Fiction")]
|
||||
[InlineData("Science Fiction")]
|
||||
[InlineData("Mystery")]
|
||||
[InlineData("Romance")]
|
||||
public void ToResponse_WhenMappingDifferentValidGenreEntities_ShouldMapCorrectly(string name)
|
||||
{
|
||||
// Arrange
|
||||
GenreEntity entity = new(name);
|
||||
|
||||
// Act
|
||||
GenreDto result = entity.ToResponse();
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Name.Should().Be(entity.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData(null)]
|
||||
public void ToResponse_WhenMappingInvalidGenreEntity_ShouldMapToDefault(string? invalidName)
|
||||
{
|
||||
// Arrange
|
||||
GenreEntity entity = new(invalidName);
|
||||
|
||||
// Act
|
||||
GenreDto result = entity.ToResponse();
|
||||
|
||||
// Assert
|
||||
result.Name.Should().Be(invalidName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainEntity_WhenMappingValidGenreEntity_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
GenreEntity entity = new("Fiction");
|
||||
|
||||
// Act
|
||||
ErrorOr<Genre> result = entity.ToDomainEntity();
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().NotBeNull();
|
||||
result.Value.Name.Should().Be(entity.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData(null)]
|
||||
public void ToDomainEntity_WhenMappingInvalidGenreEntity_ShouldMapToDefault(string? invalidName)
|
||||
{
|
||||
// Arrange
|
||||
GenreEntity entity = new(invalidName);
|
||||
|
||||
// Act
|
||||
ErrorOr<Genre> result = entity.ToDomainEntity();
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Metadata.GenreNameCannotBeEmpty);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainEntities_WhenMappingMultipleValidGenreEntities_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<GenreEntity> entities =
|
||||
[
|
||||
new GenreEntity("Fiction"),
|
||||
new GenreEntity("Mystery"),
|
||||
new GenreEntity("Romance"),
|
||||
new GenreEntity("Thriller")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<ErrorOr<Genre>> results = entities.ToDomainEntities();
|
||||
|
||||
// Assert
|
||||
results.Should().NotBeNull();
|
||||
results.Should().HaveCount(entities.Count);
|
||||
|
||||
List<ErrorOr<Genre>> resultList = results.ToList();
|
||||
for (int i = 0; i < entities.Count; i++)
|
||||
{
|
||||
resultList[i].IsError.Should().BeFalse();
|
||||
resultList[i].Value.Name.Should().Be(entities[i].Name);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToResponses_WhenMappingMultipleValidGenreEntities_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<GenreEntity> entities =
|
||||
[
|
||||
new GenreEntity("Fiction"),
|
||||
new GenreEntity("Mystery"),
|
||||
new GenreEntity("Romance"),
|
||||
new GenreEntity("Thriller")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<GenreDto> results = entities.ToResponses();
|
||||
|
||||
// Assert
|
||||
results.Should().NotBeNull();
|
||||
results.Should().HaveCount(entities.Count);
|
||||
|
||||
List<GenreDto> resultList = results.ToList();
|
||||
for (int i = 0; i < entities.Count; i++)
|
||||
{
|
||||
resultList[i].Name.Should().Be(entities[i].Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
+32
-32
@@ -2,7 +2,7 @@
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -12,24 +12,24 @@ using System.Linq;
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="TagEntityMapping"/> class.
|
||||
/// Contains unit tests for the <see cref="TagDtoMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TagModelMappingTests
|
||||
public class TagDtoMappingTests
|
||||
{
|
||||
[Fact]
|
||||
public void ToDomainModel_WhenMappingValidTagEntity_ShouldMapCorrectly()
|
||||
public void ToDomainEntity_WhenMappingValidTagDto_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
TagEntity tagEntity = new("indie");
|
||||
TagDto tagDto = new("indie");
|
||||
|
||||
// Act
|
||||
ErrorOr<Tag> result = tagEntity.ToDomainEntity();
|
||||
ErrorOr<Tag> result = tagDto.ToDomainEntity();
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().NotBeNull();
|
||||
result.Value.Name.Should().Be(tagEntity.Name);
|
||||
result.Value.Name.Should().Be(tagDto.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -38,81 +38,81 @@ public class TagModelMappingTests
|
||||
[InlineData("instrumental")]
|
||||
[InlineData("live")]
|
||||
[InlineData("acoustic")]
|
||||
public void ToDomainModel_WhenMappingDifferentValidTagEntities_ShouldMapCorrectly(string name)
|
||||
public void ToDomainEntity_WhenMappingDifferentValidTagDtos_ShouldMapCorrectly(string name)
|
||||
{
|
||||
// Arrange
|
||||
TagEntity tagEntity = new(name);
|
||||
TagDto tagDto = new(name);
|
||||
|
||||
// Act
|
||||
ErrorOr<Tag> result = tagEntity.ToDomainEntity();
|
||||
ErrorOr<Tag> result = tagDto.ToDomainEntity();
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().NotBeNull();
|
||||
result.Value.Name.Should().Be(tagEntity.Name);
|
||||
result.Value.Name.Should().Be(tagDto.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData(null)]
|
||||
public void ToDomainModel_WhenMappingInvalidTagEntity_ShouldReturnError(string? invalidName)
|
||||
public void ToDomainEntity_WhenMappingInvalidTagDto_ShouldReturnError(string? invalidName)
|
||||
{
|
||||
// Arrange
|
||||
TagEntity tagEntity = new(invalidName);
|
||||
TagDto tagDto = new(invalidName);
|
||||
|
||||
// Act
|
||||
ErrorOr<Tag> result = tagEntity.ToDomainEntity();
|
||||
ErrorOr<Tag> result = tagDto.ToDomainEntity();
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainModels_WhenMappingMultipleValidTagEntities_ShouldMapAllCorrectly()
|
||||
public void ToDomainModels_WhenMappingMultipleValidTagDtos_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<TagEntity> tagEntities =
|
||||
List<TagDto> tagDtos =
|
||||
[
|
||||
new TagEntity("indie"),
|
||||
new TagEntity("electronic"),
|
||||
new TagEntity("instrumental"),
|
||||
new TagEntity("live")
|
||||
new TagDto("indie"),
|
||||
new TagDto("electronic"),
|
||||
new TagDto("instrumental"),
|
||||
new TagDto("live")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<ErrorOr<Tag>> results = tagEntities.ToDomainEntities();
|
||||
IEnumerable<ErrorOr<Tag>> results = tagDtos.ToDomainEntities();
|
||||
|
||||
// Assert
|
||||
results.Should().NotBeNull();
|
||||
results.Should().HaveCount(tagEntities.Count);
|
||||
results.Should().HaveCount(tagDtos.Count);
|
||||
|
||||
List<ErrorOr<Tag>> resultList = results.ToList();
|
||||
for (int i = 0; i < tagEntities.Count; i++)
|
||||
for (int i = 0; i < tagDtos.Count; i++)
|
||||
{
|
||||
resultList[i].IsError.Should().BeFalse();
|
||||
resultList[i].Value.Name.Should().Be(tagEntities[i].Name);
|
||||
resultList[i].Value.Name.Should().Be(tagDtos[i].Name);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainModels_WhenMappingMixedValidAndInvalidTagEntities_ShouldReturnMixedResults()
|
||||
public void ToDomainModels_WhenMappingMixedValidAndInvalidTagDtos_ShouldReturnMixedResults()
|
||||
{
|
||||
// Arrange
|
||||
List<TagEntity> tagEntities =
|
||||
List<TagDto> tagDtos =
|
||||
[
|
||||
new TagEntity("indie"),
|
||||
new TagEntity(""),
|
||||
new TagEntity("electronic"),
|
||||
new TagEntity(" ")
|
||||
new TagDto("indie"),
|
||||
new TagDto(""),
|
||||
new TagDto("electronic"),
|
||||
new TagDto(" ")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<ErrorOr<Tag>> results = tagEntities.ToDomainEntities();
|
||||
IEnumerable<ErrorOr<Tag>> results = tagDtos.ToDomainEntities();
|
||||
|
||||
// Assert
|
||||
results.Should().NotBeNull();
|
||||
results.Should().HaveCount(tagEntities.Count);
|
||||
results.Should().HaveCount(tagDtos.Count);
|
||||
|
||||
List<ErrorOr<Tag>> resultList = results.ToList();
|
||||
resultList[0].IsError.Should().BeFalse();
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="TagEntityMapping"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TagEntityMappingTests
|
||||
{
|
||||
[Fact]
|
||||
public void ToResponse_WhenMappingValidTagEntity_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
TagEntity entity = new("Fantasy");
|
||||
|
||||
// Act
|
||||
TagDto result = entity.ToResponse();
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Name.Should().Be(entity.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Fantasy")]
|
||||
[InlineData("Young Adult")]
|
||||
[InlineData("Historical")]
|
||||
[InlineData("Coming of Age")]
|
||||
public void ToResponse_WhenMappingDifferentValidTagEntities_ShouldMapCorrectly(string name)
|
||||
{
|
||||
// Arrange
|
||||
TagEntity entity = new(name);
|
||||
|
||||
// Act
|
||||
TagDto result = entity.ToResponse();
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Name.Should().Be(entity.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData(null)]
|
||||
public void ToResponse_WhenMappingInvalidTagEntity_ShouldMapToDefault(string? invalidName)
|
||||
{
|
||||
// Arrange
|
||||
TagEntity entity = new(invalidName);
|
||||
|
||||
// Act
|
||||
TagDto result = entity.ToResponse();
|
||||
|
||||
// Assert
|
||||
result.Name.Should().Be(invalidName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainEntity_WhenMappingValidTagEntity_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
TagEntity entity = new("Fantasy");
|
||||
|
||||
// Act
|
||||
ErrorOr<Tag> result = entity.ToDomainEntity();
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().NotBeNull();
|
||||
result.Value.Name.Should().Be(entity.Name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData(null)]
|
||||
public void ToDomainEntity_WhenMappingInvalidTagEntity_ShouldMapToDefault(string? invalidName)
|
||||
{
|
||||
// Arrange
|
||||
TagEntity entity = new(invalidName);
|
||||
|
||||
// Act
|
||||
ErrorOr<Tag> result = entity.ToDomainEntity();
|
||||
|
||||
// Assert
|
||||
result.IsError.Should().BeTrue();
|
||||
result.FirstError.Should().Be(Errors.Metadata.TagNameCannotBeEmpty);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToDomainEntities_WhenMappingMultipleValidTagEntities_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<TagEntity> entities =
|
||||
[
|
||||
new TagEntity("Fantasy"),
|
||||
new TagEntity("Young Adult"),
|
||||
new TagEntity("Historical"),
|
||||
new TagEntity("Coming of Age")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<ErrorOr<Tag>> results = entities.ToDomainEntities();
|
||||
|
||||
// Assert
|
||||
results.Should().NotBeNull();
|
||||
results.Should().HaveCount(entities.Count);
|
||||
|
||||
List<ErrorOr<Tag>> resultList = results.ToList();
|
||||
for (int i = 0; i < entities.Count; i++)
|
||||
{
|
||||
resultList[i].IsError.Should().BeFalse();
|
||||
resultList[i].Value.Name.Should().Be(entities[i].Name);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToResponses_WhenMappingMultipleValidTagEntities_ShouldMapAllCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
List<TagEntity> entities =
|
||||
[
|
||||
new TagEntity("Fantasy"),
|
||||
new TagEntity("Young Adult"),
|
||||
new TagEntity("Historical"),
|
||||
new TagEntity("Coming of Age")
|
||||
];
|
||||
|
||||
// Act
|
||||
IEnumerable<TagDto> results = entities.ToResponses();
|
||||
|
||||
// Assert
|
||||
results.Should().NotBeNull();
|
||||
results.Should().HaveCount(entities.Count);
|
||||
|
||||
List<TagDto> resultList = results.ToList();
|
||||
for (int i = 0; i < entities.Count; i++)
|
||||
{
|
||||
resultList[i].Name.Should().Be(entities[i].Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
Reference in new issue
Block a user