mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 19:21:10 +00:00
Adds playlist management and playback
This commit is contained in:
1 parent
009a0c8156
commit
9889c86c76
296 files changed
+18830
-367
No files matched your search
+7
-9
@@ -45,15 +45,13 @@ public class AlbumLiteRowFixture
|
||||
bool includeReleaseYear = true,
|
||||
bool includeReleaseTypes = true)
|
||||
{
|
||||
return new AlbumLiteRow
|
||||
{
|
||||
Id = id ?? _faker.Random.Guid(),
|
||||
Title = title ?? _faker.Music.Genre(),
|
||||
TotalTracks = totalTracks ?? _faker.Random.Int(1, 30),
|
||||
CoverPath = includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null,
|
||||
ReleaseYear = includeReleaseYear ? (releaseYear ?? _faker.Random.Int(MINIMUM_RELEASE_YEAR, MAXIMUM_RELEASE_YEAR)) : null,
|
||||
ReleaseTypes = includeReleaseTypes ? (releaseTypes ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(index => _faker.PickRandom<MusicReleaseType>())]) : null
|
||||
};
|
||||
return new AlbumLiteRow(
|
||||
id ?? _faker.Random.Guid(),
|
||||
title ?? _faker.Music.Genre(),
|
||||
totalTracks ?? _faker.Random.Int(1, 30),
|
||||
includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null,
|
||||
includeReleaseYear ? (releaseYear ?? _faker.Random.Int(MINIMUM_RELEASE_YEAR, MAXIMUM_RELEASE_YEAR)) : null,
|
||||
includeReleaseTypes ? (releaseTypes ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(index => _faker.PickRandom<MusicReleaseType>())]) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+4
-6
@@ -31,12 +31,10 @@ public class ArtistLiteRowFixture
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new ArtistLiteRow
|
||||
{
|
||||
Id = id ?? _faker.Random.Guid(),
|
||||
Name = name ?? _faker.Name.FullName(),
|
||||
CoverPath = includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null
|
||||
};
|
||||
return new ArtistLiteRow(
|
||||
id ?? _faker.Random.Guid(),
|
||||
name ?? _faker.Name.FullName(),
|
||||
includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+6
-8
@@ -35,14 +35,12 @@ public class TrackLiteRowFixture
|
||||
bool includeDiscNumber = true,
|
||||
int? durationInSeconds = null)
|
||||
{
|
||||
return new TrackLiteRow
|
||||
{
|
||||
Id = id ?? _faker.Random.Guid(),
|
||||
Title = title ?? _faker.Lorem.Sentence(),
|
||||
TrackNumber = trackNumber ?? _faker.Random.Int(1, 30),
|
||||
DiscNumber = includeDiscNumber ? (discNumber ?? _faker.Random.Int(1, 3)) : null,
|
||||
DurationInSeconds = durationInSeconds ?? _faker.Random.Int(1, 600)
|
||||
};
|
||||
return new TrackLiteRow(
|
||||
id ?? _faker.Random.Guid(),
|
||||
title ?? _faker.Lorem.Sentence(),
|
||||
trackNumber ?? _faker.Random.Int(1, 30),
|
||||
includeDiscNumber ? (discNumber ?? _faker.Random.Int(1, 3)) : null,
|
||||
durationInSeconds ?? _faker.Random.Int(1, 600));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+5
-7
@@ -31,13 +31,11 @@ public class BookLiteRowFixture
|
||||
int? releaseYear = null,
|
||||
string? coverPath = null)
|
||||
{
|
||||
return new BookLiteRow
|
||||
{
|
||||
Id = id ?? _faker.Random.Guid(),
|
||||
Title = title ?? _faker.Lorem.Sentence(),
|
||||
ReleaseYear = releaseYear,
|
||||
CoverPath = coverPath
|
||||
};
|
||||
return new BookLiteRow(
|
||||
id ?? _faker.Random.Guid(),
|
||||
title ?? _faker.Lorem.Sentence(),
|
||||
releaseYear,
|
||||
coverPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Playlists;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the playlist.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the playlist.</param>
|
||||
/// <param name="name">Optional. The name of the playlist.</param>
|
||||
/// <param name="includeDescription">Whether the description should be populated.</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 ordered entries of the playlist.</param>
|
||||
/// <param name="entryCount">Optional. The number of entries the playlist holds.</param>
|
||||
/// <param name="version">Optional. The concurrency token of the playlist.</param>
|
||||
/// <param name="createdOnUtc">Optional. The time and date when the playlist was created.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the playlist.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be populated.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The time and date when the playlist was updated.</param>
|
||||
/// <param name="updatedBy">Optional. The Id of the user that updated the playlist.</param>
|
||||
/// <returns>The created playlist entity.</returns>
|
||||
public PlaylistEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? userId = null,
|
||||
string? name = null,
|
||||
bool includeDescription = true,
|
||||
string? description = null,
|
||||
PlaylistType? type = null,
|
||||
IEnumerable<PlaylistEntryEntity>? entries = null,
|
||||
int? entryCount = null,
|
||||
long? version = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
Guid? createdBy = null,
|
||||
bool includeUpdatedOnUtc = false,
|
||||
DateTime? updatedOnUtc = null,
|
||||
Guid? updatedBy = null)
|
||||
{
|
||||
Guid playlistId = id ?? Guid.NewGuid();
|
||||
List<PlaylistEntryEntity> resolvedEntries = entries is null ? [] : [.. entries];
|
||||
|
||||
return new Faker<PlaylistEntity>()
|
||||
.CustomInstantiator(f => new PlaylistEntity
|
||||
{
|
||||
Id = playlistId,
|
||||
UserId = userId ?? f.Random.Guid(),
|
||||
Name = name ?? f.Lorem.Sentence(3),
|
||||
Description = includeDescription ? (description ?? f.Lorem.Sentence()) : null,
|
||||
Type = type ?? f.PickRandom<PlaylistType>(),
|
||||
Entries = resolvedEntries,
|
||||
EntryCount = entryCount ?? resolvedEntries.Count,
|
||||
Version = version ?? f.Random.Long(0, 1_000L),
|
||||
CreatedOnUtc = createdOnUtc ?? f.Date.Past(),
|
||||
CreatedBy = createdBy ?? f.Random.Guid(),
|
||||
UpdatedOnUtc = includeUpdatedOnUtc ? (updatedOnUtc ?? f.Date.Recent()) : null,
|
||||
UpdatedBy = includeUpdatedOnUtc ? (updatedBy ?? f.Random.Guid()) : null
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the created playlists.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntity"/> instances.</returns>
|
||||
public List<PlaylistEntity> CreateMany(int count = 3, Guid? userId = null)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create(userId: userId))];
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Playlists;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryEntityFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistEntryEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the entry.</param>
|
||||
/// <param name="playlistId">Optional. The Id of the playlist the entry belongs to.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the referenced media item.</param>
|
||||
/// <param name="mediaItemType">Optional. The kind of the referenced media item.</param>
|
||||
/// <param name="position">Optional. The sparse order key of the entry.</param>
|
||||
/// <param name="createdOnUtc">Optional. The time and date when the entry was created.</param>
|
||||
/// <param name="createdBy">Optional. The Id of the user that created the entry.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be populated.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The time and date when the entry was updated.</param>
|
||||
/// <param name="updatedBy">Optional. The Id of the user that updated the entry.</param>
|
||||
/// <returns>The created playlist entry entity.</returns>
|
||||
public PlaylistEntryEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? playlistId = null,
|
||||
Guid? mediaItemId = null,
|
||||
PlaylistMediaItemType? mediaItemType = null,
|
||||
long? position = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
Guid? createdBy = null,
|
||||
bool includeUpdatedOnUtc = false,
|
||||
DateTime? updatedOnUtc = null,
|
||||
Guid? updatedBy = null)
|
||||
{
|
||||
return new Faker<PlaylistEntryEntity>()
|
||||
.CustomInstantiator(f => new PlaylistEntryEntity
|
||||
{
|
||||
Id = id ?? f.Random.Guid(),
|
||||
PlaylistId = playlistId ?? f.Random.Guid(),
|
||||
MediaItemId = mediaItemId ?? f.Random.Guid(),
|
||||
MediaItemType = mediaItemType ?? f.PickRandom<PlaylistMediaItemType>(),
|
||||
Position = position ?? f.Random.Long(0, 1_000_000_000L),
|
||||
CreatedOnUtc = createdOnUtc ?? f.Date.Past(),
|
||||
CreatedBy = createdBy ?? f.Random.Guid(),
|
||||
UpdatedOnUtc = includeUpdatedOnUtc ? (updatedOnUtc ?? f.Date.Recent()) : null,
|
||||
UpdatedBy = includeUpdatedOnUtc ? (updatedBy ?? f.Random.Guid()) : null
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user