mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 21:11:10 +00:00
Implements tests for commit 525ac1348d
Covers the favorites feature and the playlist and favorite pagination changes with unit, integration and security tests, and fixtures for the new request, response, DTO and entity types. Also fixes the issues found while covering the commit: declares FavoriteMediaKind.None as the default value and rejects it in every favorite operation; queues the favorite added domain event only after the persisted favorite is read back; and preserves the private, no-store cache header on view pages after the antiforgery and session middlewares overwrite it.
This commit is contained in:
1 parent
468f1846f1
commit
394f6b510c
135 files changed
+19167
-13
No files matched your search
+61
@@ -0,0 +1,61 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteItemDisplayDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteItemDisplayDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="FavoriteItemDisplayDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that contains the media item.</param>
|
||||
/// <param name="title">Optional. The title of the media item.</param>
|
||||
/// <param name="collectionId">Optional. The Id of the collection that contains the media item.</param>
|
||||
/// <param name="collectionTitle">Optional. The title of the collection that contains the media item.</param>
|
||||
/// <param name="creatorId">Optional. The Id of the creator of the media item.</param>
|
||||
/// <param name="creatorName">Optional. The name of the creator of the media item.</param>
|
||||
/// <param name="coverPath">Optional. The path of the cover art of the media item.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="FavoriteItemDisplayDto"/>.</returns>
|
||||
public FavoriteItemDisplayDto Create(
|
||||
Guid? libraryId = null,
|
||||
string? title = null,
|
||||
Guid? collectionId = null,
|
||||
string? collectionTitle = null,
|
||||
Guid? creatorId = null,
|
||||
string? creatorName = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new FavoriteItemDisplayDto(
|
||||
libraryId ?? _faker.Random.Guid(),
|
||||
title ?? _faker.Lorem.Sentence(3),
|
||||
collectionId ?? _faker.Random.Guid(),
|
||||
collectionTitle ?? _faker.Lorem.Sentence(3),
|
||||
creatorId ?? _faker.Random.Guid(),
|
||||
creatorName ?? _faker.Name.FullName(),
|
||||
includeCoverPath ? (coverPath ?? $"/covers/{_faker.Random.Guid()}.jpg") : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="FavoriteItemDisplayDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteItemDisplayDto"/> instances.</returns>
|
||||
public List<FavoriteItemDisplayDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Favorites;
|
||||
using Lumina.Application.Common.DTO.Favorites;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Favorites;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteItemDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteItemDtoFixture
|
||||
{
|
||||
private readonly FavoriteEntityFixture _favoriteEntityFixture = new();
|
||||
private readonly FavoriteItemDisplayDtoFixture _favoriteItemDisplayDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="FavoriteItemDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="favorite">Optional. The stored favorite.</param>
|
||||
/// <param name="display">Optional. The display data of the referenced media item.</param>
|
||||
/// <param name="includeDisplay">Whether the display data should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="FavoriteItemDto"/>.</returns>
|
||||
public FavoriteItemDto Create(
|
||||
FavoriteEntity? favorite = null,
|
||||
FavoriteItemDisplayDto? display = null,
|
||||
bool includeDisplay = true)
|
||||
{
|
||||
return new FavoriteItemDto(
|
||||
favorite ?? _favoriteEntityFixture.Create(),
|
||||
includeDisplay ? (display ?? _favoriteItemDisplayDtoFixture.Create()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="FavoriteItemDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteItemDto"/> instances.</returns>
|
||||
public List<FavoriteItemDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Playlists;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.DTO.Playlists;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Playlists;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistDetailsDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistDetailsDtoFixture
|
||||
{
|
||||
private readonly PlaylistEntityFixture _playlistEntityFixture = new();
|
||||
private readonly PlaylistEntryDtoFixture _playlistEntryDtoFixture = new();
|
||||
private readonly PaginatedResultDtoFixture<PlaylistEntryDto> _paginatedResultDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistDetailsDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="playlist">Optional. The stored playlist.</param>
|
||||
/// <param name="entries">Optional. The requested page of entries. Defaults to a page of random entries.</param>
|
||||
/// <returns>The created <see cref="PlaylistDetailsDto"/>.</returns>
|
||||
public PlaylistDetailsDto Create(
|
||||
PlaylistEntity? playlist = null,
|
||||
PaginatedResultDto<PlaylistEntryDto>? entries = null)
|
||||
{
|
||||
List<PlaylistEntryDto> entryDtos = _playlistEntryDtoFixture.CreateMany();
|
||||
return new PlaylistDetailsDto(
|
||||
playlist ?? _playlistEntityFixture.Create(),
|
||||
entries ?? _paginatedResultDtoFixture.Create(data: entryDtos, count: entryDtos.Count));
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryDisplayDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryDisplayDtoFixture
|
||||
{
|
||||
private const int MAXIMUM_DURATION_SECONDS = 36_000;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistEntryDisplayDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="trackId">Optional. The Id of the track.</param>
|
||||
/// <param name="trackTitle">Optional. The title of the track.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the track, in seconds. Defaults to a bounded random duration.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that contains the track.</param>
|
||||
/// <param name="albumId">Optional. The Id of the album that contains the track.</param>
|
||||
/// <param name="albumTitle">Optional. The title of the album that contains the track.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist that produced the track.</param>
|
||||
/// <param name="artistName">Optional. The name of the artist that produced the track.</param>
|
||||
/// <param name="coverPath">Optional. The path of the cover art of the album.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PlaylistEntryDisplayDto"/>.</returns>
|
||||
public PlaylistEntryDisplayDto Create(
|
||||
Guid? trackId = null,
|
||||
string? trackTitle = null,
|
||||
int? durationInSeconds = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? albumId = null,
|
||||
string? albumTitle = null,
|
||||
Guid? artistId = null,
|
||||
string? artistName = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new PlaylistEntryDisplayDto(
|
||||
trackId ?? _faker.Random.Guid(),
|
||||
trackTitle ?? _faker.Lorem.Sentence(3),
|
||||
durationInSeconds ?? _faker.Random.Int(0, MAXIMUM_DURATION_SECONDS),
|
||||
libraryId ?? _faker.Random.Guid(),
|
||||
albumId ?? _faker.Random.Guid(),
|
||||
albumTitle ?? _faker.Lorem.Sentence(3),
|
||||
artistId ?? _faker.Random.Guid(),
|
||||
artistName ?? _faker.Name.FullName(),
|
||||
includeCoverPath ? (coverPath ?? $"/covers/{_faker.Random.Guid()}.jpg") : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistEntryDisplayDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntryDisplayDto"/> instances.</returns>
|
||||
public List<PlaylistEntryDisplayDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Playlists;
|
||||
using Lumina.Application.Common.DTO.Playlists;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.Playlists;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly PlaylistEntryEntityFixture _playlistEntryEntityFixture = new();
|
||||
private readonly PlaylistEntryDisplayDtoFixture _playlistEntryDisplayDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistEntryDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="entry">Optional. The stored playlist entry.</param>
|
||||
/// <param name="display">Optional. The display data of the referenced media item.</param>
|
||||
/// <param name="displayPosition">Optional. The dense zero based position shown to the client.</param>
|
||||
/// <param name="includeDisplay">Whether the display data should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PlaylistEntryDto"/>.</returns>
|
||||
public PlaylistEntryDto Create(
|
||||
PlaylistEntryEntity? entry = null,
|
||||
PlaylistEntryDisplayDto? display = null,
|
||||
int? displayPosition = null,
|
||||
bool includeDisplay = true)
|
||||
{
|
||||
return new PlaylistEntryDto(
|
||||
entry ?? _playlistEntryEntityFixture.Create(),
|
||||
includeDisplay ? (display ?? _playlistEntryDisplayDtoFixture.Create()) : null,
|
||||
displayPosition ?? _faker.Random.Int(0, 1_000));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistEntryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntryDto"/> instances.</returns>
|
||||
public List<PlaylistEntryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Favorites;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="FavoriteEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the favorite.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the favorite.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of the favorited media item. Defaults to a random supported kind.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the favorited media item.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the favorite was created. Defaults to a moment in the past.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the row.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the favorite was last updated. Defaults to a moment at or after the creation date.</param>
|
||||
/// <param name="updatedBy">Optional. The Id of the user that last updated the row.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedBy">Whether the updating user Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="FavoriteEntity"/>.</returns>
|
||||
public FavoriteEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? userId = null,
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
Guid? mediaItemId = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
Guid? createdBy = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
Guid? updatedBy = null,
|
||||
bool includeUpdatedOnUtc = true,
|
||||
bool includeUpdatedBy = true)
|
||||
{
|
||||
DateTime resolvedCreatedOnUtc = createdOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).AddMinutes(-_faker.Random.Int(0, 59));
|
||||
|
||||
return new FavoriteEntity
|
||||
{
|
||||
Id = id ?? _faker.Random.Guid(),
|
||||
UserId = userId ?? _faker.Random.Guid(),
|
||||
MediaKind = mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
|
||||
MediaItemId = mediaItemId ?? _faker.Random.Guid(),
|
||||
CreatedOnUtc = resolvedCreatedOnUtc,
|
||||
CreatedBy = createdBy ?? _faker.Random.Guid(),
|
||||
UpdatedOnUtc = includeUpdatedOnUtc ? (updatedOnUtc ?? resolvedCreatedOnUtc.AddMinutes(_faker.Random.Int(0, 120))) : null,
|
||||
UpdatedBy = includeUpdatedBy ? (updatedBy ?? _faker.Random.Guid()) : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="FavoriteEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteEntity"/> instances.</returns>
|
||||
public List<FavoriteEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.Favorites.Commands.AddFavorite;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Favorites.Commands.AddFavorite;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddFavoriteCommand"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddFavoriteCommandFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AddFavoriteCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional. The kind of the media item to favorite. Defaults to a supported kind.</param>
|
||||
/// <param name="mediaItemId">Optional. The unique identifier of the media item to favorite.</param>
|
||||
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMediaItemId">Whether the media item Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="AddFavoriteCommand"/>.</returns>
|
||||
public AddFavoriteCommand Create(
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
Guid? mediaItemId = null,
|
||||
bool includeMediaKind = true,
|
||||
bool includeMediaItemId = true)
|
||||
{
|
||||
return new AddFavoriteCommand(
|
||||
includeMediaKind ? (mediaKind ?? FavoriteMediaKind.MusicTrack) : null,
|
||||
includeMediaItemId ? (mediaItemId ?? _faker.Random.Guid()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AddFavoriteCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AddFavoriteCommand"/> instances.</returns>
|
||||
public List<AddFavoriteCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.Favorites.Commands.RemoveFavorite;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Favorites.Commands.RemoveFavorite;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="RemoveFavoriteCommand"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RemoveFavoriteCommandFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="RemoveFavoriteCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional. The name of the kind of the favorited media item. Defaults to the name of a supported kind.</param>
|
||||
/// <param name="mediaItemId">Optional. The unique identifier of the favorited media item.</param>
|
||||
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMediaItemId">Whether the media item Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="RemoveFavoriteCommand"/>.</returns>
|
||||
public RemoveFavoriteCommand Create(
|
||||
string? mediaKind = null,
|
||||
string? mediaItemId = null,
|
||||
bool includeMediaKind = true,
|
||||
bool includeMediaItemId = true)
|
||||
{
|
||||
return new RemoveFavoriteCommand(
|
||||
includeMediaKind ? (mediaKind ?? nameof(FavoriteMediaKind.MusicTrack)) : null,
|
||||
includeMediaItemId ? (mediaItemId ?? _faker.Random.Guid().ToString()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="RemoveFavoriteCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="RemoveFavoriteCommand"/> instances.</returns>
|
||||
public List<RemoveFavoriteCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.Favorites.Queries.GetFavoriteStatus;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Favorites.Queries.GetFavoriteStatus;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetFavoriteStatusQuery"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetFavoriteStatusQueryFixture
|
||||
{
|
||||
private const int DEFAULT_MEDIA_ITEM_COUNT = 3;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetFavoriteStatusQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional. The kind of the media items to check. Defaults to a supported kind.</param>
|
||||
/// <param name="mediaItemIds">Optional. The unique identifiers of the media items to check. Defaults to a bounded list of random Ids.</param>
|
||||
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMediaItemIds">Whether the media item Ids should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="GetFavoriteStatusQuery"/>.</returns>
|
||||
public GetFavoriteStatusQuery Create(
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
IReadOnlyList<Guid>? mediaItemIds = null,
|
||||
bool includeMediaKind = true,
|
||||
bool includeMediaItemIds = true)
|
||||
{
|
||||
return new GetFavoriteStatusQuery(
|
||||
includeMediaKind ? (mediaKind ?? FavoriteMediaKind.MusicTrack) : null,
|
||||
includeMediaItemIds ? (mediaItemIds ?? CreateRandomMediaItemIds()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetFavoriteStatusQuery"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetFavoriteStatusQuery"/> instances.</returns>
|
||||
public List<GetFavoriteStatusQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a bounded list of random media item Ids.
|
||||
/// </summary>
|
||||
/// <returns>The created list of media item Ids.</returns>
|
||||
private List<Guid> CreateRandomMediaItemIds()
|
||||
{
|
||||
return [.. Enumerable.Range(0, DEFAULT_MEDIA_ITEM_COUNT).Select(_ => _faker.Random.Guid())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Favorites.Queries.GetFavorites;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Favorites.Queries.GetFavorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetFavoritesQuery"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetFavoritesQueryFixture
|
||||
{
|
||||
private readonly PaginationDataDtoFixture _paginationDataDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetFavoritesQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional. The kind of media item to restrict the favorites to. Defaults to a supported kind.</param>
|
||||
/// <param name="paginationData">Optional. The object containing the requested pagination data. Defaults to a random page.</param>
|
||||
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePaginationData">Whether the pagination data should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="GetFavoritesQuery"/>.</returns>
|
||||
public GetFavoritesQuery Create(
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
PaginationDataDto? paginationData = null,
|
||||
bool includeMediaKind = true,
|
||||
bool includePaginationData = true)
|
||||
{
|
||||
return new GetFavoritesQuery(
|
||||
includeMediaKind ? (mediaKind ?? FavoriteMediaKind.MusicTrack) : null,
|
||||
includePaginationData ? (paginationData ?? _paginationDataDtoFixture.Create()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetFavoritesQuery"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetFavoritesQuery"/> instances.</returns>
|
||||
public List<GetFavoritesQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.Playlists.Commands.CreatePlaylist;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Playlists.Commands.CreatePlaylist;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="CreatePlaylistCommand"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class CreatePlaylistCommandFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="CreatePlaylistCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The name of the playlist.</param>
|
||||
/// <param name="description">Optional. The optional description of the playlist.</param>
|
||||
/// <param name="type">Optional. The kind of media the playlist holds. Defaults to the only supported kind.</param>
|
||||
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeType">Whether the media type should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="CreatePlaylistCommand"/>.</returns>
|
||||
public CreatePlaylistCommand Create(
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
PlaylistType? type = null,
|
||||
bool includeDescription = true,
|
||||
bool includeType = true)
|
||||
{
|
||||
return new CreatePlaylistCommand(
|
||||
name ?? _faker.Lorem.Sentence(3),
|
||||
includeDescription ? (description ?? _faker.Lorem.Sentence()) : null,
|
||||
includeType ? (type ?? PlaylistType.Music) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="CreatePlaylistCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="CreatePlaylistCommand"/> instances.</returns>
|
||||
public List<CreatePlaylistCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.Playlists.Queries.GetPlaylist;
|
||||
using Lumina.Application.Fixtures.Common.DTO.Pagination;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Playlists.Queries.GetPlaylist;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetPlaylistQuery"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetPlaylistQueryFixture
|
||||
{
|
||||
private readonly PaginationDataDtoFixture _paginationDataDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetPlaylistQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional. The unique identifier of the playlist. Defaults to a random Guid.</param>
|
||||
/// <param name="paginationData">Optional. The object containing the requested pagination data. Defaults to a random page.</param>
|
||||
/// <param name="includePlaylistId">Whether the playlist Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePaginationData">Whether the pagination data should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="GetPlaylistQuery"/>.</returns>
|
||||
public GetPlaylistQuery Create(
|
||||
string? playlistId = null,
|
||||
PaginationDataDto? paginationData = null,
|
||||
bool includePlaylistId = true,
|
||||
bool includePaginationData = true)
|
||||
{
|
||||
return new GetPlaylistQuery(
|
||||
includePlaylistId ? (playlistId ?? Guid.NewGuid().ToString()) : null,
|
||||
includePaginationData ? (paginationData ?? _paginationDataDtoFixture.Create()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetPlaylistQuery"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetPlaylistQuery"/> instances.</returns>
|
||||
public List<GetPlaylistQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.Favorites;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddFavoriteRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddFavoriteRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AddFavoriteRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional. The kind of the media item to favorite. Defaults to a random supported kind.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the media item to favorite.</param>
|
||||
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMediaItemId">Whether the media item Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="AddFavoriteRequest"/>.</returns>
|
||||
public AddFavoriteRequest Create(
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
Guid? mediaItemId = null,
|
||||
bool includeMediaKind = true,
|
||||
bool includeMediaItemId = true)
|
||||
{
|
||||
return new AddFavoriteRequest(
|
||||
includeMediaKind ? (mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds)) : null,
|
||||
includeMediaItemId ? (mediaItemId ?? _faker.Random.Guid()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AddFavoriteRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AddFavoriteRequest"/> instances.</returns>
|
||||
public List<AddFavoriteRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.Favorites;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetFavoriteStatusRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetFavoriteStatusRequestFixture
|
||||
{
|
||||
private const int DEFAULT_MEDIA_ITEM_COUNT = 3;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetFavoriteStatusRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional. The kind of the media items to check. Defaults to a random supported kind.</param>
|
||||
/// <param name="mediaItemIds">Optional. The Ids of the media items to check. Defaults to a bounded list of random Ids.</param>
|
||||
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMediaItemIds">Whether the media item Ids should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="GetFavoriteStatusRequest"/>.</returns>
|
||||
public GetFavoriteStatusRequest Create(
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
List<Guid>? mediaItemIds = null,
|
||||
bool includeMediaKind = true,
|
||||
bool includeMediaItemIds = true)
|
||||
{
|
||||
return new GetFavoriteStatusRequest(
|
||||
includeMediaKind ? (mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds)) : null,
|
||||
includeMediaItemIds ? (mediaItemIds ?? CreateRandomMediaItemIds()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetFavoriteStatusRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetFavoriteStatusRequest"/> instances.</returns>
|
||||
public List<GetFavoriteStatusRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a bounded list of random media item Ids.
|
||||
/// </summary>
|
||||
/// <returns>The created list of media item Ids.</returns>
|
||||
private List<Guid> CreateRandomMediaItemIds()
|
||||
{
|
||||
return [.. Enumerable.Range(0, DEFAULT_MEDIA_ITEM_COUNT).Select(_ => _faker.Random.Guid())];
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.Favorites;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetFavoritesRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetFavoritesRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetFavoritesRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional. The kind of media item to restrict the favorites to. Defaults to a random supported kind.</param>
|
||||
/// <param name="currentPage">Optional. The one based page of favorites to return. Defaults to a bounded random page.</param>
|
||||
/// <param name="perPage">Optional. The number of favorites per page. Defaults to a bounded random page size.</param>
|
||||
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeCurrentPage">Whether the current page should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePerPage">Whether the per page count should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="GetFavoritesRequest"/>.</returns>
|
||||
public GetFavoritesRequest Create(
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
int? currentPage = null,
|
||||
int? perPage = null,
|
||||
bool includeMediaKind = true,
|
||||
bool includeCurrentPage = true,
|
||||
bool includePerPage = true)
|
||||
{
|
||||
return new GetFavoritesRequest(
|
||||
includeMediaKind ? (mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds)) : null,
|
||||
includeCurrentPage ? (currentPage ?? _faker.Random.Int(1, 100)) : null,
|
||||
includePerPage ? (perPage ?? _faker.Random.Int(1, 200)) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetFavoritesRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetFavoritesRequest"/> instances.</returns>
|
||||
public List<GetFavoritesRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.Playlists;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetPlaylistRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetPlaylistRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetPlaylistRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="currentPage">Optional. The one based page of entries to return. Defaults to a bounded random page.</param>
|
||||
/// <param name="perPage">Optional. The number of entries per page. Defaults to a bounded random page size.</param>
|
||||
/// <param name="includeCurrentPage">Whether the current page should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePerPage">Whether the per page count should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="GetPlaylistRequest"/>.</returns>
|
||||
public GetPlaylistRequest Create(
|
||||
int? currentPage = null,
|
||||
int? perPage = null,
|
||||
bool includeCurrentPage = true,
|
||||
bool includePerPage = true)
|
||||
{
|
||||
return new GetPlaylistRequest(
|
||||
includeCurrentPage ? (currentPage ?? _faker.Random.Int(1, 100)) : null,
|
||||
includePerPage ? (perPage ?? _faker.Random.Int(1, 200)) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetPlaylistRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetPlaylistRequest"/> instances.</returns>
|
||||
public List<GetPlaylistRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Favorites;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteItemResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteItemResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="FavoriteItemResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional. The kind of the favorited media item. Defaults to a random supported kind.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the favorited media item.</param>
|
||||
/// <param name="isAvailable">Optional. Whether the media item is available.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that contains the media item.</param>
|
||||
/// <param name="title">Optional. The title of the media item.</param>
|
||||
/// <param name="collectionId">Optional. The Id of the collection that contains the media item.</param>
|
||||
/// <param name="collectionTitle">Optional. The title of the collection that contains the media item.</param>
|
||||
/// <param name="creatorId">Optional. The Id of the creator of the media item.</param>
|
||||
/// <param name="creatorName">Optional. The name of the creator of the media item.</param>
|
||||
/// <param name="coverPath">Optional. The path of the cover art of the media item.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="FavoriteItemResponse"/>.</returns>
|
||||
public FavoriteItemResponse Create(
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
Guid? mediaItemId = null,
|
||||
bool? isAvailable = null,
|
||||
Guid? libraryId = null,
|
||||
string? title = null,
|
||||
Guid? collectionId = null,
|
||||
string? collectionTitle = null,
|
||||
Guid? creatorId = null,
|
||||
string? creatorName = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new FavoriteItemResponse(
|
||||
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
|
||||
mediaItemId ?? _faker.Random.Guid(),
|
||||
isAvailable ?? _faker.Random.Bool(),
|
||||
libraryId ?? _faker.Random.Guid(),
|
||||
title ?? _faker.Lorem.Sentence(3),
|
||||
collectionId ?? _faker.Random.Guid(),
|
||||
collectionTitle ?? _faker.Lorem.Sentence(3),
|
||||
creatorId ?? _faker.Random.Guid(),
|
||||
creatorName ?? _faker.Name.FullName(),
|
||||
includeCoverPath ? (coverPath ?? $"/covers/{_faker.Random.Guid()}.jpg") : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="FavoriteItemResponse"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteItemResponse"/> instances.</returns>
|
||||
public List<FavoriteItemResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Favorites;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="FavoriteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the favorite.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of the favorited media item. Defaults to a random supported kind.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the favorited media item.</param>
|
||||
/// <param name="favoritedOnUtc">Optional. The date and time when the media item was favorited. Defaults to a moment in the past.</param>
|
||||
/// <returns>The created <see cref="FavoriteResponse"/>.</returns>
|
||||
public FavoriteResponse Create(
|
||||
Guid? id = null,
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
Guid? mediaItemId = null,
|
||||
DateTime? favoritedOnUtc = null)
|
||||
{
|
||||
return new FavoriteResponse(
|
||||
id ?? _faker.Random.Guid(),
|
||||
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
|
||||
mediaItemId ?? _faker.Random.Guid(),
|
||||
favoritedOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).AddMinutes(-_faker.Random.Int(0, 59)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="FavoriteResponse"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteResponse"/> instances.</returns>
|
||||
public List<FavoriteResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteStatusResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteStatusResponseFixture
|
||||
{
|
||||
private const int DEFAULT_FAVORITED_COUNT = 3;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="FavoriteStatusResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="favoritedMediaItemIds">Optional. The Ids of the media items that are favorites. Defaults to a bounded list of random Ids.</param>
|
||||
/// <returns>The created <see cref="FavoriteStatusResponse"/>.</returns>
|
||||
public FavoriteStatusResponse Create(IReadOnlyList<Guid>? favoritedMediaItemIds = null)
|
||||
{
|
||||
return new FavoriteStatusResponse(
|
||||
favoritedMediaItemIds ?? CreateRandomMediaItemIds());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="FavoriteStatusResponse"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteStatusResponse"/> instances.</returns>
|
||||
public List<FavoriteStatusResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a bounded list of random media item Ids.
|
||||
/// </summary>
|
||||
/// <returns>The created list of media item Ids.</returns>
|
||||
private List<Guid> CreateRandomMediaItemIds()
|
||||
{
|
||||
return [.. Enumerable.Range(0, DEFAULT_FAVORITED_COUNT).Select(_ => _faker.Random.Guid())];
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Playlists;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistEntryResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the entry.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the media item referenced by the entry.</param>
|
||||
/// <param name="mediaItemType">Optional. The kind of media item referenced by the entry.</param>
|
||||
/// <param name="position">Optional. The zero based position of the entry in the playlist.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that contains the media item.</param>
|
||||
/// <param name="collectionId">Optional. The Id of the collection that contains the media item.</param>
|
||||
/// <param name="creatorId">Optional. The Id of the creator of the media item.</param>
|
||||
/// <param name="mediaItemTitle">Optional. The title of the media item.</param>
|
||||
/// <param name="collectionTitle">Optional. The title of the collection that contains the media item.</param>
|
||||
/// <param name="creatorName">Optional. The name of the creator of the media item.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the media item in seconds.</param>
|
||||
/// <param name="coverPath">Optional. The path of the cover art of the collection.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PlaylistEntryResponse"/>.</returns>
|
||||
public PlaylistEntryResponse Create(
|
||||
Guid? id = null,
|
||||
Guid? mediaItemId = null,
|
||||
PlaylistMediaItemType? mediaItemType = null,
|
||||
int? position = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? collectionId = null,
|
||||
Guid? creatorId = null,
|
||||
string? mediaItemTitle = null,
|
||||
string? collectionTitle = null,
|
||||
string? creatorName = null,
|
||||
int? durationInSeconds = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new PlaylistEntryResponse(
|
||||
id ?? _faker.Random.Guid(),
|
||||
mediaItemId ?? _faker.Random.Guid(),
|
||||
mediaItemType ?? _faker.PickRandom<PlaylistMediaItemType>(),
|
||||
position ?? _faker.Random.Int(0, 1_000),
|
||||
libraryId ?? _faker.Random.Guid(),
|
||||
collectionId ?? _faker.Random.Guid(),
|
||||
creatorId ?? _faker.Random.Guid(),
|
||||
mediaItemTitle ?? _faker.Lorem.Sentence(3),
|
||||
collectionTitle ?? _faker.Lorem.Sentence(2),
|
||||
creatorName ?? _faker.Name.FullName(),
|
||||
durationInSeconds ?? _faker.Random.Int(1, 3_600),
|
||||
includeCoverPath ? (coverPath ?? $"/covers/{_faker.Random.Guid()}.jpg") : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistEntryResponse"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntryResponse"/> instances.</returns>
|
||||
public List<PlaylistEntryResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Fixtures.Responses.Common;
|
||||
using Lumina.Contracts.Responses.Common;
|
||||
using Lumina.Contracts.Responses.Playlists;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistResponseFixture
|
||||
{
|
||||
private const int DEFAULT_ENTRY_COUNT = 3;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
private readonly PlaylistEntryResponseFixture _playlistEntryResponseFixture = new();
|
||||
private readonly PaginatedResponseFixture<PlaylistEntryResponse> _paginatedResponseFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the playlist.</param>
|
||||
/// <param name="name">Optional. The name of the playlist.</param>
|
||||
/// <param name="description">Optional. The description of the playlist.</param>
|
||||
/// <param name="type">Optional. The kind of media the playlist holds.</param>
|
||||
/// <param name="entries">Optional. The page of entries of the playlist.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the playlist was created.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PlaylistResponse"/>.</returns>
|
||||
public PlaylistResponse Create(
|
||||
Guid? id = null,
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
PlaylistType? type = null,
|
||||
PaginatedResponse<PlaylistEntryResponse>? entries = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeDescription = true,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
return new PlaylistResponse(
|
||||
id ?? _faker.Random.Guid(),
|
||||
name ?? _faker.Lorem.Sentence(3),
|
||||
includeDescription ? (description ?? _faker.Lorem.Sentence()) : null,
|
||||
type ?? PlaylistType.Music,
|
||||
entries ?? CreateEntriesPage(),
|
||||
createdOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)),
|
||||
includeUpdatedOnUtc ? (updatedOnUtc ?? DateTime.UtcNow.AddMinutes(-_faker.Random.Int(1, 1_440))) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistResponse"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistResponse"/> instances.</returns>
|
||||
public List<PlaylistResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a page of random playlist entries.
|
||||
/// </summary>
|
||||
/// <returns>The created page of playlist entries.</returns>
|
||||
private PaginatedResponse<PlaylistEntryResponse> CreateEntriesPage()
|
||||
{
|
||||
List<PlaylistEntryResponse> entries = [];
|
||||
for (int index = 0; index < DEFAULT_ENTRY_COUNT; index++)
|
||||
entries.Add(_playlistEntryResponseFixture.Create(position: index));
|
||||
|
||||
return _paginatedResponseFixture.Create(data: entries, currentPage: 1, perPage: DEFAULT_ENTRY_COUNT, count: DEFAULT_ENTRY_COUNT, numberOfPages: 1);
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaItemId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaItemIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaItemId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the media item Id.</param>
|
||||
/// <returns>The created <see cref="MediaItemId"/>.</returns>
|
||||
public MediaItemId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return MediaItemId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaItemId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaItemId"/> instances.</returns>
|
||||
public List<MediaItemId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UserId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UserId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the user Id.</param>
|
||||
/// <returns>The created <see cref="UserId"/>.</returns>
|
||||
public UserId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return UserId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UserId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="UserId"/> instances.</returns>
|
||||
public List<UserId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteAddedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteAddedDomainEventFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteIdFixture _favoriteIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="FavoriteAddedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="favoriteId">Optional. The unique identifier of the favorite.</param>
|
||||
/// <param name="userId">Optional. The unique identifier of the user that favorited the media item.</param>
|
||||
/// <param name="mediaItemId">Optional. The unique identifier of the favorited media item.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of the favorited media item. Defaults to a random supported kind.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="FavoriteAddedDomainEvent"/>.</returns>
|
||||
public FavoriteAddedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
FavoriteId? favoriteId = null,
|
||||
UserId? userId = null,
|
||||
MediaItemId? mediaItemId = null,
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new FavoriteAddedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
favoriteId ?? _favoriteIdFixture.Create(),
|
||||
userId ?? _userIdFixture.Create(),
|
||||
mediaItemId ?? _mediaItemIdFixture.Create(),
|
||||
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="FavoriteAddedDomainEvent"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteAddedDomainEvent"/> instances.</returns>
|
||||
public List<FavoriteAddedDomainEvent> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteRemovedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteRemovedDomainEventFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteIdFixture _favoriteIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="FavoriteRemovedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="favoriteId">Optional. The unique identifier of the removed favorite.</param>
|
||||
/// <param name="userId">Optional. The unique identifier of the user that owned the favorite.</param>
|
||||
/// <param name="mediaItemId">Optional. The unique identifier of the media item that was unfavorited.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of the media item that was unfavorited. Defaults to a random supported kind.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="FavoriteRemovedDomainEvent"/>.</returns>
|
||||
public FavoriteRemovedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
FavoriteId? favoriteId = null,
|
||||
UserId? userId = null,
|
||||
MediaItemId? mediaItemId = null,
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new FavoriteRemovedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
favoriteId ?? _favoriteIdFixture.Create(),
|
||||
userId ?? _userIdFixture.Create(),
|
||||
mediaItemId ?? _mediaItemIdFixture.Create(),
|
||||
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="FavoriteRemovedDomainEvent"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteRemovedDomainEvent"/> instances.</returns>
|
||||
public List<FavoriteRemovedDomainEvent> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Favorite"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteIdFixture _favoriteIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="Favorite"/> domain aggregate, with pre-existing data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the favorite.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the favorite.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the favorited media item.</param>
|
||||
/// <param name="mediaKind">Optional. The kind of the favorited media item. Defaults to a random supported kind.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the favorite was created. Defaults to a few days in the past.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the favorite was last updated. Defaults to a moment at or after the creation date, or to no value when <paramref name="includeUpdatedOnUtc"/> is <see langword="false"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether to generate an update date and time when <paramref name="updatedOnUtc"/> is not supplied.</param>
|
||||
/// <returns>The created <see cref="Favorite"/>.</returns>
|
||||
/// <remarks>
|
||||
/// The favorite is built through the rehydrating <see cref="Favorite.Create(FavoriteId, UserId, MediaItemId, FavoriteMediaKind, DateTime, Optional{DateTime})"/>
|
||||
/// overload, so it carries no domain events, is never marked as removed, and keeps whatever media kind it is given, including a planned one.
|
||||
/// </remarks>
|
||||
public Favorite Create(
|
||||
FavoriteId? id = null,
|
||||
UserId? userId = null,
|
||||
MediaItemId? mediaItemId = null,
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
Optional<DateTime>? updatedOnUtc = null,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
DateTime resolvedCreatedOnUtc = createdOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).AddMinutes(-_faker.Random.Int(0, 59));
|
||||
return Favorite.Create(
|
||||
id ?? _favoriteIdFixture.Create(),
|
||||
userId ?? _userIdFixture.Create(),
|
||||
mediaItemId ?? _mediaItemIdFixture.Create(),
|
||||
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
|
||||
resolvedCreatedOnUtc,
|
||||
ResolveUpdatedOnUtc(updatedOnUtc, includeUpdatedOnUtc, resolvedCreatedOnUtc)).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="Favorite"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="Favorite"/> instances.</returns>
|
||||
public List<Favorite> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the update date and time of the favorite, keeping it at or after the creation date and inside the date range.
|
||||
/// </summary>
|
||||
/// <param name="updatedOnUtc">The explicitly supplied update date and time, if any.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether to generate an update date and time when none is supplied.</param>
|
||||
/// <param name="createdOnUtc">The creation date and time of the favorite.</param>
|
||||
/// <returns>The resolved update date and time, or no value when the favorite was never updated.</returns>
|
||||
private Optional<DateTime> ResolveUpdatedOnUtc(Optional<DateTime>? updatedOnUtc, bool includeUpdatedOnUtc, DateTime createdOnUtc)
|
||||
{
|
||||
if (updatedOnUtc.HasValue)
|
||||
return updatedOnUtc.Value;
|
||||
if (!includeUpdatedOnUtc)
|
||||
return Optional<DateTime>.None();
|
||||
TimeSpan offsetFromCreation = TimeSpan.FromMinutes(_faker.Random.Int(0, 1440));
|
||||
return Optional<DateTime>.Some(DateTime.MaxValue - createdOnUtc < offsetFromCreation
|
||||
? DateTime.MaxValue
|
||||
: createdOnUtc.Add(offsetFromCreation));
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="FavoriteId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the favorite Id.</param>
|
||||
/// <returns>The created <see cref="FavoriteId"/>.</returns>
|
||||
public FavoriteId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return FavoriteId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="FavoriteId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteId"/> instances.</returns>
|
||||
public List<FavoriteId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Favorites;
|
||||
using Lumina.Presentation.Web.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="FavoriteDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional Id of the favorite.</param>
|
||||
/// <param name="mediaKind">Optional kind of the favorited media item.</param>
|
||||
/// <param name="mediaItemId">Optional Id of the favorited media item.</param>
|
||||
/// <param name="favoritedOnUtc">Optional date and time when the media item was favorited.</param>
|
||||
/// <returns>A configured <see cref="FavoriteDto"/> instance.</returns>
|
||||
public FavoriteDto Create(
|
||||
Guid? id = null,
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
Guid? mediaItemId = null,
|
||||
DateTime? favoritedOnUtc = null)
|
||||
{
|
||||
return new FavoriteDto(
|
||||
Id: id ?? _faker.Random.Guid(),
|
||||
MediaKind: mediaKind ?? _faker.PickRandom(_supportedMediaKinds),
|
||||
MediaItemId: mediaItemId ?? _faker.Random.Guid(),
|
||||
FavoritedOnUtc: favoritedOnUtc ?? _faker.Date.Between(new DateTime(2024, 1, 1), new DateTime(2026, 12, 31))
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="FavoriteDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteDto"/> instances.</returns>
|
||||
public List<FavoriteDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Favorites;
|
||||
using Lumina.Presentation.Web.Common.Enums.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteItemDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteItemDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="FavoriteItemDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional kind of the favorited media item.</param>
|
||||
/// <param name="mediaItemId">Optional Id of the favorited media item.</param>
|
||||
/// <param name="isAvailable">Optional value indicating whether the media item still exists and can be accessed by the user.</param>
|
||||
/// <param name="libraryId">Optional Id of the media library that contains the media item.</param>
|
||||
/// <param name="title">Optional title of the media item.</param>
|
||||
/// <param name="collectionId">Optional Id of the collection that contains the media item.</param>
|
||||
/// <param name="collectionTitle">Optional title of the collection that contains the media item.</param>
|
||||
/// <param name="creatorId">Optional Id of the creator of the media item.</param>
|
||||
/// <param name="creatorName">Optional name of the creator of the media item.</param>
|
||||
/// <param name="coverPath">Optional path of the cover art of the media item.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="FavoriteItemDto"/> instance.</returns>
|
||||
public FavoriteItemDto Create(
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
Guid? mediaItemId = null,
|
||||
bool? isAvailable = null,
|
||||
Guid? libraryId = null,
|
||||
string? title = null,
|
||||
Guid? collectionId = null,
|
||||
string? collectionTitle = null,
|
||||
Guid? creatorId = null,
|
||||
string? creatorName = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new FavoriteItemDto(
|
||||
MediaKind: mediaKind ?? _faker.PickRandom(_supportedMediaKinds),
|
||||
MediaItemId: mediaItemId ?? _faker.Random.Guid(),
|
||||
IsAvailable: isAvailable ?? _faker.Random.Bool(),
|
||||
LibraryId: libraryId ?? _faker.Random.Guid(),
|
||||
Title: title ?? _faker.Lorem.Sentence(3),
|
||||
CollectionId: collectionId ?? _faker.Random.Guid(),
|
||||
CollectionTitle: collectionTitle ?? _faker.Lorem.Sentence(3),
|
||||
CreatorId: creatorId ?? _faker.Random.Guid(),
|
||||
CreatorName: creatorName ?? _faker.Name.FullName(),
|
||||
CoverPath: includeCoverPath ? (coverPath ?? $"covers/{_faker.Random.AlphaNumeric(12)}.jpg") : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="FavoriteItemDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteItemDto"/> instances.</returns>
|
||||
public List<FavoriteItemDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FavoriteStatusDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FavoriteStatusDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="FavoriteStatusDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="favoritedMediaItemIds">Optional Ids of the media items that are favorites of the current user.</param>
|
||||
/// <param name="mediaItemCount">Optional number of random favorited media item Ids to generate, between 0 and 5.</param>
|
||||
/// <returns>A configured <see cref="FavoriteStatusDto"/> instance.</returns>
|
||||
public FavoriteStatusDto Create(
|
||||
List<Guid>? favoritedMediaItemIds = null,
|
||||
int? mediaItemCount = null)
|
||||
{
|
||||
int resolvedCount = mediaItemCount ?? _faker.Random.Int(0, 5);
|
||||
return new FavoriteStatusDto(
|
||||
FavoritedMediaItemIds: favoritedMediaItemIds ?? [.. Enumerable.Range(0, resolvedCount).Select(_ => _faker.Random.Guid())]
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="FavoriteStatusDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="FavoriteStatusDto"/> instances.</returns>
|
||||
public List<FavoriteStatusDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.Playlists;
|
||||
using Lumina.Presentation.Web.Common.Enums.Playlists;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly PlaylistEntryDtoFixture _playlistEntryDtoFixture = new();
|
||||
private readonly PaginatedDtoFixture<PlaylistEntryDto> _paginatedDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PlaylistDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional Id of the playlist.</param>
|
||||
/// <param name="name">Optional name of the playlist.</param>
|
||||
/// <param name="description">Optional description of the playlist.</param>
|
||||
/// <param name="type">Optional kind of media the playlist holds.</param>
|
||||
/// <param name="entries">Optional page of ordered entries of the playlist.</param>
|
||||
/// <param name="createdOnUtc">Optional date and time when the playlist was created.</param>
|
||||
/// <param name="updatedOnUtc">Optional date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the last update date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="PlaylistDto"/> instance.</returns>
|
||||
public PlaylistDto Create(
|
||||
Guid? id = null,
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
PlaylistType? type = null,
|
||||
PaginatedDto<PlaylistEntryDto>? entries = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeDescription = true,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
DateTime resolvedCreatedOnUtc = DateTime.SpecifyKind(createdOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)), DateTimeKind.Utc);
|
||||
DateTime resolvedUpdatedOnUtc = DateTime.SpecifyKind(updatedOnUtc ?? resolvedCreatedOnUtc.AddHours(_faker.Random.Int(1, 24)), DateTimeKind.Utc);
|
||||
return new PlaylistDto(
|
||||
Id: id ?? _faker.Random.Guid(),
|
||||
Name: name ?? _faker.Lorem.Sentence(3),
|
||||
Description: includeDescription ? (description ?? _faker.Lorem.Sentence(5)) : null,
|
||||
Type: type ?? PlaylistType.Music,
|
||||
Entries: entries ?? _paginatedDtoFixture.Create(data: _playlistEntryDtoFixture.CreateMany(_faker.Random.Int(0, 5))),
|
||||
CreatedOnUtc: resolvedCreatedOnUtc,
|
||||
UpdatedOnUtc: includeUpdatedOnUtc ? resolvedUpdatedOnUtc : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistDto"/> instances.</returns>
|
||||
public List<PlaylistDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Playlists;
|
||||
using Lumina.Presentation.Web.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PlaylistEntryDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional Id of the entry.</param>
|
||||
/// <param name="mediaItemId">Optional Id of the media item referenced by the entry.</param>
|
||||
/// <param name="mediaItemType">Optional kind of media item referenced by the entry.</param>
|
||||
/// <param name="position">Optional zero based position of the entry in the playlist.</param>
|
||||
/// <param name="libraryId">Optional Id of the media library that contains the media item.</param>
|
||||
/// <param name="collectionId">Optional Id of the collection that contains the media item.</param>
|
||||
/// <param name="creatorId">Optional Id of the creator of the media item.</param>
|
||||
/// <param name="mediaItemTitle">Optional title of the media item.</param>
|
||||
/// <param name="collectionTitle">Optional title of the collection that contains the media item.</param>
|
||||
/// <param name="creatorName">Optional name of the creator of the media item.</param>
|
||||
/// <param name="durationInSeconds">Optional duration of the media item in seconds.</param>
|
||||
/// <param name="coverPath">Optional path of the cover art of the collection.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="PlaylistEntryDto"/> instance.</returns>
|
||||
public PlaylistEntryDto Create(
|
||||
Guid? id = null,
|
||||
Guid? mediaItemId = null,
|
||||
PlaylistMediaItemType? mediaItemType = null,
|
||||
int? position = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? collectionId = null,
|
||||
Guid? creatorId = null,
|
||||
string? mediaItemTitle = null,
|
||||
string? collectionTitle = null,
|
||||
string? creatorName = null,
|
||||
int? durationInSeconds = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new PlaylistEntryDto(
|
||||
Id: id ?? _faker.Random.Guid(),
|
||||
MediaItemId: mediaItemId ?? _faker.Random.Guid(),
|
||||
MediaItemType: mediaItemType ?? _faker.PickRandom(PlaylistMediaItemType.MusicTrack, PlaylistMediaItemType.VideoFile),
|
||||
Position: position ?? _faker.Random.Int(0, 1000),
|
||||
LibraryId: libraryId ?? _faker.Random.Guid(),
|
||||
CollectionId: collectionId ?? _faker.Random.Guid(),
|
||||
CreatorId: creatorId ?? _faker.Random.Guid(),
|
||||
MediaItemTitle: mediaItemTitle ?? _faker.Lorem.Sentence(3),
|
||||
CollectionTitle: collectionTitle ?? _faker.Lorem.Sentence(2),
|
||||
CreatorName: creatorName ?? _faker.Name.FullName(),
|
||||
DurationInSeconds: durationInSeconds ?? _faker.Random.Int(0, 36000),
|
||||
CoverPath: includeCoverPath ? (coverPath ?? $"/artwork/{_faker.Random.Guid()}/cover.jpg") : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistEntryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntryDto"/> instances.</returns>
|
||||
public List<PlaylistEntryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Enums.Favorites;
|
||||
using Lumina.Presentation.Web.Common.Requests.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddFavoriteRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddFavoriteRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="AddFavoriteRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional kind of the media item to favorite.</param>
|
||||
/// <param name="mediaItemId">Optional Id of the media item to favorite.</param>
|
||||
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMediaItemId">Whether the media item Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="AddFavoriteRequest"/> instance.</returns>
|
||||
public AddFavoriteRequest Create(
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
Guid? mediaItemId = null,
|
||||
bool includeMediaKind = true,
|
||||
bool includeMediaItemId = true)
|
||||
{
|
||||
return new AddFavoriteRequest(
|
||||
MediaKind: includeMediaKind ? (mediaKind ?? _faker.PickRandom(_supportedMediaKinds)) : null,
|
||||
MediaItemId: includeMediaItemId ? (mediaItemId ?? _faker.Random.Guid()) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="AddFavoriteRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AddFavoriteRequest"/> instances.</returns>
|
||||
public List<AddFavoriteRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Enums.Favorites;
|
||||
using Lumina.Presentation.Web.Common.Requests.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetFavoriteStatusRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetFavoriteStatusRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GetFavoriteStatusRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional kind of the media items to check.</param>
|
||||
/// <param name="mediaItemIds">Optional Ids of the media items to check.</param>
|
||||
/// <param name="mediaItemCount">Optional number of random media item Ids to generate, between 1 and 5.</param>
|
||||
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeMediaItemIds">Whether the media item Ids should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="GetFavoriteStatusRequest"/> instance.</returns>
|
||||
public GetFavoriteStatusRequest Create(
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
List<Guid>? mediaItemIds = null,
|
||||
int? mediaItemCount = null,
|
||||
bool includeMediaKind = true,
|
||||
bool includeMediaItemIds = true)
|
||||
{
|
||||
int resolvedCount = mediaItemCount ?? _faker.Random.Int(1, 5);
|
||||
return new GetFavoriteStatusRequest(
|
||||
MediaKind: includeMediaKind ? (mediaKind ?? _faker.PickRandom(_supportedMediaKinds)) : null,
|
||||
MediaItemIds: includeMediaItemIds ? (mediaItemIds ?? [.. Enumerable.Range(0, resolvedCount).Select(_ => _faker.Random.Guid())]) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="GetFavoriteStatusRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetFavoriteStatusRequest"/> instances.</returns>
|
||||
public List<GetFavoriteStatusRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Enums.Favorites;
|
||||
using Lumina.Presentation.Web.Common.Requests.Favorites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Favorites;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetFavoritesRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetFavoritesRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly FavoriteMediaKind[] _supportedMediaKinds =
|
||||
[
|
||||
FavoriteMediaKind.MusicArtist,
|
||||
FavoriteMediaKind.MusicAlbum,
|
||||
FavoriteMediaKind.MusicTrack,
|
||||
FavoriteMediaKind.Book
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GetFavoritesRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="mediaKind">Optional kind of media item to restrict the favorites to.</param>
|
||||
/// <param name="currentPage">Optional one based page of favorites to return.</param>
|
||||
/// <param name="perPage">Optional number of favorites per page.</param>
|
||||
/// <param name="includeMediaKind">Whether the media kind should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeCurrentPage">Whether the current page should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePerPage">Whether the page size should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="GetFavoritesRequest"/> instance.</returns>
|
||||
public GetFavoritesRequest Create(
|
||||
FavoriteMediaKind? mediaKind = null,
|
||||
int? currentPage = null,
|
||||
int? perPage = null,
|
||||
bool includeMediaKind = true,
|
||||
bool includeCurrentPage = true,
|
||||
bool includePerPage = true)
|
||||
{
|
||||
return new GetFavoritesRequest(
|
||||
MediaKind: includeMediaKind ? (mediaKind ?? _faker.PickRandom(_supportedMediaKinds)) : null,
|
||||
CurrentPage: includeCurrentPage ? (currentPage ?? _faker.Random.Int(1, 10)) : null,
|
||||
PerPage: includePerPage ? (perPage ?? _faker.Random.Int(1, 100)) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="GetFavoritesRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetFavoritesRequest"/> instances.</returns>
|
||||
public List<GetFavoritesRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Requests.Playlists;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetPlaylistRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetPlaylistRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GetPlaylistRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="currentPage">Optional one based page of entries to return.</param>
|
||||
/// <param name="perPage">Optional number of entries per page.</param>
|
||||
/// <param name="includeCurrentPage">Whether the page should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePerPage">Whether the page size should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="GetPlaylistRequest"/> instance.</returns>
|
||||
public GetPlaylistRequest Create(
|
||||
int? currentPage = null,
|
||||
int? perPage = null,
|
||||
bool includeCurrentPage = true,
|
||||
bool includePerPage = true)
|
||||
{
|
||||
return new GetPlaylistRequest(
|
||||
CurrentPage: includeCurrentPage ? (currentPage ?? _faker.Random.Int(1, 10)) : null,
|
||||
PerPage: includePerPage ? (perPage ?? _faker.Random.Int(1, 200)) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="GetPlaylistRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetPlaylistRequest"/> instances.</returns>
|
||||
public List<GetPlaylistRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+9
@@ -22,6 +22,15 @@ public class BaseEndpointFixture : BaseEndpoint<EmptyRequest, IResult>
|
||||
/// </summary>
|
||||
public string TestCulture => Culture;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the <c>Cache-Control</c> header through the <see cref="BaseEndpoint.SetCacheControl(string)"/> helper.
|
||||
/// </summary>
|
||||
/// <param name="cacheControl">The <c>Cache-Control</c> value chosen by the endpoint.</param>
|
||||
public void TestSetCacheControl(string cacheControl)
|
||||
{
|
||||
SetCacheControl(cacheControl);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders a Razor view through the <see cref="BaseEndpoint.View(string, object?, IReadOnlyDictionary{string, object?})"/> helper.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user