#region ========================================================================= USING ===================================================================================== using Bogus; using Lumina.Plugins.MusicBrainz.Common.Models.Contracts.Responses; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; #endregion namespace Lumina.Plugins.MusicBrainz.Fixtures.Common.Models.Contracts.Responses; /// /// Fixture class for the record. /// The releases of the release group default to an empty list, because they are only returned by a dedicated browse request. /// [ExcludeFromCodeCoverage] internal sealed class MusicBrainzReleaseGroupResponseFixture { private readonly Faker _faker = new(); private readonly MusicBrainzArtistCreditResponseFixture _musicBrainzArtistCreditResponseFixture = new(); private readonly MusicBrainzTagResponseFixture _musicBrainzTagResponseFixture = new(); private readonly MusicBrainzRatingResponseFixture _musicBrainzRatingResponseFixture = new(); /// /// Creates a new instance with randomized test data. /// /// Optional. The MusicBrainz identifier of the release group. /// Whether the identifier should be included, or forced to . /// Optional. The title of the release group. /// Whether the title should be included, or forced to . /// Optional. The disambiguation comment of the release group. /// Whether the disambiguation should be included, or forced to . /// Optional. The primary type of the release group. /// Whether the primary type should be included, or forced to . /// Optional. The secondary types of the release group. /// Optional. The date the release group was first released. /// Whether the first release date should be included, or forced to . /// Optional. The artist credit of the release group. /// Optional. The releases of the release group. /// Optional. The tags of the release group. /// Optional. The genres of the release group. /// Optional. The aggregated rating of the release group. /// Whether the rating should be included, or forced to . /// A configured instance. public MusicBrainzReleaseGroupResponse Create( string? id = null, bool includeId = true, string? title = null, bool includeTitle = true, string? disambiguation = null, bool includeDisambiguation = true, string? primaryType = null, bool includePrimaryType = true, List? secondaryTypes = null, string? firstReleaseDate = null, bool includeFirstReleaseDate = true, List? artistCredit = null, List? releases = null, List? tags = null, List? genres = null, MusicBrainzRatingResponse? rating = null, bool includeRating = false) { return new MusicBrainzReleaseGroupResponse { Id = includeId ? id ?? Guid.NewGuid().ToString() : null, Title = includeTitle ? title ?? _faker.Commerce.ProductName() : null, Disambiguation = includeDisambiguation ? disambiguation ?? _faker.Lorem.Sentence(2) : null, PrimaryType = includePrimaryType ? primaryType ?? _faker.PickRandom("Album", "Single", "EP") : null, SecondaryTypes = secondaryTypes ?? [], FirstReleaseDate = includeFirstReleaseDate ? firstReleaseDate ?? _faker.Date.Past(40).ToString("yyyy-MM-dd") : null, ArtistCredit = artistCredit ?? [.. _musicBrainzArtistCreditResponseFixture.CreateMany(2)], Releases = releases ?? [], Tags = tags ?? [.. _musicBrainzTagResponseFixture.CreateMany(2)], Genres = genres ?? [.. _musicBrainzTagResponseFixture.CreateMany(2)], Rating = includeRating ? rating ?? _musicBrainzRatingResponseFixture.Create() : null }; } /// /// Creates multiple instances with randomized test data. /// /// Number of instances to create. /// List of configured instances. public List CreateMany(int count = 3) { return [.. Enumerable.Range(0, count).Select(_ => Create())]; } }