Implements tests for commit f29f89f31f

This commit is contained in:
BinaryAlley committed 2026-10-28 14:00:50 +02:00
1 parent ab2940d665
commit c0737dbfe8
3 files changed
+87 -64

No files matched your search

@@ -21,25 +21,18 @@ internal sealed class Id3TagDtoFixture
/// Creates a new <see cref="Id3TagDto"/> instance with randomized test data.
/// </summary>
/// <param name="title">Optional. The title of the track.</param>
/// <param name="includeTitle">Whether the title should be included, or forced to <see langword="null"/>.</param>
/// <param name="album">Optional. The title of the album the track belongs to.</param>
/// <param name="includeAlbum">Whether the album should be included, or forced to <see langword="null"/>.</param>
/// <param name="trackArtists">Optional. The artists credited on the track.</param>
/// <param name="albumArtists">Optional. The artists credited on the album.</param>
/// <param name="albumArtistSortName">Optional. The sort name of the album artist.</param>
/// <param name="includeAlbumArtistSortName">Whether the album artist sort name should be included, or forced to <see langword="null"/>.</param>
/// <param name="trackArtistSortName">Optional. The sort name of the track artist.</param>
/// <param name="includeTrackArtistSortName">Whether the track artist sort name should be included, or forced to <see langword="null"/>.</param>
/// <param name="trackNumber">Optional. The number of the track on its disc, or a random one when not supplied.</param>
/// <param name="trackCount">Optional. The number of tracks on the disc, or a random one when not supplied.</param>
/// <param name="discNumber">Optional. The number of the disc the track belongs to, or a random one when not supplied.</param>
/// <param name="discCount">Optional. The number of discs of the release, or a random one when not supplied.</param>
/// <param name="year">Optional. The year the track was released.</param>
/// <param name="includeYear">Whether the year should be included, or forced to <see langword="null"/>.</param>
/// <param name="originalReleaseDate">Optional. The original release date of the track.</param>
/// <param name="includeOriginalReleaseDate">Whether the original release date should be included, or forced to <see langword="null"/>.</param>
/// <param name="originalReleaseYear">Optional. The original release year of the track.</param>
/// <param name="includeOriginalReleaseYear">Whether the original release year should be included, or forced to <see langword="null"/>.</param>
/// <param name="genres">Optional. The genres the tags associate with the track.</param>
/// <param name="composers">Optional. The composers credited on the track.</param>
/// <param name="lyricists">Optional. The lyricists credited on the track.</param>
@@ -47,83 +40,85 @@ internal sealed class Id3TagDtoFixture
/// <param name="remixers">Optional. The remixers credited on the track.</param>
/// <param name="involvedPeople">Optional. The people credited on the track, each with their role.</param>
/// <param name="language">Optional. The language of the track.</param>
/// <param name="includeLanguage">Whether the language should be included, or forced to <see langword="null"/>.</param>
/// <param name="script">Optional. The script used by the language of the track.</param>
/// <param name="includeScript">Whether the script should be included, or forced to <see langword="null"/>.</param>
/// <param name="label">Optional. The label that issued the album.</param>
/// <param name="includeLabel">Whether the label should be included, or forced to <see langword="null"/>.</param>
/// <param name="catalogNumbers">Optional. The catalog numbers of the album.</param>
/// <param name="barcode">Optional. The barcode of the album.</param>
/// <param name="includeBarcode">Whether the barcode should be included, or forced to <see langword="null"/>.</param>
/// <param name="releaseTypes">Optional. The types of the release.</param>
/// <param name="releaseStatus">Optional. The status of the release.</param>
/// <param name="includeReleaseStatus">Whether the release status should be included, or forced to <see langword="null"/>.</param>
/// <param name="releaseCountry">Optional. The country the release was issued in.</param>
/// <param name="includeReleaseCountry">Whether the release country should be included, or forced to <see langword="null"/>.</param>
/// <param name="mediaFormat">Optional. The medium of the release.</param>
/// <param name="includeMediaFormat">Whether the media format should be included, or forced to <see langword="null"/>.</param>
/// <param name="packaging">Optional. The packaging of the release.</param>
/// <param name="includePackaging">Whether the packaging should be included, or forced to <see langword="null"/>.</param>
/// <param name="asin">Optional. The ASIN of the album.</param>
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
/// <param name="isrcs">Optional. The ISRCs of the track.</param>
/// <param name="moods">Optional. The moods of the track.</param>
/// <param name="workTitle">Optional. The title of the work the track is a recording of.</param>
/// <param name="includeWorkTitle">Whether the work title should be included, or forced to <see langword="null"/>.</param>
/// <param name="musicKey">Optional. The musical key of the track.</param>
/// <param name="includeMusicKey">Whether the musical key should be included, or forced to <see langword="null"/>.</param>
/// <param name="bpm">Optional. The tempo of the track in beats per minute.</param>
/// <param name="includeBpm">Whether the tempo should be included, or forced to <see langword="null"/>.</param>
/// <param name="durationInSeconds">Optional. The duration of the audio of the track in seconds.</param>
/// <param name="includeDurationInSeconds">Whether the duration should be included, or forced to <see langword="null"/>.</param>
/// <param name="sampleRate">Optional. The sample rate of the audio of the track in Hz.</param>
/// <param name="includeSampleRate">Whether the sample rate should be included, or forced to <see langword="null"/>.</param>
/// <param name="channels">Optional. The number of audio channels of the track.</param>
/// <param name="includeChannels">Whether the channel count should be included, or forced to <see langword="null"/>.</param>
/// <param name="bitDepth">Optional. The bit depth of the audio of the track.</param>
/// <param name="includeBitDepth">Whether the bit depth should be included, or forced to <see langword="null"/>.</param>
/// <param name="bitrate">Optional. The bitrate of the audio of the track in kbps.</param>
/// <param name="includeBitrate">Whether the bitrate should be included, or forced to <see langword="null"/>.</param>
/// <param name="audioCodec">Optional. The description of the audio codec of the track.</param>
/// <param name="includeAudioCodec">Whether the audio codec should be included, or forced to <see langword="null"/>.</param>
/// <param name="container">Optional. The container of the audio file of the track.</param>
/// <param name="website">Optional. The official website associated with the artist.</param>
/// <param name="includeWebsite">Whether the website should be included, or forced to <see langword="null"/>.</param>
/// <param name="musicBrainzArtistId">Optional. The MusicBrainz identifier of the artist.</param>
/// <param name="includeMusicBrainzArtistId">Whether the MusicBrainz artist identifier should be included, or forced to <see langword="null"/>.</param>
/// <param name="musicBrainzReleaseArtistId">Optional. The MusicBrainz identifier of the release artist.</param>
/// <param name="includeMusicBrainzReleaseArtistId">Whether the MusicBrainz release artist identifier should be included, or forced to <see langword="null"/>.</param>
/// <param name="musicBrainzReleaseGroupId">Optional. The MusicBrainz identifier of the release group.</param>
/// <param name="includeMusicBrainzReleaseGroupId">Whether the MusicBrainz release group identifier should be included, or forced to <see langword="null"/>.</param>
/// <param name="musicBrainzReleaseId">Optional. The MusicBrainz identifier of the release.</param>
/// <param name="includeMusicBrainzReleaseId">Whether the MusicBrainz release identifier should be included, or forced to <see langword="null"/>.</param>
/// <param name="musicBrainzRecordingId">Optional. The MusicBrainz identifier of the recording of the track.</param>
/// <param name="includeMusicBrainzRecordingId">Whether the MusicBrainz recording identifier should be included, or forced to <see langword="null"/>.</param>
/// <param name="musicBrainzReleaseTrackId">Optional. The MusicBrainz identifier of the track on its release.</param>
/// <param name="includeMusicBrainzReleaseTrackId">Whether the MusicBrainz release track identifier should be included, or forced to <see langword="null"/>.</param>
/// <param name="musicBrainzWorkId">Optional. The MusicBrainz identifier of the work the track is a recording of.</param>
/// <param name="includeTitle">Whether the title should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbum">Whether the album should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumArtistSortName">Whether the album artist sort name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackArtistSortName">Whether the track artist sort name should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeYear">Whether the year should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOriginalReleaseDate">Whether the original release date should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOriginalReleaseYear">Whether the original release year should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLanguage">Whether the language should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeScript">Whether the script should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLabel">Whether the label should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBarcode">Whether the barcode should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeReleaseStatus">Whether the release status should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeReleaseCountry">Whether the release country should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMediaFormat">Whether the media format should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePackaging">Whether the packaging should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeWorkTitle">Whether the work title should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicKey">Whether the musical key should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBpm">Whether the tempo should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeDurationInSeconds">Whether the duration should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSampleRate">Whether the sample rate should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeChannels">Whether the channel count should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBitDepth">Whether the bit depth should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBitrate">Whether the bitrate should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAudioCodec">Whether the audio codec should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContainer">Whether the container should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeWebsite">Whether the website should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzArtistId">Whether the MusicBrainz artist identifier should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseArtistId">Whether the MusicBrainz release artist identifier should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseGroupId">Whether the MusicBrainz release group identifier should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseId">Whether the MusicBrainz release identifier should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzRecordingId">Whether the MusicBrainz recording identifier should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzReleaseTrackId">Whether the MusicBrainz release track identifier should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzWorkId">Whether the MusicBrainz work identifier should be included, or forced to <see langword="null"/>.</param>
/// <returns>A configured <see cref="Id3TagDto"/> instance.</returns>
public Id3TagDto Create(
string? title = null,
bool includeTitle = true,
string? album = null,
bool includeAlbum = true,
List<string>? trackArtists = null,
List<string>? albumArtists = null,
string? albumArtistSortName = null,
bool includeAlbumArtistSortName = true,
string? trackArtistSortName = null,
bool includeTrackArtistSortName = true,
uint? trackNumber = null,
uint? trackCount = null,
uint? discNumber = null,
uint? discCount = null,
int? year = null,
bool includeYear = true,
DateOnly? originalReleaseDate = null,
bool includeOriginalReleaseDate = true,
int? originalReleaseYear = null,
bool includeOriginalReleaseYear = true,
List<string>? genres = null,
List<string>? composers = null,
List<string>? lyricists = null,
@@ -131,60 +126,69 @@ internal sealed class Id3TagDtoFixture
List<string>? remixers = null,
List<(string Role, string Name)>? involvedPeople = null,
string? language = null,
bool includeLanguage = true,
string? script = null,
bool includeScript = true,
string? label = null,
bool includeLabel = true,
List<string>? catalogNumbers = null,
string? barcode = null,
bool includeBarcode = true,
List<string>? releaseTypes = null,
string? releaseStatus = null,
bool includeReleaseStatus = true,
string? releaseCountry = null,
bool includeReleaseCountry = true,
string? mediaFormat = null,
bool includeMediaFormat = true,
string? packaging = null,
bool includePackaging = true,
string? asin = null,
bool includeAsin = true,
List<string>? isrcs = null,
List<string>? moods = null,
string? workTitle = null,
bool includeWorkTitle = true,
string? musicKey = null,
bool includeMusicKey = true,
int? bpm = null,
bool includeBpm = true,
int? durationInSeconds = null,
bool includeDurationInSeconds = true,
int? sampleRate = null,
bool includeSampleRate = true,
int? channels = null,
bool includeChannels = true,
int? bitDepth = null,
bool includeBitDepth = true,
int? bitrate = null,
bool includeBitrate = true,
string? audioCodec = null,
bool includeAudioCodec = true,
string? container = null,
string? website = null,
bool includeWebsite = true,
string? musicBrainzArtistId = null,
bool includeMusicBrainzArtistId = true,
string? musicBrainzReleaseArtistId = null,
bool includeMusicBrainzReleaseArtistId = true,
string? musicBrainzReleaseGroupId = null,
bool includeMusicBrainzReleaseGroupId = true,
string? musicBrainzReleaseId = null,
bool includeMusicBrainzReleaseId = true,
string? musicBrainzRecordingId = null,
bool includeMusicBrainzRecordingId = true,
string? musicBrainzReleaseTrackId = null,
bool includeMusicBrainzReleaseTrackId = true,
string? musicBrainzWorkId = null,
bool includeTitle = true,
bool includeAlbum = true,
bool includeAlbumArtistSortName = true,
bool includeTrackArtistSortName = true,
bool includeYear = true,
bool includeOriginalReleaseDate = true,
bool includeOriginalReleaseYear = true,
bool includeLanguage = true,
bool includeScript = true,
bool includeLabel = true,
bool includeBarcode = true,
bool includeReleaseStatus = true,
bool includeReleaseCountry = true,
bool includeMediaFormat = true,
bool includePackaging = true,
bool includeAsin = true,
bool includeWorkTitle = true,
bool includeMusicKey = true,
bool includeBpm = true,
bool includeDurationInSeconds = true,
bool includeSampleRate = true,
bool includeChannels = true,
bool includeBitDepth = true,
bool includeBitrate = true,
bool includeAudioCodec = true,
bool includeContainer = true,
bool includeWebsite = true,
bool includeMusicBrainzArtistId = true,
bool includeMusicBrainzReleaseArtistId = true,
bool includeMusicBrainzReleaseGroupId = true,
bool includeMusicBrainzReleaseId = true,
bool includeMusicBrainzRecordingId = true,
bool includeMusicBrainzReleaseTrackId = true,
bool includeMusicBrainzWorkId = true)
{
return new Id3TagDto
@@ -230,6 +234,7 @@ internal sealed class Id3TagDtoFixture
BitDepth = includeBitDepth ? bitDepth ?? _faker.PickRandom(16, 24, 32) : null,
Bitrate = includeBitrate ? bitrate ?? _faker.Random.Int(128, 320) : null,
AudioCodec = includeAudioCodec ? audioCodec ?? _faker.PickRandom("PCM Audio", "MPEG Audio") : null,
Container = includeContainer ? container ?? _faker.PickRandom("MP3", "FLAC", "OGG", "WAV") : null,
Website = includeWebsite ? website ?? _faker.Internet.Url() : null,
MusicBrainzArtistId = includeMusicBrainzArtistId ? musicBrainzArtistId ?? Guid.NewGuid().ToString() : null,
MusicBrainzReleaseArtistId = includeMusicBrainzReleaseArtistId ? musicBrainzReleaseArtistId ?? Guid.NewGuid().ToString() : null,
@@ -673,6 +673,7 @@ public class Id3TagMapperTests
bitDepth: 24,
bitrate: 320,
audioCodec: "MPEG Audio",
container: "FLAC",
originalReleaseDate: new DateOnly(1975, 11, 21),
originalReleaseYear: 1975,
releaseCountry: "US",
@@ -719,6 +720,7 @@ public class Id3TagMapperTests
Assert.Equal(24, result.BitDepth);
Assert.Equal(320, result.Bitrate);
Assert.Equal("MPEG Audio", result.AudioCodec);
Assert.Equal("FLAC", result.Container);
Assert.Equal(recordingId, result.MusicBrainzRecordingId);
Assert.Equal(releaseTrackId, result.MusicBrainzTrackId);
Assert.Null(result.Ratings);
@@ -749,6 +751,7 @@ public class Id3TagMapperTests
includeBitDepth: false,
includeBitrate: false,
includeAudioCodec: false,
includeContainer: false,
includeOriginalReleaseDate: false,
includeOriginalReleaseYear: false,
includeReleaseCountry: false,
@@ -783,11 +786,25 @@ public class Id3TagMapperTests
Assert.Null(result.BitDepth);
Assert.Null(result.Bitrate);
Assert.Null(result.AudioCodec);
Assert.Null(result.Container);
Assert.Null(result.MusicBrainzRecordingId);
Assert.Null(result.MusicBrainzTrackId);
Assert.Null(result.Contributors);
}
[Fact]
public void MapTrack_WhenTheContainerIsWhiteSpace_ShouldReturnNullContainer()
{
// Arrange
Id3TagDto data = _id3TagDtoFixture.Create(container: " ");
// Act
AudioMetadataDto result = Id3TagMapper.MapTrack(data);
// Assert
Assert.Null(result.Container);
}
[Fact]
public void MapTrack_WhenThereIsNoReleaseInformation_ShouldReturnNullReleaseInfo()
{
@@ -1051,6 +1051,7 @@ public class MusicBrainzMapperTests
Assert.Null(result.Channels);
Assert.Null(result.BitDepth);
Assert.Null(result.AudioCodec);
Assert.Null(result.Container); // a metadata provider never supplies the container, which is captured locally from the file
Assert.Null(result.Bitrate);
Assert.Equal(recordingId, result.MusicBrainzRecordingId);
Assert.Null(result.MusicBrainzTrackId);