mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13: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
+8
-8
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Entities.FileSystemManagement;
|
||||
using Lumina.Contracts.DTO.FileSystemManagement;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
@@ -9,7 +9,7 @@ using System.Linq;
|
||||
namespace Lumina.Application.UnitTests.Core.FileSystemManagement.Directories.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FileSystemItemEntity"/> class.
|
||||
/// Fixture class for the <see cref="FileSystemItemDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FileSystemItemModelFixture
|
||||
@@ -17,12 +17,12 @@ public class FileSystemItemModelFixture
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="FileSystemItemEntity"/>.
|
||||
/// Creates a random valid <see cref="FileSystemItemDto"/>.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="FileSystemItemEntity"/>.</returns>
|
||||
public FileSystemItemEntity Create()
|
||||
/// <returns>The created <see cref="FileSystemItemDto"/>.</returns>
|
||||
public FileSystemItemDto Create()
|
||||
{
|
||||
return new FileSystemItemEntity(
|
||||
return new FileSystemItemDto(
|
||||
_faker.System.FilePath(),
|
||||
_faker.System.FileName(),
|
||||
_faker.Date.Past(),
|
||||
@@ -31,11 +31,11 @@ public class FileSystemItemModelFixture
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="FileSystemItemEntity"/>.
|
||||
/// Creates a list of <see cref="FileSystemItemDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<FileSystemItemEntity> CreateMany(int count = 3)
|
||||
public List<FileSystemItemDto> CreateMany(int count = 3)
|
||||
{
|
||||
return Enumerable.Range(0, count).Select(_ => Create()).ToList();
|
||||
}
|
||||
|
||||
-1
@@ -11,7 +11,6 @@ using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.File
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using NSubstitute;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Core.MediaLibrary.Management.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Library"/>.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DomainLibraryFixture
|
||||
{
|
||||
private readonly Faker _faker;
|
||||
private readonly Random _random = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DomainLibraryFixture"/> class.
|
||||
/// </summary>
|
||||
public DomainLibraryFixture()
|
||||
{
|
||||
_faker = new Faker();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a media library domain entity.
|
||||
/// </summary>
|
||||
/// <returns>The created media library entity.</returns>
|
||||
public Library CreateLibrary()
|
||||
{
|
||||
List<string> validPaths =
|
||||
[
|
||||
"C:/Media",
|
||||
"D:/Books",
|
||||
"E:/Digital Library",
|
||||
"F:/Content"
|
||||
];
|
||||
|
||||
ErrorOr<Library> library = Library.Create(
|
||||
Guid.NewGuid(),
|
||||
_faker.Random.String2(_faker.Random.Number(1, 50)),
|
||||
_faker.PickRandom<LibraryType>(),
|
||||
validPaths.Take(_random.Next(1, validPaths.Count))
|
||||
);
|
||||
|
||||
return library.Value;
|
||||
}
|
||||
|
||||
public Library CreateLibraryWithSpecificValues(
|
||||
Guid? id = null,
|
||||
Guid? userId = null,
|
||||
string? title = null,
|
||||
LibraryType? libraryType = null,
|
||||
IEnumerable<string>? contentLocations = null)
|
||||
{
|
||||
ErrorOr<Library> library = id is null ?
|
||||
Library.Create(
|
||||
userId ?? Guid.NewGuid(),
|
||||
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
|
||||
libraryType ?? LibraryType.Book,
|
||||
contentLocations ?? ["C:/Media"]
|
||||
) :
|
||||
Library.Create(
|
||||
LibraryId.Create(id.Value),
|
||||
userId ?? Guid.NewGuid(),
|
||||
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
|
||||
libraryType ?? LibraryType.Book,
|
||||
contentLocations ?? ["C:/Media"]
|
||||
);
|
||||
|
||||
return library.Value;
|
||||
}
|
||||
}
|
||||
+13
-12
@@ -3,15 +3,16 @@ using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using ErrorOr;
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Books;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
using Lumina.Application.UnitTests.Common.Setup;
|
||||
using Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook.Fixtures;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Common.Enums.BookLibrary;
|
||||
using Lumina.Application.UnitTests.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook.Fixtures;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using NSubstitute;
|
||||
using System;
|
||||
@@ -20,7 +21,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
namespace Lumina.Application.UnitTests.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="AddBookCommandHandler"/> class.
|
||||
@@ -112,7 +113,7 @@ public class AddBookCommandHandlerTests
|
||||
{
|
||||
// Arrange
|
||||
AddBookCommand bookCommand = _commandBookFixture.CreateCommandBook();
|
||||
bookCommand = bookCommand with { ISBNs = [new IsbnEntity("invalid", IsbnFormat.Isbn13)] };
|
||||
bookCommand = bookCommand with { ISBNs = [new IsbnDto("invalid", IsbnFormat.Isbn13)] };
|
||||
|
||||
// Act
|
||||
ErrorOr<BookResponse> result = await _sut.Handle(bookCommand, CancellationToken.None);
|
||||
@@ -129,7 +130,7 @@ public class AddBookCommandHandlerTests
|
||||
{
|
||||
// Arrange
|
||||
AddBookCommand bookCommand = _commandBookFixture.CreateCommandBook();
|
||||
bookCommand = bookCommand with { Ratings = [new BookRatingEntity(-1, 5, null, null)] };
|
||||
bookCommand = bookCommand with { Ratings = [new BookRatingDto(-1, 5, null, null)] };
|
||||
|
||||
// Act
|
||||
ErrorOr<BookResponse> result = await _sut.Handle(bookCommand, CancellationToken.None);
|
||||
@@ -150,7 +151,7 @@ public class AddBookCommandHandlerTests
|
||||
{
|
||||
Metadata = bookCommand.Metadata! with
|
||||
{
|
||||
Genres = [new GenreEntity("")]
|
||||
Genres = [new GenreDto("")]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -173,7 +174,7 @@ public class AddBookCommandHandlerTests
|
||||
{
|
||||
Metadata = bookCommand.Metadata! with
|
||||
{
|
||||
Tags = [new TagEntity("")]
|
||||
Tags = [new TagDto("")]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -196,7 +197,7 @@ public class AddBookCommandHandlerTests
|
||||
{
|
||||
Metadata = bookCommand.Metadata! with
|
||||
{
|
||||
ReleaseInfo = new ReleaseInfoEntity(
|
||||
ReleaseInfo = new ReleaseInfoDto(
|
||||
OriginalReleaseDate: new DateOnly(2025, 1, 1),
|
||||
ReReleaseDate: new DateOnly(2024, 1, 1),
|
||||
OriginalReleaseYear: null,
|
||||
@@ -226,7 +227,7 @@ public class AddBookCommandHandlerTests
|
||||
{
|
||||
Metadata = bookCommand.Metadata! with
|
||||
{
|
||||
Language = new LanguageInfoEntity("", "English", null)
|
||||
Language = new LanguageInfoDto("", "English", null)
|
||||
}
|
||||
};
|
||||
|
||||
@@ -249,7 +250,7 @@ public class AddBookCommandHandlerTests
|
||||
{
|
||||
Metadata = bookCommand.Metadata! with
|
||||
{
|
||||
OriginalLanguage = new LanguageInfoEntity("", "English", null)
|
||||
OriginalLanguage = new LanguageInfoDto("", "English", null)
|
||||
}
|
||||
};
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
using Bogus;
|
||||
using FluentValidation.TestHelper;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
using Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook.Fixtures;
|
||||
using Lumina.Application.UnitTests.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook.Fixtures;
|
||||
using Lumina.Domain.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using System;
|
||||
@@ -10,7 +10,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
namespace Lumina.Application.UnitTests.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="AddBookCommandValidator"/> class.
|
||||
+47
-47
@@ -3,10 +3,10 @@ using AutoFixture;
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
using Lumina.Application.UnitTests.Common.Setup;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Contracts.Entities.MediaContributors;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -14,7 +14,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook.Fixtures;
|
||||
namespace Lumina.Application.UnitTests.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddBookCommand"/> class.
|
||||
@@ -46,8 +46,8 @@ public class AddBookCommandFixture
|
||||
int releaseYear = _random.Next(2000, 2010);
|
||||
int reReleaseYear = _random.Next(2010, 2020);
|
||||
|
||||
ReleaseInfoEntity releaseInfo = new Faker<ReleaseInfoEntity>()
|
||||
.CustomInstantiator(f => new ReleaseInfoEntity(
|
||||
ReleaseInfoDto releaseInfo = new Faker<ReleaseInfoDto>()
|
||||
.CustomInstantiator(f => new ReleaseInfoDto(
|
||||
default,
|
||||
default,
|
||||
default,
|
||||
@@ -63,42 +63,42 @@ public class AddBookCommandFixture
|
||||
.RuleFor(x => x.ReleaseVersion, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.Generate();
|
||||
|
||||
Faker<GenreEntity> genre = new Faker<GenreEntity>()
|
||||
.CustomInstantiator(f => new GenreEntity(
|
||||
Faker<GenreDto> genre = new Faker<GenreDto>()
|
||||
.CustomInstantiator(f => new GenreDto(
|
||||
default!
|
||||
))
|
||||
.RuleFor(e => e.Name, f => f.Random.String2(f.Random.Number(1, 50)));
|
||||
|
||||
Faker<TagEntity> tag = new Faker<TagEntity>()
|
||||
.CustomInstantiator(f => new TagEntity(
|
||||
Faker<TagDto> tag = new Faker<TagDto>()
|
||||
.CustomInstantiator(f => new TagDto(
|
||||
default!
|
||||
))
|
||||
.RuleFor(e => e.Name, f => f.Random.String2(f.Random.Number(1, 50)));
|
||||
|
||||
Faker<MediaContributorRoleEntity> mediaContributorRole = new Faker<MediaContributorRoleEntity>()
|
||||
.CustomInstantiator(f => new MediaContributorRoleEntity(
|
||||
Faker<MediaContributorRoleDto> mediaContributorRole = new Faker<MediaContributorRoleDto>()
|
||||
.CustomInstantiator(f => new MediaContributorRoleDto(
|
||||
default!,
|
||||
default!
|
||||
))
|
||||
.RuleFor(e => e.Name, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(e => e.Category, f => f.Random.String2(f.Random.Number(1, 50)));
|
||||
Faker<MediaContributorNameEntity> mediaContributorName = new Faker<MediaContributorNameEntity>()
|
||||
.CustomInstantiator(f => new MediaContributorNameEntity(
|
||||
Faker<MediaContributorNameDto> mediaContributorName = new Faker<MediaContributorNameDto>()
|
||||
.CustomInstantiator(f => new MediaContributorNameDto(
|
||||
default!,
|
||||
default!
|
||||
))
|
||||
.RuleFor(e => e.DisplayName, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(e => e.LegalName, f => f.Random.String2(f.Random.Number(1, 50)));
|
||||
Faker<MediaContributorEntity> mediaContributor = new Faker<MediaContributorEntity>()
|
||||
.CustomInstantiator(f => new MediaContributorEntity(
|
||||
Faker<MediaContributorDto> mediaContributor = new Faker<MediaContributorDto>()
|
||||
.CustomInstantiator(f => new MediaContributorDto(
|
||||
default!,
|
||||
default!
|
||||
))
|
||||
.RuleFor(e => e.Name, mediaContributorName)
|
||||
.RuleFor(e => e.Role, mediaContributorRole);
|
||||
|
||||
Faker<BookRatingEntity> rating = new Faker<BookRatingEntity>()
|
||||
.CustomInstantiator(f => new BookRatingEntity(
|
||||
Faker<BookRatingDto> rating = new Faker<BookRatingDto>()
|
||||
.CustomInstantiator(f => new BookRatingDto(
|
||||
default,
|
||||
default,
|
||||
default,
|
||||
@@ -109,8 +109,8 @@ public class AddBookCommandFixture
|
||||
.RuleFor(e => e.Source, _fixture.Create<BookRatingSource>())
|
||||
.RuleFor(e => e.VoteCount, _random.Next(1, 1000));
|
||||
|
||||
Faker<LanguageInfoEntity> language = new Faker<LanguageInfoEntity>()
|
||||
.CustomInstantiator(f => new LanguageInfoEntity(
|
||||
Faker<LanguageInfoDto> language = new Faker<LanguageInfoDto>()
|
||||
.CustomInstantiator(f => new LanguageInfoDto(
|
||||
default!,
|
||||
default!,
|
||||
default
|
||||
@@ -119,8 +119,8 @@ public class AddBookCommandFixture
|
||||
.RuleFor(e => e.LanguageCode, f => f.Random.String2(2))
|
||||
.RuleFor(e => e.NativeName, f => f.Random.String2(f.Random.Number(1, 50)));
|
||||
|
||||
Faker<LanguageInfoEntity> originalLanguage = new Faker<LanguageInfoEntity>()
|
||||
.CustomInstantiator(f => new LanguageInfoEntity(
|
||||
Faker<LanguageInfoDto> originalLanguage = new Faker<LanguageInfoDto>()
|
||||
.CustomInstantiator(f => new LanguageInfoDto(
|
||||
default!,
|
||||
default!,
|
||||
default
|
||||
@@ -129,8 +129,8 @@ public class AddBookCommandFixture
|
||||
.RuleFor(e => e.LanguageCode, f => f.Random.String2(2))
|
||||
.RuleFor(e => e.NativeName, f => f.Random.String2(f.Random.Number(1, 50)));
|
||||
|
||||
Faker<WrittenContentMetadataEntity> metadata = new Faker<WrittenContentMetadataEntity>()
|
||||
.CustomInstantiator(f => new WrittenContentMetadataEntity(
|
||||
Faker<WrittenContentMetadataDto> metadata = new Faker<WrittenContentMetadataDto>()
|
||||
.CustomInstantiator(f => new WrittenContentMetadataDto(
|
||||
default!,
|
||||
default,
|
||||
default,
|
||||
@@ -153,8 +153,8 @@ public class AddBookCommandFixture
|
||||
.RuleFor(x => x.Publisher, f => f.Random.String2(f.Random.Number(1, 100)))
|
||||
.RuleFor(x => x.PageCount, _random.Next(100, 300));
|
||||
|
||||
Faker<IsbnEntity> isbn = new Faker<IsbnEntity>()
|
||||
.CustomInstantiator(f => new IsbnEntity(
|
||||
Faker<IsbnDto> isbn = new Faker<IsbnDto>()
|
||||
.CustomInstantiator(f => new IsbnDto(
|
||||
default!,
|
||||
default
|
||||
))
|
||||
@@ -171,7 +171,7 @@ public class AddBookCommandFixture
|
||||
int sum = 0;
|
||||
for (int i = 0; i < 12; i++)
|
||||
sum += (i % 2 == 0 ? 1 : 3) * int.Parse(isbn[i].ToString());
|
||||
int checkDigit = (10 - (sum % 10)) % 10;
|
||||
int checkDigit = (10 - sum % 10) % 10;
|
||||
return $"{prefix}-{group[..1]}-{publisher}-{title}-{checkDigit}";
|
||||
}
|
||||
else
|
||||
@@ -182,7 +182,7 @@ public class AddBookCommandFixture
|
||||
int sum = 0;
|
||||
for (int i = 0; i < 9; i++)
|
||||
sum += (10 - i) * digits[i];
|
||||
int checkDigit = (11 - (sum % 11)) % 11;
|
||||
int checkDigit = (11 - sum % 11) % 11;
|
||||
string checkChar = checkDigit == 10 ? "X" : checkDigit.ToString();
|
||||
return $"{digits[0]}-{digits[1]}{digits[2]}-{digits[3]}{digits[4]}{digits[5]}{digits[6]}{digits[7]}{digits[8]}-{checkChar}";
|
||||
}
|
||||
@@ -276,7 +276,7 @@ public class AddBookCommandFixture
|
||||
int releaseYear = _random.Next(2000, 2010);
|
||||
int reReleaseYear = _random.Next(2010, 2020);
|
||||
|
||||
_fixture.Register(() => new ReleaseInfoEntity(
|
||||
_fixture.Register(() => new ReleaseInfoDto(
|
||||
_faker.DateOnlyBetween(new DateOnly(releaseYear, 1, 1), new DateOnly(releaseYear, 12, 31)),
|
||||
releaseYear,
|
||||
_faker.DateOnlyBetween(new DateOnly(reReleaseYear, 1, 1), new DateOnly(reReleaseYear, 12, 31)),
|
||||
@@ -284,53 +284,53 @@ public class AddBookCommandFixture
|
||||
_fixture.Create<string>()[2..],
|
||||
_fixture.Create<string?>()));
|
||||
|
||||
_fixture.Register(() => new GenreEntity(
|
||||
_fixture.Register(() => new GenreDto(
|
||||
_fixture.Create<string>()
|
||||
));
|
||||
_fixture.Register(() => new TagEntity(
|
||||
_fixture.Register(() => new TagDto(
|
||||
_fixture.Create<string>()
|
||||
));
|
||||
_fixture.Register(() => new LanguageInfoEntity(
|
||||
_fixture.Register(() => new LanguageInfoDto(
|
||||
_fixture.Create<string>(),
|
||||
_fixture.Create<string>(),
|
||||
_fixture.Create<string?>()
|
||||
));
|
||||
_fixture.Register(() => new IsbnEntity(
|
||||
_fixture.Register(() => new IsbnDto(
|
||||
_fixture.Create<string>(),
|
||||
_fixture.Create<IsbnFormat>()
|
||||
));
|
||||
_fixture.Register(() => new BookRatingEntity(
|
||||
_fixture.Register(() => new BookRatingDto(
|
||||
_fixture.Create<decimal>(),
|
||||
_fixture.Create<decimal>(),
|
||||
_fixture.Create<BookRatingSource?>(),
|
||||
_fixture.Create<int?>()
|
||||
));
|
||||
_fixture.Register(() => new WrittenContentMetadataEntity(
|
||||
_fixture.Register(() => new WrittenContentMetadataDto(
|
||||
_fixture.Create<string>()[255..],
|
||||
LimitStringLength(_fixture.Create<string?>(), 255),
|
||||
LimitStringLength(_fixture.Create<string?>(), 2000),
|
||||
_fixture.Create<ReleaseInfoEntity>(),
|
||||
_fixture.Create<List<GenreEntity>>(),
|
||||
_fixture.Create<List<TagEntity>>(),
|
||||
_fixture.Create<LanguageInfoEntity?>(),
|
||||
_fixture.Create<LanguageInfoEntity?>(),
|
||||
_fixture.Create<ReleaseInfoDto>(),
|
||||
_fixture.Create<List<GenreDto>>(),
|
||||
_fixture.Create<List<TagDto>>(),
|
||||
_fixture.Create<LanguageInfoDto?>(),
|
||||
_fixture.Create<LanguageInfoDto?>(),
|
||||
_fixture.Create<string?>(),
|
||||
_fixture.Create<int?>()
|
||||
));
|
||||
_fixture.Register(() => new BookSeriesEntity(
|
||||
_fixture.Register(() => new BookSeriesDto(
|
||||
_fixture.Create<string>()
|
||||
));
|
||||
_fixture.Register(() => new MediaContributorRoleEntity(
|
||||
_fixture.Register(() => new MediaContributorRoleDto(
|
||||
_fixture.Create<string>(),
|
||||
_fixture.Create<string>()
|
||||
));
|
||||
_fixture.Register(() => new MediaContributorNameEntity(
|
||||
_fixture.Register(() => new MediaContributorNameDto(
|
||||
_fixture.Create<string>(),
|
||||
_fixture.Create<string?>()
|
||||
));
|
||||
_fixture.Register(() => new MediaContributorEntity(
|
||||
_fixture.Create<MediaContributorNameEntity>(),
|
||||
_fixture.Create<MediaContributorRoleEntity>()
|
||||
_fixture.Register(() => new MediaContributorDto(
|
||||
_fixture.Create<MediaContributorNameDto>(),
|
||||
_fixture.Create<MediaContributorRoleDto>()
|
||||
));
|
||||
}
|
||||
|
||||
+29
-29
@@ -2,18 +2,18 @@
|
||||
using AutoFixture;
|
||||
using Bogus;
|
||||
using Lumina.Application.UnitTests.Common.Setup;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Contracts.Entities.MediaContributors;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Common.Enums.BookLibrary;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook.Fixtures;
|
||||
namespace Lumina.Application.UnitTests.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddBookRequest"/> class.
|
||||
@@ -45,8 +45,8 @@ public class AddBookRequestFixture
|
||||
int releaseYear = _random.Next(2000, 2010);
|
||||
int reReleaseYear = _random.Next(2010, 2020);
|
||||
|
||||
ReleaseInfoEntity releaseInfo = new Faker<ReleaseInfoEntity>()
|
||||
.CustomInstantiator(f => new ReleaseInfoEntity(
|
||||
ReleaseInfoDto releaseInfo = new Faker<ReleaseInfoDto>()
|
||||
.CustomInstantiator(f => new ReleaseInfoDto(
|
||||
default,
|
||||
default,
|
||||
default,
|
||||
@@ -62,44 +62,44 @@ public class AddBookRequestFixture
|
||||
.RuleFor(x => x.ReleaseVersion, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.Generate();
|
||||
|
||||
Faker<GenreEntity> genre = new Faker<GenreEntity>()
|
||||
.CustomInstantiator(f => new GenreEntity(
|
||||
Faker<GenreDto> genre = new Faker<GenreDto>()
|
||||
.CustomInstantiator(f => new GenreDto(
|
||||
default!
|
||||
))
|
||||
.RuleFor(e => e.Name, f => f.Random.String2(f.Random.Number(1, 50)));
|
||||
|
||||
Faker<TagEntity> tag = new Faker<TagEntity>()
|
||||
.CustomInstantiator(f => new TagEntity(
|
||||
Faker<TagDto> tag = new Faker<TagDto>()
|
||||
.CustomInstantiator(f => new TagDto(
|
||||
default!
|
||||
))
|
||||
.RuleFor(e => e.Name, f => f.Random.String2(f.Random.Number(1, 50)));
|
||||
|
||||
Faker<MediaContributorRoleEntity> mediaContributorRole = new Faker<MediaContributorRoleEntity>()
|
||||
.CustomInstantiator(f => new MediaContributorRoleEntity(
|
||||
Faker<MediaContributorRoleDto> mediaContributorRole = new Faker<MediaContributorRoleDto>()
|
||||
.CustomInstantiator(f => new MediaContributorRoleDto(
|
||||
default!,
|
||||
default!
|
||||
))
|
||||
.RuleFor(e => e.Name, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(e => e.Category, f => f.Random.String2(f.Random.Number(1, 50)));
|
||||
|
||||
Faker<MediaContributorNameEntity> mediaContributorName = new Faker<MediaContributorNameEntity>()
|
||||
.CustomInstantiator(f => new MediaContributorNameEntity(
|
||||
Faker<MediaContributorNameDto> mediaContributorName = new Faker<MediaContributorNameDto>()
|
||||
.CustomInstantiator(f => new MediaContributorNameDto(
|
||||
default!,
|
||||
default!
|
||||
))
|
||||
.RuleFor(e => e.DisplayName, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(e => e.LegalName, f => f.Random.String2(f.Random.Number(1, 50)));
|
||||
|
||||
Faker<MediaContributorEntity> mediaContributor = new Faker<MediaContributorEntity>()
|
||||
.CustomInstantiator(f => new MediaContributorEntity(
|
||||
Faker<MediaContributorDto> mediaContributor = new Faker<MediaContributorDto>()
|
||||
.CustomInstantiator(f => new MediaContributorDto(
|
||||
default!,
|
||||
default!
|
||||
))
|
||||
.RuleFor(e => e.Name, mediaContributorName)
|
||||
.RuleFor(e => e.Role, mediaContributorRole);
|
||||
|
||||
Faker<BookRatingEntity> rating = new Faker<BookRatingEntity>()
|
||||
.CustomInstantiator(f => new BookRatingEntity(
|
||||
Faker<BookRatingDto> rating = new Faker<BookRatingDto>()
|
||||
.CustomInstantiator(f => new BookRatingDto(
|
||||
default,
|
||||
default,
|
||||
default,
|
||||
@@ -110,8 +110,8 @@ public class AddBookRequestFixture
|
||||
.RuleFor(e => e.Source, _fixture.Create<BookRatingSource>())
|
||||
.RuleFor(e => e.VoteCount, _random.Next(1, 1000));
|
||||
|
||||
Faker<LanguageInfoEntity> language = new Faker<LanguageInfoEntity>()
|
||||
.CustomInstantiator(f => new LanguageInfoEntity(
|
||||
Faker<LanguageInfoDto> language = new Faker<LanguageInfoDto>()
|
||||
.CustomInstantiator(f => new LanguageInfoDto(
|
||||
default!,
|
||||
default!,
|
||||
default
|
||||
@@ -120,8 +120,8 @@ public class AddBookRequestFixture
|
||||
.RuleFor(e => e.LanguageCode, f => f.Random.String2(2))
|
||||
.RuleFor(e => e.NativeName, f => f.Random.String2(f.Random.Number(1, 50)));
|
||||
|
||||
Faker<LanguageInfoEntity> originalLanguage = new Faker<LanguageInfoEntity>()
|
||||
.CustomInstantiator(f => new LanguageInfoEntity(
|
||||
Faker<LanguageInfoDto> originalLanguage = new Faker<LanguageInfoDto>()
|
||||
.CustomInstantiator(f => new LanguageInfoDto(
|
||||
default!,
|
||||
default!,
|
||||
default
|
||||
@@ -130,8 +130,8 @@ public class AddBookRequestFixture
|
||||
.RuleFor(e => e.LanguageCode, f => f.Random.String2(2))
|
||||
.RuleFor(e => e.NativeName, f => f.Random.String2(f.Random.Number(1, 50)));
|
||||
|
||||
Faker<WrittenContentMetadataEntity> metadata = new Faker<WrittenContentMetadataEntity>()
|
||||
.CustomInstantiator(f => new WrittenContentMetadataEntity(
|
||||
Faker<WrittenContentMetadataDto> metadata = new Faker<WrittenContentMetadataDto>()
|
||||
.CustomInstantiator(f => new WrittenContentMetadataDto(
|
||||
default!,
|
||||
default,
|
||||
default,
|
||||
@@ -154,8 +154,8 @@ public class AddBookRequestFixture
|
||||
.RuleFor(x => x.Publisher, f => f.Random.String2(f.Random.Number(1, 100)))
|
||||
.RuleFor(x => x.PageCount, _random.Next(100, 300));
|
||||
|
||||
Faker<IsbnEntity> isbn = new Faker<IsbnEntity>()
|
||||
.CustomInstantiator(f => new IsbnEntity(
|
||||
Faker<IsbnDto> isbn = new Faker<IsbnDto>()
|
||||
.CustomInstantiator(f => new IsbnDto(
|
||||
default!,
|
||||
default
|
||||
))
|
||||
@@ -172,7 +172,7 @@ public class AddBookRequestFixture
|
||||
int sum = 0;
|
||||
for (int i = 0; i < 12; i++)
|
||||
sum += (i % 2 == 0 ? 1 : 3) * int.Parse(isbn[i].ToString());
|
||||
int checkDigit = (10 - (sum % 10)) % 10;
|
||||
int checkDigit = (10 - sum % 10) % 10;
|
||||
return $"{prefix}-{group[..1]}-{publisher}-{title}-{checkDigit}";
|
||||
}
|
||||
else
|
||||
@@ -183,7 +183,7 @@ public class AddBookRequestFixture
|
||||
int sum = 0;
|
||||
for (int i = 0; i < 9; i++)
|
||||
sum += (10 - i) * digits[i];
|
||||
int checkDigit = (11 - (sum % 11)) % 11;
|
||||
int checkDigit = (11 - sum % 11) % 11;
|
||||
string checkChar = checkDigit == 10 ? "X" : checkDigit.ToString();
|
||||
return $"{digits[0]}-{digits[1]}{digits[2]}-{digits[3]}{digits[4]}{digits[5]}{digits[6]}{digits[7]}{digits[8]}-{checkChar}";
|
||||
}
|
||||
+5
-5
@@ -1,16 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using AutoFixture;
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.UnitTests.Common.Setup;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook.Fixtures;
|
||||
namespace Lumina.Application.UnitTests.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookEntity"/> class.
|
||||
@@ -84,7 +84,7 @@ public class BookEntityFixture
|
||||
int sum = 0;
|
||||
for (int i = 0; i < 12; i++)
|
||||
sum += (i % 2 == 0 ? 1 : 3) * int.Parse(isbn[i].ToString());
|
||||
int checkDigit = (10 - (sum % 10)) % 10;
|
||||
int checkDigit = (10 - sum % 10) % 10;
|
||||
return $"{prefix}-{group[..1]}-{publisher}-{title}-{checkDigit}";
|
||||
}
|
||||
else
|
||||
@@ -95,7 +95,7 @@ public class BookEntityFixture
|
||||
int sum = 0;
|
||||
for (int i = 0; i < 9; i++)
|
||||
sum += (10 - i) * digits[i];
|
||||
int checkDigit = (11 - (sum % 11)) % 11;
|
||||
int checkDigit = (11 - sum % 11) % 11;
|
||||
string checkChar = checkDigit == 10 ? "X" : checkDigit.ToString();
|
||||
return $"{digits[0]}-{digits[1]}{digits[2]}-{digits[3]}{digits[4]}{digits[5]}{digits[6]}{digits[7]}{digits[8]}-{checkChar}";
|
||||
}
|
||||
+9
-5
@@ -14,20 +14,20 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook.Fixtures;
|
||||
namespace Lumina.Application.UnitTests.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Book"/> domain entity.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DomainBookFixture
|
||||
public class BookFixture
|
||||
{
|
||||
private readonly Fixture _fixture;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DomainBookFixture"/> class.
|
||||
/// Initializes a new instance of the <see cref="BookFixture"/> class.
|
||||
/// </summary>
|
||||
public DomainBookFixture()
|
||||
public BookFixture()
|
||||
{
|
||||
_fixture = new Fixture();
|
||||
_fixture.Customizations.Add(new DateOnlySpecimenBuilder());
|
||||
@@ -35,6 +35,10 @@ public class DomainBookFixture
|
||||
ConfigureCustomDomainTypes();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid book domain entity.
|
||||
/// </summary>
|
||||
/// <returns>The created book domain entity.</returns>
|
||||
public Book CreateDomainBook()
|
||||
{
|
||||
return Book.Create(
|
||||
@@ -69,7 +73,7 @@ public class DomainBookFixture
|
||||
int reReleaseYear = _fixture.Create<Generator<int>>().First(y => y >= originalYear && y <= 2025);
|
||||
|
||||
return ReleaseInfo.Create(
|
||||
Optional<DateOnly>.Some(DateOnly.FromDateTime(new DateTime(originalYear, 1, 1))),
|
||||
Optional<DateOnly>.Some(DateOnly.FromDateTime(new DateTime(originalYear, 1, 1))),
|
||||
Optional<int>.Some(originalYear),
|
||||
Optional<DateOnly>.Some(DateOnly.FromDateTime(new DateTime(reReleaseYear, 1, 1))),
|
||||
Optional<int>.Some(reReleaseYear),
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using AutoFixture;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Common.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookRatingDto"/>.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookRatingDtoFixture
|
||||
{
|
||||
private readonly Fixture _fixture;
|
||||
private readonly Random _random = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BookRatingDtoFixture"/> class.
|
||||
/// </summary>
|
||||
public BookRatingDtoFixture()
|
||||
{
|
||||
_fixture = new Fixture();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a complete book rating DTO with all properties.
|
||||
/// </summary>
|
||||
/// <returns>The created book rating DTO.</returns>
|
||||
public BookRatingDto CreateComplete()
|
||||
{
|
||||
return new BookRatingDto(
|
||||
_random.Next(1, 5),
|
||||
5,
|
||||
_fixture.Create<BookRatingSource>(),
|
||||
_random.Next(1, 1000)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a minimal book rating DTO with only required properties.
|
||||
/// </summary>
|
||||
/// <returns>The created book rating DTO.</returns>
|
||||
public BookRatingDto CreateMinimal()
|
||||
{
|
||||
return new BookRatingDto(
|
||||
_random.Next(1, 5),
|
||||
5,
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an invalid book rating DTO.
|
||||
/// </summary>
|
||||
/// <returns>The created invalid book rating DTO.</returns>
|
||||
public BookRatingDto CreateInvalid()
|
||||
{
|
||||
return new BookRatingDto(
|
||||
10, // invalid: value > maxValue
|
||||
5,
|
||||
_fixture.Create<BookRatingSource>(),
|
||||
_random.Next(1, 1000)
|
||||
);
|
||||
}
|
||||
}
|
||||
+10
-27
@@ -1,13 +1,12 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using AutoFixture;
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.Common.Fixtures;
|
||||
namespace Lumina.Application.UnitTests.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Common.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookRatingEntity"/>.
|
||||
@@ -15,7 +14,6 @@ namespace Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.C
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookRatingEntityFixture
|
||||
{
|
||||
private readonly Fixture _fixture;
|
||||
private readonly Random _random = new();
|
||||
private readonly Faker _faker;
|
||||
|
||||
@@ -24,49 +22,34 @@ public class BookRatingEntityFixture
|
||||
/// </summary>
|
||||
public BookRatingEntityFixture()
|
||||
{
|
||||
_fixture = new Fixture();
|
||||
_faker = new Faker();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a complete book rating entity with all properties.
|
||||
/// Creates a book rating entity.
|
||||
/// </summary>
|
||||
/// <returns>The created book rating entity.</returns>
|
||||
public BookRatingEntity CreateComplete()
|
||||
public BookRatingEntity CreateBookRating()
|
||||
{
|
||||
return new BookRatingEntity(
|
||||
_random.Next(1, 5),
|
||||
5,
|
||||
_fixture.Create<BookRatingSource>(),
|
||||
_faker.PickRandom<BookRatingSource>(),
|
||||
_random.Next(1, 1000)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a minimal book rating entity with only required properties.
|
||||
/// </summary>
|
||||
/// <returns>The created book rating entity.</returns>
|
||||
public BookRatingEntity CreateMinimal()
|
||||
{
|
||||
return new BookRatingEntity(
|
||||
_random.Next(1, 5),
|
||||
5,
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an invalid book rating entity.
|
||||
/// </summary>
|
||||
/// <returns>The created invalid book rating entity.</returns>
|
||||
public BookRatingEntity CreateInvalid()
|
||||
public BookRatingEntity CreateInvalidBookRating()
|
||||
{
|
||||
return new BookRatingEntity(
|
||||
10, // invalid: value > maxValue
|
||||
5,
|
||||
_fixture.Create<BookRatingSource>(),
|
||||
_random.Next(1, 1000)
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.Common.Fixtures;
|
||||
namespace Lumina.Application.UnitTests.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Common.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookRating"/> domain entity.
|
||||
+20
-20
@@ -1,51 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.Common.Fixtures;
|
||||
namespace Lumina.Application.UnitTests.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Common.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="IsbnEntity"/>.
|
||||
/// Fixture class for the <see cref="IsbnDto"/>.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class IsbnEntityFixture
|
||||
public class IsbnDtoFixture
|
||||
{
|
||||
private readonly Random _random = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a valid ISBN-10 entity.
|
||||
/// Creates a valid ISBN-10 DTO.
|
||||
/// </summary>
|
||||
/// <returns>The created ISBN entity.</returns>
|
||||
public IsbnEntity CreateIsbn10()
|
||||
/// <returns>The created ISBN DTO.</returns>
|
||||
public IsbnDto CreateIsbn10()
|
||||
{
|
||||
return new IsbnEntity(
|
||||
return new IsbnDto(
|
||||
GenerateValidIsbn10(),
|
||||
IsbnFormat.Isbn10
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a valid ISBN-13 entity.
|
||||
/// Creates a valid ISBN-13 DTO.
|
||||
/// </summary>
|
||||
/// <returns>The created ISBN entity.</returns>
|
||||
public IsbnEntity CreateIsbn13()
|
||||
/// <returns>The created ISBN DTO.</returns>
|
||||
public IsbnDto CreateIsbn13()
|
||||
{
|
||||
return new IsbnEntity(
|
||||
return new IsbnDto(
|
||||
GenerateValidIsbn13(),
|
||||
IsbnFormat.Isbn13
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an invalid ISBN entity.
|
||||
/// Creates an invalid ISBN DTO.
|
||||
/// </summary>
|
||||
/// <returns>The created invalid ISBN entity.</returns>
|
||||
public IsbnEntity CreateInvalid()
|
||||
/// <returns>The created invalid ISBN DTO.</returns>
|
||||
public IsbnDto CreateInvalid()
|
||||
{
|
||||
return new IsbnEntity(
|
||||
return new IsbnDto(
|
||||
"invalid-isbn",
|
||||
IsbnFormat.Isbn13
|
||||
);
|
||||
@@ -55,9 +55,9 @@ public class IsbnEntityFixture
|
||||
/// Creates an ISBN entity without format.
|
||||
/// </summary>
|
||||
/// <returns>The created ISBN entity.</returns>
|
||||
public IsbnEntity CreateWithoutFormat()
|
||||
public IsbnDto CreateWithoutFormat()
|
||||
{
|
||||
return new IsbnEntity(
|
||||
return new IsbnDto(
|
||||
GenerateValidIsbn13(),
|
||||
null
|
||||
);
|
||||
@@ -73,7 +73,7 @@ public class IsbnEntityFixture
|
||||
for (int i = 0; i < 9; i++)
|
||||
sum += (10 - i) * digits[i];
|
||||
|
||||
int checkDigit = (11 - (sum % 11)) % 11;
|
||||
int checkDigit = (11 - sum % 11) % 11;
|
||||
string checkChar = checkDigit == 10 ? "X" : checkDigit.ToString();
|
||||
|
||||
return $"{digits[0]}-{digits[1]}{digits[2]}-{digits[3]}{digits[4]}{digits[5]}{digits[6]}{digits[7]}{digits[8]}-{checkChar}";
|
||||
@@ -91,7 +91,7 @@ public class IsbnEntityFixture
|
||||
for (int i = 0; i < 12; i++)
|
||||
sum += (i % 2 == 0 ? 1 : 3) * int.Parse(isbn[i].ToString());
|
||||
|
||||
int checkDigit = (10 - (sum % 10)) % 10;
|
||||
int checkDigit = (10 - sum % 10) % 10;
|
||||
|
||||
return $"{prefix}-{group[..1]}-{publisher}-{title}-{checkDigit}";
|
||||
}
|
||||
+3
-3
@@ -5,7 +5,7 @@ using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.Common.Fixtures;
|
||||
namespace Lumina.Application.UnitTests.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Common.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Isbn"/> domain entity.
|
||||
@@ -45,7 +45,7 @@ public class IsbnFixture
|
||||
for (int i = 0; i < 9; i++)
|
||||
sum += (10 - i) * digits[i];
|
||||
|
||||
int checkDigit = (11 - (sum % 11)) % 11;
|
||||
int checkDigit = (11 - sum % 11) % 11;
|
||||
string checkChar = checkDigit == 10 ? "X" : checkDigit.ToString();
|
||||
|
||||
return $"{digits[0]}-{digits[1]}{digits[2]}-{digits[3]}{digits[4]}{digits[5]}{digits[6]}{digits[7]}{digits[8]}-{checkChar}";
|
||||
@@ -63,7 +63,7 @@ public class IsbnFixture
|
||||
for (int i = 0; i < 12; i++)
|
||||
sum += (i % 2 == 0 ? 1 : 3) * int.Parse(isbn[i].ToString());
|
||||
|
||||
int checkDigit = (10 - (sum % 10)) % 10;
|
||||
int checkDigit = (10 - sum % 10) % 10;
|
||||
|
||||
return $"{prefix}-{group[..1]}-{publisher}-{title}-{checkDigit}";
|
||||
}
|
||||
Reference in new issue
Block a user