Add editorconfig and analyzers, format backend code

This commit is contained in:
2026-09-24 04:54:17 +02:00
parent 87c3f97529
commit c8fe28b07b
367 changed files with 12179 additions and 12459 deletions
@@ -2,26 +2,25 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Xunit;
namespace Musify.Application.Tests.TestSupport
namespace Musify.Application.Tests.TestSupport;
public abstract class HandlerTestBase : IAsyncLifetime
{
public abstract class HandlerTestBase : IAsyncLifetime
private TestDatabase database = null!;
protected TestDatabase Database => database;
public async ValueTask InitializeAsync() => database = await TestDatabase.CreateAsync();
public ValueTask DisposeAsync() => database.DisposeAsync();
protected static ILogger<T> NoOpLogger<T>() => NullLogger<T>.Instance;
protected async Task SeedAsync(params object[] entities)
{
private TestDatabase database = null!;
foreach (var entity in entities)
Database.Add(entity);
protected TestDatabase Database => database;
public async ValueTask InitializeAsync() => database = await TestDatabase.CreateAsync();
public ValueTask DisposeAsync() => database.DisposeAsync();
protected static ILogger<T> NoOpLogger<T>() => NullLogger<T>.Instance;
protected async Task SeedAsync(params object[] entities)
{
foreach (var entity in entities)
Database.Add(entity);
await Database.SaveChangesAsync(CancellationToken.None);
}
await Database.SaveChangesAsync(CancellationToken.None);
}
}
@@ -1,26 +1,25 @@
using Musify.Application.Configuration;
namespace Musify.Application.Tests.TestSupport
namespace Musify.Application.Tests.TestSupport;
public static class TestConfigurations
{
public static class TestConfigurations
{
public static ApplicationStorageConfiguration Storage(string bucket = "test-bucket") =>
new() { Bucket = bucket };
public static ApplicationStorageConfiguration Storage(string bucket = "test-bucket") =>
new() { Bucket = bucket };
public static TrackConfiguration Track() => new();
public static TrackConfiguration Track() => new();
public static PlayListConfiguration PlayList() => new();
public static PlayListConfiguration PlayList() => new();
public static AlbumConfiguration Album() => new();
public static AlbumConfiguration Album() => new();
public static MixConfiguration Mix() => new();
public static MixConfiguration Mix() => new();
public static UploadIntentConfiguration UploadIntent() => new();
public static UploadIntentConfiguration UploadIntent() => new();
public static StreamGatewayConfiguration StreamGateway(string publicBaseUrl = "https://stream.musify.test") =>
new() { PublicBaseUrl = publicBaseUrl };
public static StreamGatewayConfiguration StreamGateway(string publicBaseUrl = "https://stream.musify.test") =>
new() { PublicBaseUrl = publicBaseUrl };
public static PlaybackConfiguration Playback(bool allowAnonymousListening = false, int anonymousFragmentSeconds = 0) =>
new() { AllowAnonymousListening = allowAnonymousListening, AnonymousFragmentSeconds = anonymousFragmentSeconds };
}
public static PlaybackConfiguration Playback(bool allowAnonymousListening = false, int anonymousFragmentSeconds = 0) =>
new() { AllowAnonymousListening = allowAnonymousListening, AnonymousFragmentSeconds = anonymousFragmentSeconds };
}
@@ -3,180 +3,179 @@ using Microsoft.EntityFrameworkCore;
using Musify.Application.Contracts;
using Musify.Domain.Entities;
namespace Musify.Application.Tests.TestSupport
namespace Musify.Application.Tests.TestSupport;
public sealed class TestDatabase : DbContext, IDatabase
{
public sealed class TestDatabase : DbContext, IDatabase
private readonly SqliteConnection connection;
private TestDatabase(SqliteConnection connection, DbContextOptions<TestDatabase> options)
: base(options)
{
private readonly SqliteConnection connection;
this.connection = connection;
}
private TestDatabase(SqliteConnection connection, DbContextOptions<TestDatabase> options)
: base(options)
public static async Task<TestDatabase> CreateAsync()
{
var connection = new SqliteConnection("Filename=:memory:");
await connection.OpenAsync();
var options = new DbContextOptionsBuilder<TestDatabase>()
.UseSqlite(connection)
.Options;
var database = new TestDatabase(connection, options);
await database.Database.EnsureCreatedAsync();
return database;
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Track>().OwnsOne(track => track.Pictures);
modelBuilder.Entity<Track>().Navigation(track => track.Pictures).IsRequired();
modelBuilder.Entity<Track>().OwnsOne(track => track.Audio);
modelBuilder.Entity<Track>().Navigation(track => track.Audio).IsRequired();
modelBuilder.Entity<Track>()
.HasOne(track => track.Owner)
.WithMany()
.HasForeignKey(track => track.OwnerUserId)
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<PlayList>().OwnsOne(playList => playList.Pictures, pictures =>
{
this.connection = connection;
}
pictures.Property(p => p.OriginalName).IsRequired(false);
pictures.Property(p => p.SmallName).IsRequired(false);
pictures.Property(p => p.MediumName).IsRequired(false);
pictures.Property(p => p.LargeName).IsRequired(false);
});
modelBuilder.Entity<PlayList>().Navigation(playList => playList.Pictures).IsRequired(false);
public static async Task<TestDatabase> CreateAsync()
{
var connection = new SqliteConnection("Filename=:memory:");
await connection.OpenAsync();
modelBuilder.Entity<Album>().OwnsOne(album => album.Pictures);
modelBuilder.Entity<Album>().Navigation(album => album.Pictures).IsRequired(false);
var options = new DbContextOptionsBuilder<TestDatabase>()
.UseSqlite(connection)
.Options;
modelBuilder.Entity<Album>()
.HasOne(album => album.Owner)
.WithMany()
.HasForeignKey(album => album.OwnerUserId)
.OnDelete(DeleteBehavior.Restrict);
var database = new TestDatabase(connection, options);
await database.Database.EnsureCreatedAsync();
return database;
}
modelBuilder.Entity<AlbumHasTrack>()
.HasOne(albumTrack => albumTrack.Album)
.WithMany(album => album.AlbumTracks)
.HasForeignKey(albumTrack => albumTrack.AlbumId)
.OnDelete(DeleteBehavior.Cascade);
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<AlbumHasTrack>()
.HasOne(albumTrack => albumTrack.Track)
.WithMany(track => track.AlbumTracks)
.HasForeignKey(albumTrack => albumTrack.TrackId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<Track>().OwnsOne(track => track.Pictures);
modelBuilder.Entity<Track>().Navigation(track => track.Pictures).IsRequired();
modelBuilder.Entity<AlbumHasTrack>()
.HasIndex(albumTrack => new { albumTrack.AlbumId, albumTrack.TrackId })
.IsUnique();
modelBuilder.Entity<Track>().OwnsOne(track => track.Audio);
modelBuilder.Entity<Track>().Navigation(track => track.Audio).IsRequired();
modelBuilder.Entity<Mix>()
.HasIndex(mix => new { mix.UserId, mix.Position });
modelBuilder.Entity<Track>()
.HasOne(track => track.Owner)
.WithMany()
.HasForeignKey(track => track.OwnerUserId)
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<MixItem>()
.HasOne(item => item.Mix)
.WithMany(mix => mix.Items)
.HasForeignKey(item => item.MixId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<PlayList>().OwnsOne(playList => playList.Pictures, pictures =>
{
pictures.Property(p => p.OriginalName).IsRequired(false);
pictures.Property(p => p.SmallName).IsRequired(false);
pictures.Property(p => p.MediumName).IsRequired(false);
pictures.Property(p => p.LargeName).IsRequired(false);
});
modelBuilder.Entity<PlayList>().Navigation(playList => playList.Pictures).IsRequired(false);
modelBuilder.Entity<MixItem>()
.HasOne(item => item.Track)
.WithMany()
.HasForeignKey(item => item.TrackId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<Album>().OwnsOne(album => album.Pictures);
modelBuilder.Entity<Album>().Navigation(album => album.Pictures).IsRequired(false);
modelBuilder.Entity<MixItem>()
.HasIndex(item => new { item.MixId, item.Position });
modelBuilder.Entity<Album>()
.HasOne(album => album.Owner)
.WithMany()
.HasForeignKey(album => album.OwnerUserId)
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<TrackLike>()
.HasIndex(like => new { like.UserId, like.TrackId })
.IsUnique();
modelBuilder.Entity<AlbumHasTrack>()
.HasOne(albumTrack => albumTrack.Album)
.WithMany(album => album.AlbumTracks)
.HasForeignKey(albumTrack => albumTrack.AlbumId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<TrackTag>()
.HasOne(trackTag => trackTag.Track)
.WithMany(track => track.Tags)
.HasForeignKey(trackTag => trackTag.TrackId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<AlbumHasTrack>()
.HasOne(albumTrack => albumTrack.Track)
.WithMany(track => track.AlbumTracks)
.HasForeignKey(albumTrack => albumTrack.TrackId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<TrackTag>()
.HasIndex(trackTag => new { trackTag.TrackId, trackTag.Tag })
.IsUnique();
modelBuilder.Entity<AlbumHasTrack>()
.HasIndex(albumTrack => new { albumTrack.AlbumId, albumTrack.TrackId })
.IsUnique();
modelBuilder.Entity<UserFollow>()
.HasOne(follow => follow.Follower)
.WithMany()
.HasForeignKey(follow => follow.FollowerId)
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<Mix>()
.HasIndex(mix => new { mix.UserId, mix.Position });
modelBuilder.Entity<UserFollow>()
.HasOne(follow => follow.Followed)
.WithMany()
.HasForeignKey(follow => follow.FollowedId)
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<MixItem>()
.HasOne(item => item.Mix)
.WithMany(mix => mix.Items)
.HasForeignKey(item => item.MixId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<UserFollow>()
.HasIndex(follow => new { follow.FollowerId, follow.FollowedId })
.IsUnique();
}
modelBuilder.Entity<MixItem>()
.HasOne(item => item.Track)
.WithMany()
.HasForeignKey(item => item.TrackId)
.OnDelete(DeleteBehavior.Cascade);
public DbSet<User> Users => Set<User>();
modelBuilder.Entity<MixItem>()
.HasIndex(item => new { item.MixId, item.Position });
public DbSet<PlayList> PlayLists => Set<PlayList>();
modelBuilder.Entity<TrackLike>()
.HasIndex(like => new { like.UserId, like.TrackId })
.IsUnique();
public DbSet<Album> Albums => Set<Album>();
modelBuilder.Entity<TrackTag>()
.HasOne(trackTag => trackTag.Track)
.WithMany(track => track.Tags)
.HasForeignKey(trackTag => trackTag.TrackId)
.OnDelete(DeleteBehavior.Cascade);
public DbSet<AlbumHasTrack> AlbumHasTracks => Set<AlbumHasTrack>();
modelBuilder.Entity<TrackTag>()
.HasIndex(trackTag => new { trackTag.TrackId, trackTag.Tag })
.IsUnique();
public DbSet<Track> Tracks => Set<Track>();
modelBuilder.Entity<UserFollow>()
.HasOne(follow => follow.Follower)
.WithMany()
.HasForeignKey(follow => follow.FollowerId)
.OnDelete(DeleteBehavior.Restrict);
public DbSet<UserHasTrack> UserHasTracks => Set<UserHasTrack>();
modelBuilder.Entity<UserFollow>()
.HasOne(follow => follow.Followed)
.WithMany()
.HasForeignKey(follow => follow.FollowedId)
.OnDelete(DeleteBehavior.Restrict);
public DbSet<PlayListHasTrack> PlayListHasTracks => Set<PlayListHasTrack>();
modelBuilder.Entity<UserFollow>()
.HasIndex(follow => new { follow.FollowerId, follow.FollowedId })
.IsUnique();
}
public DbSet<Mix> Mixes => Set<Mix>();
public DbSet<User> Users => Set<User>();
public DbSet<MixItem> MixItems => Set<MixItem>();
public DbSet<PlayList> PlayLists => Set<PlayList>();
public DbSet<Upload> Uploads => Set<Upload>();
public DbSet<Album> Albums => Set<Album>();
public DbSet<UploadIntent> UploadIntents => Set<UploadIntent>();
public DbSet<AlbumHasTrack> AlbumHasTracks => Set<AlbumHasTrack>();
public DbSet<ListeningHistory> ListeningHistories => Set<ListeningHistory>();
public DbSet<Track> Tracks => Set<Track>();
public DbSet<TrackLike> TrackLikes => Set<TrackLike>();
public DbSet<UserHasTrack> UserHasTracks => Set<UserHasTrack>();
public DbSet<TrackTag> TrackTags => Set<TrackTag>();
public DbSet<PlayListHasTrack> PlayListHasTracks => Set<PlayListHasTrack>();
public DbSet<UserFollow> UserFollows => Set<UserFollow>();
public DbSet<Mix> Mixes => Set<Mix>();
public async Task<IDatabaseTransaction> BeginTransactionAsync(System.Data.IsolationLevel isolationLevel, CancellationToken cancellationToken)
{
var transaction = await Database.BeginTransactionAsync(isolationLevel, cancellationToken);
return new SqliteDatabaseTransaction(transaction);
}
public DbSet<MixItem> MixItems => Set<MixItem>();
public override async ValueTask DisposeAsync()
{
await base.DisposeAsync();
await connection.DisposeAsync();
}
public DbSet<Upload> Uploads => Set<Upload>();
private sealed class SqliteDatabaseTransaction(Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction inner)
: IDatabaseTransaction
{
public Task CommitAsync(CancellationToken cancellationToken = default) =>
inner.CommitAsync(cancellationToken);
public DbSet<UploadIntent> UploadIntents => Set<UploadIntent>();
public DbSet<ListeningHistory> ListeningHistories => Set<ListeningHistory>();
public DbSet<TrackLike> TrackLikes => Set<TrackLike>();
public DbSet<TrackTag> TrackTags => Set<TrackTag>();
public DbSet<UserFollow> UserFollows => Set<UserFollow>();
public async Task<IDatabaseTransaction> BeginTransactionAsync(System.Data.IsolationLevel isolationLevel, CancellationToken cancellationToken)
{
var transaction = await Database.BeginTransactionAsync(isolationLevel, cancellationToken);
return new SqliteDatabaseTransaction(transaction);
}
public override async ValueTask DisposeAsync()
{
await base.DisposeAsync();
await connection.DisposeAsync();
}
private sealed class SqliteDatabaseTransaction(Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction inner)
: IDatabaseTransaction
{
public Task CommitAsync(CancellationToken cancellationToken = default) =>
inner.CommitAsync(cancellationToken);
public ValueTask DisposeAsync() => inner.DisposeAsync();
}
public ValueTask DisposeAsync() => inner.DisposeAsync();
}
}
@@ -1,194 +1,193 @@
using Musify.Domain.Entities;
using Musify.Domain.ValueObjects;
namespace Musify.Application.Tests.TestSupport
namespace Musify.Application.Tests.TestSupport;
public static class TestEntities
{
public static class TestEntities
public static User User(
long id = 1,
string name = "test-user",
string? firstName = "Test",
string? secondName = "User",
string? profilePictureUrl = null) =>
new()
{
Id = id,
Name = name,
NormalizedName = name.ToUpperInvariant(),
FirstName = firstName,
SecondName = secondName,
ProfilePictureUrl = profilePictureUrl
};
public static TrackPictures ProcessedPictures() => new()
{
public static User User(
long id = 1,
string name = "test-user",
string? firstName = "Test",
string? secondName = "User",
string? profilePictureUrl = null) =>
new()
{
Id = id,
Name = name,
NormalizedName = name.ToUpperInvariant(),
FirstName = firstName,
SecondName = secondName,
ProfilePictureUrl = profilePictureUrl
};
OriginalName = "original.webp",
SmallName = "small.webp",
MediumName = "medium.webp",
LargeName = "large.webp",
ProcessingStatus = ProcessingStatus.Completed
};
public static TrackPictures ProcessedPictures() => new()
public static TrackPictures PendingPictures() => new()
{
OriginalName = "original.webp",
ProcessingStatus = ProcessingStatus.Pending
};
public static TrackAudio ProcessedAudio(string folderName = "audio-folder") => new()
{
OriginalName = "original.mp3",
FolderName = folderName,
TranscodeStatus = ProcessingStatus.Completed
};
public static TrackAudio PendingAudio() => new()
{
OriginalName = "original.mp3",
TranscodeStatus = ProcessingStatus.Pending
};
public static Track Track(
User owner,
string title = "Test Track",
double durationSeconds = 180,
TrackPictures? pictures = null,
TrackAudio? audio = null,
LifeCycleStatus lifeCycleStatus = LifeCycleStatus.Active,
IEnumerable<Genre>? tags = null,
bool isExplicit = false)
{
var track = new Track
{
OriginalName = "original.webp",
SmallName = "small.webp",
MediumName = "medium.webp",
LargeName = "large.webp",
ProcessingStatus = ProcessingStatus.Completed
Title = title,
NormalizedTitle = title.ToUpperInvariant(),
DurationSeconds = durationSeconds,
LifeCycleStatus = lifeCycleStatus,
IsExplicit = isExplicit,
OwnerUserId = owner.Id,
Owner = owner,
Pictures = pictures ?? ProcessedPictures(),
Audio = audio ?? ProcessedAudio()
};
public static TrackPictures PendingPictures() => new()
{
OriginalName = "original.webp",
ProcessingStatus = ProcessingStatus.Pending
};
track.Tags = (tags ?? [Genre.Pop])
.Select(tag => new TrackTag { TrackId = track.Id, Tag = tag })
.ToList();
public static TrackAudio ProcessedAudio(string folderName = "audio-folder") => new()
{
OriginalName = "original.mp3",
FolderName = folderName,
TranscodeStatus = ProcessingStatus.Completed
};
public static TrackAudio PendingAudio() => new()
{
OriginalName = "original.mp3",
TranscodeStatus = ProcessingStatus.Pending
};
public static Track Track(
User owner,
string title = "Test Track",
double durationSeconds = 180,
TrackPictures? pictures = null,
TrackAudio? audio = null,
LifeCycleStatus lifeCycleStatus = LifeCycleStatus.Active,
IEnumerable<Genre>? tags = null,
bool isExplicit = false)
{
var track = new Track
{
Title = title,
NormalizedTitle = title.ToUpperInvariant(),
DurationSeconds = durationSeconds,
LifeCycleStatus = lifeCycleStatus,
IsExplicit = isExplicit,
OwnerUserId = owner.Id,
Owner = owner,
Pictures = pictures ?? ProcessedPictures(),
Audio = audio ?? ProcessedAudio()
};
track.Tags = (tags ?? [Genre.Pop])
.Select(tag => new TrackTag { TrackId = track.Id, Tag = tag })
.ToList();
return track;
}
public static PlayListPictures PlayListPictures() => new()
{
OriginalName = "original.webp",
SmallName = "small.webp",
MediumName = "medium.webp",
LargeName = "large.webp"
};
public static PlayList PlayList(
long userId,
string name = "Test Playlist",
string? description = null,
PlayListPictures? pictures = null,
LifeCycleStatus lifeCycleStatus = LifeCycleStatus.Active,
PlaylistVisibility visibility = PlaylistVisibility.Private) =>
new()
{
UserId = userId,
Name = name,
NormalizedName = name.ToUpperInvariant(),
Description = description,
Pictures = pictures ?? PlayListPictures(),
LifeCycleStatus = lifeCycleStatus,
Visibility = visibility
};
public static AlbumPictures AlbumPictures() => new()
{
OriginalName = "original.webp",
SmallName = "small.webp",
MediumName = "medium.webp",
LargeName = "large.webp"
};
public static Album Album(
long ownerUserId,
string title = "Test Album",
string? description = null,
int? releaseYear = 2024,
AlbumPictures? pictures = null) =>
new()
{
Title = title,
NormalizedTitle = title.ToUpperInvariant(),
Description = description,
ReleaseYear = releaseYear,
OwnerUserId = ownerUserId,
Pictures = pictures ?? AlbumPictures()
};
public static UploadIntent UploadIntent(
long userId,
UploadIntentPurpose purpose = UploadIntentPurpose.TrackPicture,
string bucket = "test-bucket",
string key = "temp/object.webp",
string objectName = "object.webp",
string contentType = "image/webp",
long? expectedSizeBytes = 1024,
UploadIntentStatus status = UploadIntentStatus.Issued,
DateTime? expiresAt = null) =>
new()
{
UserId = userId,
Bucket = bucket,
Key = key,
ObjectName = objectName,
ContentType = contentType,
ExpectedSizeBytes = expectedSizeBytes,
Purpose = purpose,
Status = status,
ExpiresAt = expiresAt ?? DateTime.UtcNow.AddMinutes(5)
};
public static Mix Mix(
long userId,
string title = "Test Mix",
string? subtitle = null,
int position = 0) =>
new()
{
UserId = userId,
Title = title,
Subtitle = subtitle,
Position = position
};
public static MixItem MixItem(
Guid mixId,
Guid trackId,
int position = 0) =>
new()
{
MixId = mixId,
Position = position,
TrackId = trackId
};
public static ListeningHistory ListeningHistory(
long userId,
Guid trackId,
DateTime? listenedAt = null,
double? playedSeconds = null,
bool isCounted = true) =>
new()
{
UserId = userId,
TrackId = trackId,
ListenedAt = listenedAt ?? DateTime.UtcNow,
PlayedSeconds = playedSeconds,
IsCounted = isCounted
};
return track;
}
public static PlayListPictures PlayListPictures() => new()
{
OriginalName = "original.webp",
SmallName = "small.webp",
MediumName = "medium.webp",
LargeName = "large.webp"
};
public static PlayList PlayList(
long userId,
string name = "Test Playlist",
string? description = null,
PlayListPictures? pictures = null,
LifeCycleStatus lifeCycleStatus = LifeCycleStatus.Active,
PlaylistVisibility visibility = PlaylistVisibility.Private) =>
new()
{
UserId = userId,
Name = name,
NormalizedName = name.ToUpperInvariant(),
Description = description,
Pictures = pictures ?? PlayListPictures(),
LifeCycleStatus = lifeCycleStatus,
Visibility = visibility
};
public static AlbumPictures AlbumPictures() => new()
{
OriginalName = "original.webp",
SmallName = "small.webp",
MediumName = "medium.webp",
LargeName = "large.webp"
};
public static Album Album(
long ownerUserId,
string title = "Test Album",
string? description = null,
int? releaseYear = 2024,
AlbumPictures? pictures = null) =>
new()
{
Title = title,
NormalizedTitle = title.ToUpperInvariant(),
Description = description,
ReleaseYear = releaseYear,
OwnerUserId = ownerUserId,
Pictures = pictures ?? AlbumPictures()
};
public static UploadIntent UploadIntent(
long userId,
UploadIntentPurpose purpose = UploadIntentPurpose.TrackPicture,
string bucket = "test-bucket",
string key = "temp/object.webp",
string objectName = "object.webp",
string contentType = "image/webp",
long? expectedSizeBytes = 1024,
UploadIntentStatus status = UploadIntentStatus.Issued,
DateTime? expiresAt = null) =>
new()
{
UserId = userId,
Bucket = bucket,
Key = key,
ObjectName = objectName,
ContentType = contentType,
ExpectedSizeBytes = expectedSizeBytes,
Purpose = purpose,
Status = status,
ExpiresAt = expiresAt ?? DateTime.UtcNow.AddMinutes(5)
};
public static Mix Mix(
long userId,
string title = "Test Mix",
string? subtitle = null,
int position = 0) =>
new()
{
UserId = userId,
Title = title,
Subtitle = subtitle,
Position = position
};
public static MixItem MixItem(
Guid mixId,
Guid trackId,
int position = 0) =>
new()
{
MixId = mixId,
Position = position,
TrackId = trackId
};
public static ListeningHistory ListeningHistory(
long userId,
Guid trackId,
DateTime? listenedAt = null,
double? playedSeconds = null,
bool isCounted = true) =>
new()
{
UserId = userId,
TrackId = trackId,
ListenedAt = listenedAt ?? DateTime.UtcNow,
PlayedSeconds = playedSeconds,
IsCounted = isCounted
};
}