Adds the ID3 music metadata plugin and its unit and integration test suites

This commit is contained in:
BinaryAlley committed 2026-09-30 12:00:00 +03:00
1 parent 80af18170a
commit 1ffa14cec4
27 files changed
+4842

No files matched your search

@@ -0,0 +1,253 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Plugins.ID3.Common.Models.DTO.Tags;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Plugins.ID3.Fixtures.Common.Models.DTO.Tags;
/// <summary>
/// Fixture class for generating <see cref="Id3TagDto"/> test data.
/// </summary>
[ExcludeFromCodeCoverage]
internal sealed class Id3TagDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// 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>
/// <param name="conductors">Optional. The conductors credited on the track.</param>
/// <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="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="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,
List<string>? conductors = null,
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? 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 includeMusicBrainzWorkId = true)
{
return new Id3TagDto
{
Title = includeTitle ? title ?? _faker.Lorem.Sentence(3) : null,
Album = includeAlbum ? album ?? _faker.Lorem.Sentence(2) : null,
TrackArtists = trackArtists ?? [.. _faker.Make(2, () => _faker.Name.FullName())],
AlbumArtists = albumArtists ?? [.. _faker.Make(2, () => _faker.Name.FullName())],
AlbumArtistSortName = includeAlbumArtistSortName ? albumArtistSortName ?? _faker.Name.LastName() : null,
TrackArtistSortName = includeTrackArtistSortName ? trackArtistSortName ?? _faker.Name.LastName() : null,
TrackNumber = trackNumber ?? (uint)_faker.Random.Int(1, 30),
TrackCount = trackCount ?? (uint)_faker.Random.Int(1, 30),
DiscNumber = discNumber ?? (uint)_faker.Random.Int(1, 4),
DiscCount = discCount ?? (uint)_faker.Random.Int(1, 4),
Year = includeYear ? year ?? _faker.Random.Int(1950, 2024) : null,
OriginalReleaseDate = includeOriginalReleaseDate ? originalReleaseDate ?? DateOnly.FromDateTime(_faker.Date.Past()) : null,
OriginalReleaseYear = includeOriginalReleaseYear ? originalReleaseYear ?? _faker.Random.Int(1950, 2024) : null,
Genres = genres ?? [.. _faker.Make(2, () => _faker.Lorem.Word())],
Composers = composers ?? [.. _faker.Make(2, () => _faker.Name.FullName())],
Lyricists = lyricists ?? [.. _faker.Make(2, () => _faker.Name.FullName())],
Conductors = conductors ?? [.. _faker.Make(2, () => _faker.Name.FullName())],
Remixers = remixers ?? [.. _faker.Make(2, () => _faker.Name.FullName())],
InvolvedPeople = involvedPeople ?? [(_faker.PickRandom("producer", "engineer", "mixer"), _faker.Name.FullName())],
Language = includeLanguage ? language ?? _faker.Random.String2(3, "abcdefghijklmnopqrstuvwxyz") : null,
Script = includeScript ? script ?? _faker.Random.String2(4, "abcdefghijklmnopqrstuvwxyz") : null,
Label = includeLabel ? label ?? _faker.Company.CompanyName() : null,
CatalogNumbers = catalogNumbers ?? [.. _faker.Make(2, () => _faker.Random.AlphaNumeric(8))],
Barcode = includeBarcode ? barcode ?? _faker.Random.AlphaNumeric(12) : null,
ReleaseTypes = releaseTypes ?? [_faker.PickRandom("album", "single", "ep")],
ReleaseStatus = includeReleaseStatus ? releaseStatus ?? _faker.PickRandom("official", "promotion") : null,
ReleaseCountry = includeReleaseCountry ? releaseCountry ?? _faker.PickRandom("US", "GB", "DE") : null,
MediaFormat = includeMediaFormat ? mediaFormat ?? _faker.PickRandom("CD", "Vinyl") : null,
Packaging = includePackaging ? packaging ?? _faker.PickRandom("Jewel Case", "Digipak") : null,
Asin = includeAsin ? asin ?? _faker.Random.AlphaNumeric(10) : null,
Isrcs = isrcs ?? [.. _faker.Make(2, () => $"US{_faker.Random.AlphaNumeric(10).ToUpperInvariant()}")],
Moods = moods ?? [.. _faker.Make(2, () => _faker.Lorem.Word())],
WorkTitle = includeWorkTitle ? workTitle ?? _faker.Lorem.Sentence(3) : null,
MusicKey = includeMusicKey ? musicKey ?? _faker.PickRandom("C major", "A minor") : null,
Bpm = includeBpm ? bpm ?? _faker.Random.Int(60, 200) : null,
DurationInSeconds = includeDurationInSeconds ? durationInSeconds ?? _faker.Random.Int(30, 600) : null,
SampleRate = includeSampleRate ? sampleRate ?? _faker.PickRandom(44100, 48000, 96000) : null,
Channels = includeChannels ? channels ?? _faker.Random.Int(1, 2) : null,
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,
Website = includeWebsite ? website ?? _faker.Internet.Url() : null,
MusicBrainzArtistId = includeMusicBrainzArtistId ? musicBrainzArtistId ?? Guid.NewGuid().ToString() : null,
MusicBrainzReleaseArtistId = includeMusicBrainzReleaseArtistId ? musicBrainzReleaseArtistId ?? Guid.NewGuid().ToString() : null,
MusicBrainzReleaseGroupId = includeMusicBrainzReleaseGroupId ? musicBrainzReleaseGroupId ?? Guid.NewGuid().ToString() : null,
MusicBrainzReleaseId = includeMusicBrainzReleaseId ? musicBrainzReleaseId ?? Guid.NewGuid().ToString() : null,
MusicBrainzRecordingId = includeMusicBrainzRecordingId ? musicBrainzRecordingId ?? Guid.NewGuid().ToString() : null,
MusicBrainzReleaseTrackId = includeMusicBrainzReleaseTrackId ? musicBrainzReleaseTrackId ?? Guid.NewGuid().ToString() : null,
MusicBrainzWorkId = includeMusicBrainzWorkId ? musicBrainzWorkId ?? Guid.NewGuid().ToString() : null
};
}
/// <summary>
/// Creates multiple <see cref="Id3TagDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="Id3TagDto"/> instances.</returns>
public List<Id3TagDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,124 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Text;
#endregion
namespace Lumina.Plugins.ID3.Fixtures.Core.Tags;
/// <summary>
/// Builds minimal, structurally valid WAV files used as test input for the ID3 tag reading tests.
/// The files are produced into a temporary directory at test runtime, because a WAV is a binary container whose
/// embedded tags can only be written by the tagging library itself.
/// </summary>
[ExcludeFromCodeCoverage]
public static class TestAudioFileFactory
{
/// <summary>
/// Creates a minimal, untagged PCM WAV file.
/// </summary>
/// <param name="path">The path where the WAV is written.</param>
/// <param name="durationMs">The duration of the audio of the file, in milliseconds.</param>
public static void CreateWav(string path, int durationMs = 200)
{
File.WriteAllBytes(path, BuildWav(durationMs));
}
/// <summary>
/// Creates a PCM WAV file whose embedded tags are configured by the provided callback.
/// </summary>
/// <param name="path">The path where the WAV is written.</param>
/// <param name="configureTags">The callback that configures the tags of the file.</param>
/// <param name="durationMs">The duration of the audio of the file, in milliseconds.</param>
public static void CreateTaggedWav(string path, Action<TagLib.File> configureTags, int durationMs = 200)
{
File.WriteAllBytes(path, BuildWav(durationMs));
using (TagLib.File tagFile = TagLib.File.Create(path))
{
configureTags(tagFile);
tagFile.Save();
}
}
/// <summary>
/// Adds a user defined text information frame (TXXX) to the ID3v2 tag of the file.
/// </summary>
/// <param name="tagFile">The file whose ID3v2 tag is extended.</param>
/// <param name="description">The description that identifies the frame.</param>
/// <param name="values">The values of the frame.</param>
public static void AddUserTextFrame(TagLib.File tagFile, string description, params string[] values)
{
GetId3v2Tag(tagFile).AddFrame(new TagLib.Id3v2.UserTextInformationFrame(description) { Text = values });
}
/// <summary>
/// Adds a text information frame to the ID3v2 tag of the file.
/// </summary>
/// <param name="tagFile">The file whose ID3v2 tag is extended.</param>
/// <param name="frameId">The four character identifier of the frame.</param>
/// <param name="values">The values of the frame.</param>
public static void AddTextFrame(TagLib.File tagFile, string frameId, params string[] values)
{
GetId3v2Tag(tagFile).AddFrame(new TagLib.Id3v2.TextInformationFrame(frameId) { Text = values });
}
/// <summary>
/// Adds a URL link frame (WXXX/WOAR) to the ID3v2 tag of the file.
/// </summary>
/// <param name="tagFile">The file whose ID3v2 tag is extended.</param>
/// <param name="frameId">The four character identifier of the frame.</param>
/// <param name="values">The URL values of the frame.</param>
public static void AddUrlFrame(TagLib.File tagFile, string frameId, params string[] values)
{
GetId3v2Tag(tagFile).AddFrame(new TagLib.Id3v2.UrlLinkFrame(frameId) { Text = values });
}
/// <summary>
/// Gets the ID3v2 tag of the file, creating it when the file does not carry one yet.
/// </summary>
/// <param name="tagFile">The file whose ID3v2 tag is read.</param>
/// <returns>The ID3v2 tag of the file.</returns>
private static TagLib.Id3v2.Tag GetId3v2Tag(TagLib.File tagFile)
{
return tagFile.GetTag(TagLib.TagTypes.Id3v2, true) as TagLib.Id3v2.Tag
?? throw new InvalidOperationException("The test audio file does not expose an ID3v2 tag.");
}
/// <summary>
/// Builds the bytes of a minimal, valid PCM WAV file with a single silent audio channel.
/// </summary>
/// <param name="durationMs">The duration of the audio of the file, in milliseconds.</param>
/// <returns>The bytes of the WAV file.</returns>
private static byte[] BuildWav(int durationMs)
{
const int SAMPLE_RATE = 44100;
const short CHANNELS = 1;
const short BITS_PER_SAMPLE = 16;
int bytesPerSample = BITS_PER_SAMPLE / 8;
int dataSize = SAMPLE_RATE * CHANNELS * bytesPerSample * durationMs / 1000;
using (MemoryStream memoryStream = new())
{
using (BinaryWriter writer = new(memoryStream))
{
writer.Write(Encoding.ASCII.GetBytes("RIFF"));
writer.Write(36 + dataSize);
writer.Write(Encoding.ASCII.GetBytes("WAVE"));
writer.Write(Encoding.ASCII.GetBytes("fmt "));
writer.Write(16);
writer.Write((short)1);
writer.Write(CHANNELS);
writer.Write(SAMPLE_RATE);
writer.Write(SAMPLE_RATE * CHANNELS * bytesPerSample);
writer.Write((short)(CHANNELS * bytesPerSample));
writer.Write(BITS_PER_SAMPLE);
writer.Write(Encoding.ASCII.GetBytes("data"));
writer.Write(dataSize);
writer.Write(new byte[dataSize]);
}
return memoryStream.ToArray();
}
}
}
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<BaseOutputPath>$(SolutionDir)..\bin\api\</BaseOutputPath>
<IsPackable>false</IsPackable>
<IsTestProject>false</IsTestProject>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoFixture" />
<PackageReference Include="AutoFixture.AutoNSubstitute" />
<PackageReference Include="AutoFixture.Xunit2" />
<PackageReference Include="Bogus" />
<PackageReference Include="TagLibSharp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\plugins\Lumina.Plugins.ID3\Lumina.Plugins.ID3.csproj" />
<ProjectReference Include="..\..\..\src\Lumina.Plugins.Contracts\Lumina.Plugins.Contracts.csproj" />
<ProjectReference Include="..\..\Common\Lumina.Contracts.Fixtures\Lumina.Contracts.Fixtures.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,21 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Lumina.Plugins.ID3.Fixtures")]
[assembly: AssemblyProduct("Lumina.Plugins.ID3.Fixtures")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("BB7E0186-B7E4-4DD2-AC9C-2C900EAF1D96")]
[assembly: InternalsVisibleTo("Lumina.Plugins.ID3.UnitTests")]
[assembly: InternalsVisibleTo("Lumina.Plugins.ID3.IntegrationTests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
@@ -0,0 +1,102 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Plugins.ID3.Core;
using Lumina.Plugins.ID3.Core.Tags;
using Lumina.Plugins.ID3.Fixtures.Core.Tags;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Plugins.ID3.IntegrationTests.Core;
/// <summary>
/// Contains integration tests for the <see cref="Id3AlbumMetadataProvider"/> class, reading real tagged audio containers.
/// </summary>
[ExcludeFromCodeCoverage]
public class Id3AlbumMetadataProviderTests : IDisposable
{
private readonly AlbumMetadataLookupDtoFixture _albumMetadataLookupDtoFixture = new();
private readonly Id3AlbumMetadataProvider _sut = new(new Id3TagReader());
private readonly string _temporaryDirectory;
/// <summary>
/// Initializes a new instance of the <see cref="Id3AlbumMetadataProviderTests"/> class.
/// </summary>
public Id3AlbumMetadataProviderTests()
{
_temporaryDirectory = Path.Combine(Path.GetTempPath(), $"lumina-id3-album-{Guid.NewGuid():N}");
Directory.CreateDirectory(_temporaryDirectory);
}
[Fact]
public async Task GetMetadataAsync_WhenTheTagsCarryAnAlbum_ShouldReturnTheMappedAlbum()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "tagged.wav");
TestAudioFileFactory.CreateTaggedWav(path, file =>
{
file.Tag.Album = "The Album";
file.Tag.AlbumArtists = ["The Album Artist"];
file.Tag.TrackCount = 10;
file.Tag.DiscCount = 2;
});
AlbumMetadataLookupDto lookup = _albumMetadataLookupDtoFixture.Create(path: path, title: "The Album");
// Act
AlbumMetadataDto? result = await _sut.GetMetadataAsync(lookup, CancellationToken.None);
// Assert
Assert.NotNull(result);
Assert.Equal("The Album", result.Title);
Assert.Equal(10, result.TotalTracks);
Assert.Equal(2, result.TotalDiscs);
Assert.NotNull(result.Contributors);
Assert.Contains(result.Contributors, contributor => contributor.Name!.DisplayName == "The Album Artist");
}
[Fact]
public async Task GetMetadataAsync_WhenTheTagsCarryNoAlbum_ShouldReturnNull()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "untagged.wav");
TestAudioFileFactory.CreateWav(path);
AlbumMetadataLookupDto lookup = _albumMetadataLookupDtoFixture.Create(path: path, title: "The Album");
// Act
AlbumMetadataDto? result = await _sut.GetMetadataAsync(lookup, CancellationToken.None);
// Assert
Assert.Null(result);
}
[Fact]
public async Task GetSearchResultsAsync_WhenTheTagsCarryAnAlbum_ShouldReturnASingleCandidate()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "tagged.wav");
TestAudioFileFactory.CreateTaggedWav(path, file => file.Tag.Album = "The Album");
AlbumMetadataLookupDto lookup = _albumMetadataLookupDtoFixture.Create(path: path, title: "The Album");
// Act
IReadOnlyList<AlbumMetadataDto> result = await _sut.GetSearchResultsAsync(lookup, CancellationToken.None);
// Assert
AlbumMetadataDto candidate = Assert.Single(result);
Assert.Equal("The Album", candidate.Title);
}
/// <summary>
/// Removes the temporary directory created for the test.
/// </summary>
public void Dispose()
{
if (Directory.Exists(_temporaryDirectory))
Directory.Delete(_temporaryDirectory, recursive: true);
GC.SuppressFinalize(this);
}
}
@@ -0,0 +1,100 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Plugins.ID3.Core;
using Lumina.Plugins.ID3.Core.Tags;
using Lumina.Plugins.ID3.Fixtures.Core.Tags;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Plugins.ID3.IntegrationTests.Core;
/// <summary>
/// Contains integration tests for the <see cref="Id3ArtistMetadataProvider"/> class, reading real tagged audio containers.
/// </summary>
[ExcludeFromCodeCoverage]
public class Id3ArtistMetadataProviderTests : IDisposable
{
private readonly ArtistMetadataLookupDtoFixture _artistMetadataLookupDtoFixture = new();
private readonly Id3ArtistMetadataProvider _sut = new(new Id3TagReader());
private readonly string _temporaryDirectory;
/// <summary>
/// Initializes a new instance of the <see cref="Id3ArtistMetadataProviderTests"/> class.
/// </summary>
public Id3ArtistMetadataProviderTests()
{
_temporaryDirectory = Path.Combine(Path.GetTempPath(), $"lumina-id3-artist-{Guid.NewGuid():N}");
Directory.CreateDirectory(_temporaryDirectory);
}
[Fact]
public async Task GetMetadataAsync_WhenTheTagsCarryAnArtist_ShouldReturnTheMappedArtist()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "tagged.wav");
Guid artistId = Guid.NewGuid();
TestAudioFileFactory.CreateTaggedWav(path, file =>
{
file.Tag.Performers = ["The Artist"];
file.Tag.PerformersSort = ["Artist, The"];
file.Tag.MusicBrainzArtistId = artistId.ToString();
});
ArtistMetadataLookupDto lookup = _artistMetadataLookupDtoFixture.Create(path: path, name: "The Artist");
// Act
ArtistMetadataDto? result = await _sut.GetMetadataAsync(lookup, CancellationToken.None);
// Assert
Assert.NotNull(result);
Assert.Equal("The Artist", result.Name);
Assert.Equal("Artist, The", result.SortName);
Assert.Equal(artistId, result.MusicBrainzArtistId);
}
[Fact]
public async Task GetMetadataAsync_WhenTheTagsCarryNoArtist_ShouldReturnNull()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "untagged.wav");
TestAudioFileFactory.CreateWav(path);
ArtistMetadataLookupDto lookup = _artistMetadataLookupDtoFixture.Create(path: path, name: "The Artist");
// Act
ArtistMetadataDto? result = await _sut.GetMetadataAsync(lookup, CancellationToken.None);
// Assert
Assert.Null(result);
}
[Fact]
public async Task GetSearchResultsAsync_WhenTheTagsCarryAnArtist_ShouldReturnASingleCandidate()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "tagged.wav");
TestAudioFileFactory.CreateTaggedWav(path, file => file.Tag.Performers = ["The Artist"]);
ArtistMetadataLookupDto lookup = _artistMetadataLookupDtoFixture.Create(path: path, name: "The Artist");
// Act
IReadOnlyList<ArtistMetadataDto> result = await _sut.GetSearchResultsAsync(lookup, CancellationToken.None);
// Assert
ArtistMetadataDto candidate = Assert.Single(result);
Assert.Equal("The Artist", candidate.Name);
}
/// <summary>
/// Removes the temporary directory created for the test.
/// </summary>
public void Dispose()
{
if (Directory.Exists(_temporaryDirectory))
Directory.Delete(_temporaryDirectory, recursive: true);
GC.SuppressFinalize(this);
}
}
@@ -0,0 +1,103 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
using Lumina.Plugins.ID3.Core;
using Lumina.Plugins.ID3.Core.Tags;
using Lumina.Plugins.ID3.Fixtures.Core.Tags;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Plugins.ID3.IntegrationTests.Core;
/// <summary>
/// Contains integration tests for the <see cref="Id3TrackMetadataProvider"/> class, reading real tagged audio containers.
/// </summary>
[ExcludeFromCodeCoverage]
public class Id3TrackMetadataProviderTests : IDisposable
{
private readonly TrackMetadataLookupDtoFixture _trackMetadataLookupDtoFixture = new();
private readonly Id3TrackMetadataProvider _sut = new(new Id3TagReader());
private readonly string _temporaryDirectory;
/// <summary>
/// Initializes a new instance of the <see cref="Id3TrackMetadataProviderTests"/> class.
/// </summary>
public Id3TrackMetadataProviderTests()
{
_temporaryDirectory = Path.Combine(Path.GetTempPath(), $"lumina-id3-track-{Guid.NewGuid():N}");
Directory.CreateDirectory(_temporaryDirectory);
}
[Fact]
public async Task GetMetadataAsync_WhenTheTagsCarryATitle_ShouldReturnTheMappedTrack()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "tagged.wav");
TestAudioFileFactory.CreateTaggedWav(path, file =>
{
file.Tag.Title = "The Track";
file.Tag.InitialKey = "C#m";
file.Tag.BeatsPerMinute = 128;
file.Tag.Performers = ["The Artist"];
});
TrackMetadataLookupDto lookup = _trackMetadataLookupDtoFixture.Create(path: path, title: "The Track");
// Act
AudioMetadataDto? result = await _sut.GetMetadataAsync(lookup, CancellationToken.None);
// Assert
Assert.NotNull(result);
Assert.Equal("The Track", result.Title);
Assert.Equal(MusicKey.CSharpMinor, result.Key);
Assert.Equal(128, result.Bpm);
Assert.NotNull(result.Contributors);
Assert.Contains(result.Contributors, contributor => contributor.Name!.DisplayName == "The Artist");
}
[Fact]
public async Task GetMetadataAsync_WhenTheTagsCarryNoTitle_ShouldReturnNull()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "untagged.wav");
TestAudioFileFactory.CreateWav(path);
TrackMetadataLookupDto lookup = _trackMetadataLookupDtoFixture.Create(path: path, title: "The Track");
// Act
AudioMetadataDto? result = await _sut.GetMetadataAsync(lookup, CancellationToken.None);
// Assert
Assert.Null(result);
}
[Fact]
public async Task GetSearchResultsAsync_WhenTheTagsCarryATitle_ShouldReturnASingleCandidate()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "tagged.wav");
TestAudioFileFactory.CreateTaggedWav(path, file => file.Tag.Title = "The Track");
TrackMetadataLookupDto lookup = _trackMetadataLookupDtoFixture.Create(path: path, title: "The Track");
// Act
IReadOnlyList<AudioMetadataDto> result = await _sut.GetSearchResultsAsync(lookup, CancellationToken.None);
// Assert
AudioMetadataDto candidate = Assert.Single(result);
Assert.Equal("The Track", candidate.Title);
}
/// <summary>
/// Removes the temporary directory created for the test.
/// </summary>
public void Dispose()
{
if (Directory.Exists(_temporaryDirectory))
Directory.Delete(_temporaryDirectory, recursive: true);
GC.SuppressFinalize(this);
}
}
@@ -0,0 +1,480 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Plugins.ID3.Common.Models.DTO.Tags;
using Lumina.Plugins.ID3.Core.Tags;
using Lumina.Plugins.ID3.Fixtures.Core.Tags;
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
#endregion
namespace Lumina.Plugins.ID3.IntegrationTests.Core.Tags;
/// <summary>
/// Contains integration tests for the <see cref="Id3TagReader"/> class, reading real audio containers through the tagging library.
/// </summary>
[ExcludeFromCodeCoverage]
public class Id3TagReaderTests : IDisposable
{
private readonly Id3TagReader _sut = new();
private readonly string _temporaryDirectory;
/// <summary>
/// Initializes a new instance of the <see cref="Id3TagReaderTests"/> class.
/// </summary>
public Id3TagReaderTests()
{
_temporaryDirectory = Path.Combine(Path.GetTempPath(), $"lumina-id3-reader-{Guid.NewGuid():N}");
Directory.CreateDirectory(_temporaryDirectory);
}
[Fact]
public void Read_WhenEveryTagIsPresent_ShouldMapEveryProperty()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "all-fields.wav");
Guid artistId = Guid.NewGuid();
Guid releaseArtistId = Guid.NewGuid();
Guid releaseGroupId = Guid.NewGuid();
Guid releaseId = Guid.NewGuid();
Guid recordingId = Guid.NewGuid();
Guid releaseTrackId = Guid.NewGuid();
Guid workId = Guid.NewGuid();
TestAudioFileFactory.CreateTaggedWav(path, file =>
{
file.Tag.Title = "The Track";
file.Tag.Album = "The Album";
file.Tag.Performers = ["Track Artist"];
file.Tag.AlbumArtists = ["Album Artist"];
file.Tag.PerformersSort = ["Track Artist, The"];
file.Tag.AlbumArtistsSort = ["Album Artist, The"];
file.Tag.Track = 3;
file.Tag.TrackCount = 12;
file.Tag.Disc = 1;
file.Tag.DiscCount = 2;
file.Tag.Genres = ["Rock/Pop", "Jazz"];
file.Tag.Composers = ["Composer One/Composer Two"];
file.Tag.Conductor = "The Conductor";
file.Tag.RemixedBy = "The Remixer";
file.Tag.Publisher = "The Label";
file.Tag.ISRC = "GBAAA0000001";
file.Tag.InitialKey = "C#m";
file.Tag.BeatsPerMinute = 128;
file.Tag.AmazonId = "B000000001";
file.Tag.MusicBrainzArtistId = artistId.ToString();
file.Tag.MusicBrainzReleaseArtistId = releaseArtistId.ToString();
file.Tag.MusicBrainzReleaseGroupId = releaseGroupId.ToString();
file.Tag.MusicBrainzReleaseId = releaseId.ToString();
file.Tag.MusicBrainzTrackId = recordingId.ToString();
file.Tag.MusicBrainzReleaseType = "album";
file.Tag.MusicBrainzReleaseStatus = "official";
file.Tag.MusicBrainzReleaseCountry = "US";
TestAudioFileFactory.AddTextFrame(file, "TDRC", "2011-03-14");
TestAudioFileFactory.AddTextFrame(file, "TDOR", "1975-11-21");
TestAudioFileFactory.AddUserTextFrame(file, "LYRICIST", "Lyricist One;Lyricist Two");
TestAudioFileFactory.AddTextFrame(file, "IPLS", "producer", "Producer Person", "engineer", "Engineer Person");
TestAudioFileFactory.AddUserTextFrame(file, "LANGUAGE", "eng");
TestAudioFileFactory.AddUserTextFrame(file, "SCRIPT", "Latn");
TestAudioFileFactory.AddUserTextFrame(file, "CATALOGNUMBER", "CAT-1;CAT-2");
TestAudioFileFactory.AddUserTextFrame(file, "BARCODE", "1234567890123");
TestAudioFileFactory.AddUserTextFrame(file, "MEDIA", "CD");
TestAudioFileFactory.AddUserTextFrame(file, "PACKAGING", "Jewel Case");
TestAudioFileFactory.AddUserTextFrame(file, "MOODS", "calm;happy");
TestAudioFileFactory.AddUserTextFrame(file, "WORK", "The Work");
TestAudioFileFactory.AddUserTextFrame(file, "MUSICBRAINZ_WORKID", workId.ToString());
TestAudioFileFactory.AddUserTextFrame(file, "MUSICBRAINZ_RELEASETRACKID", releaseTrackId.ToString());
TestAudioFileFactory.AddUserTextFrame(file, "website", "https://artist.example");
}, durationMs: 2000);
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.NotNull(result);
Assert.Equal("The Track", result.Title);
Assert.Equal("The Album", result.Album);
Assert.Equal(["Track Artist"], result.TrackArtists);
Assert.Equal(["Album Artist"], result.AlbumArtists);
Assert.Equal("Album Artist, The", result.AlbumArtistSortName);
Assert.Equal("Track Artist, The", result.TrackArtistSortName);
Assert.Equal(3u, result.TrackNumber);
Assert.Equal(12u, result.TrackCount);
Assert.Equal(1u, result.DiscNumber);
Assert.Equal(2u, result.DiscCount);
Assert.Equal(2011, result.Year);
Assert.Equal(new DateOnly(1975, 11, 21), result.OriginalReleaseDate);
Assert.Equal(1975, result.OriginalReleaseYear);
Assert.Equal(["Rock", "Pop", "Jazz"], result.Genres);
Assert.Equal(["Composer One", "Composer Two"], result.Composers);
Assert.Equal(["Lyricist One", "Lyricist Two"], result.Lyricists);
Assert.Equal(["The Conductor"], result.Conductors);
Assert.Equal(["The Remixer"], result.Remixers);
Assert.Equal([("producer", "Producer Person"), ("engineer", "Engineer Person")], result.InvolvedPeople);
Assert.Equal("eng", result.Language);
Assert.Equal("Latn", result.Script);
Assert.Equal("The Label", result.Label);
Assert.Equal(["CAT-1", "CAT-2"], result.CatalogNumbers);
Assert.Equal("1234567890123", result.Barcode);
Assert.Equal(["album"], result.ReleaseTypes);
Assert.Equal("official", result.ReleaseStatus);
Assert.Equal("US", result.ReleaseCountry);
Assert.Equal("CD", result.MediaFormat);
Assert.Equal("Jewel Case", result.Packaging);
Assert.Equal("B000000001", result.Asin);
Assert.Equal(["GBAAA0000001"], result.Isrcs);
Assert.Equal(["calm", "happy"], result.Moods);
Assert.Equal("The Work", result.WorkTitle);
Assert.Equal("C#m", result.MusicKey);
Assert.Equal(128, result.Bpm);
Assert.Equal(2, result.DurationInSeconds);
Assert.Equal(44100, result.SampleRate);
Assert.Equal(1, result.Channels);
Assert.Equal(16, result.BitDepth);
Assert.True(result.Bitrate > 0);
Assert.Equal("PCM Audio", result.AudioCodec);
Assert.Equal("https://artist.example", result.Website);
Assert.Equal(artistId.ToString(), result.MusicBrainzArtistId);
Assert.Equal(releaseArtistId.ToString(), result.MusicBrainzReleaseArtistId);
Assert.Equal(releaseGroupId.ToString(), result.MusicBrainzReleaseGroupId);
Assert.Equal(releaseId.ToString(), result.MusicBrainzReleaseId);
Assert.Equal(recordingId.ToString(), result.MusicBrainzRecordingId);
Assert.Equal(releaseTrackId.ToString(), result.MusicBrainzReleaseTrackId);
Assert.Equal(workId.ToString(), result.MusicBrainzWorkId);
}
[Fact]
public void Read_WhenTheFileIsUntagged_ShouldReturnASnapshotWithTheAudioProperties()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "untagged.wav");
TestAudioFileFactory.CreateWav(path);
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.NotNull(result);
Assert.Null(result.Title);
Assert.Null(result.Album);
Assert.Empty(result.TrackArtists);
Assert.Empty(result.AlbumArtists);
Assert.Null(result.AlbumArtistSortName);
Assert.Null(result.TrackArtistSortName);
Assert.Equal(0u, result.TrackNumber);
Assert.Equal(0u, result.TrackCount);
Assert.Equal(0u, result.DiscNumber);
Assert.Equal(0u, result.DiscCount);
Assert.Null(result.Year);
Assert.Null(result.OriginalReleaseDate);
Assert.Null(result.OriginalReleaseYear);
Assert.Empty(result.Genres);
Assert.Empty(result.Composers);
Assert.Empty(result.Lyricists);
Assert.Empty(result.Conductors);
Assert.Empty(result.Remixers);
Assert.Empty(result.InvolvedPeople);
Assert.Null(result.Language);
Assert.Null(result.Script);
Assert.Null(result.Label);
Assert.Empty(result.CatalogNumbers);
Assert.Null(result.Barcode);
Assert.Empty(result.ReleaseTypes);
Assert.Null(result.ReleaseStatus);
Assert.Null(result.ReleaseCountry);
Assert.Null(result.MediaFormat);
Assert.Null(result.Packaging);
Assert.Null(result.Asin);
Assert.Empty(result.Isrcs);
Assert.Empty(result.Moods);
Assert.Null(result.WorkTitle);
Assert.Null(result.MusicKey);
Assert.Null(result.Bpm);
Assert.Equal(44100, result.SampleRate);
Assert.Equal(1, result.Channels);
Assert.Equal(16, result.BitDepth);
Assert.Equal("PCM Audio", result.AudioCodec);
Assert.Null(result.Website);
Assert.Null(result.MusicBrainzArtistId);
Assert.Null(result.MusicBrainzReleaseArtistId);
Assert.Null(result.MusicBrainzReleaseGroupId);
Assert.Null(result.MusicBrainzReleaseId);
Assert.Null(result.MusicBrainzRecordingId);
Assert.Null(result.MusicBrainzReleaseTrackId);
Assert.Null(result.MusicBrainzWorkId);
}
[Fact]
public void Read_WhenTheFileIsNotAnAudioContainer_ShouldReturnNull()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "not-audio.txt");
File.WriteAllText(path, "this is not an audio file");
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.Null(result);
}
[Fact]
public void Read_WhenCalledTwiceForTheSamePath_ShouldReturnTheCachedSnapshot()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "cached.wav");
TestAudioFileFactory.CreateTaggedWav(path, file => file.Tag.Title = "The Track");
// Act
Id3TagDto? first = _sut.Read(path);
Id3TagDto? second = _sut.Read(path);
// Assert
Assert.NotNull(first);
Assert.Same(first, second);
}
[Theory]
[InlineData("2011-03-14", 2011)] // a full date yields its year
[InlineData("2011", 2011)] // a bare year is matched by the year pattern
[InlineData("released in 1999 remastered", 1999)] // a year embedded in free form text is still matched
public void Read_WhenTheReleaseDateIsPresent_ShouldParseTheYear(string releaseDate, int expectedYear)
{
// Arrange
string path = Path.Combine(_temporaryDirectory, $"release-date-{Guid.NewGuid():N}.wav");
TestAudioFileFactory.CreateTaggedWav(path, file => TestAudioFileFactory.AddUserTextFrame(file, "TDRC", releaseDate));
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.NotNull(result);
Assert.Equal(expectedYear, result.Year);
}
[Fact]
public void Read_WhenOnlyTheYearTagIsPresent_ShouldMapTheYear()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "year-only.wav");
TestAudioFileFactory.CreateTaggedWav(path, file => file.Tag.Year = 1999);
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.NotNull(result);
Assert.Equal(1999, result.Year);
Assert.Null(result.OriginalReleaseDate);
Assert.Equal(1999, result.OriginalReleaseYear);
}
[Fact]
public void Read_WhenOnlyTheOriginalYearIsPresent_ShouldUseItForTheOriginalReleaseYear()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "original-year.wav");
TestAudioFileFactory.CreateTaggedWav(path, file =>
{
file.Tag.Year = 2000;
TestAudioFileFactory.AddUserTextFrame(file, "originalyear", "1960");
});
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.NotNull(result);
Assert.Equal(2000, result.Year);
Assert.Null(result.OriginalReleaseDate);
Assert.Equal(1960, result.OriginalReleaseYear);
}
[Fact]
public void Read_WhenOnlyTheOriginalReleaseDateIsPresent_ShouldDeriveTheOriginalReleaseYearFromIt()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "original-date.wav");
TestAudioFileFactory.CreateTaggedWav(path, file =>
{
TestAudioFileFactory.AddUserTextFrame(file, "TDRC", "2011-03-14");
TestAudioFileFactory.AddUserTextFrame(file, "TDOR", "1975-11-21");
});
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.NotNull(result);
Assert.Equal(new DateOnly(1975, 11, 21), result.OriginalReleaseDate);
Assert.Equal(1975, result.OriginalReleaseYear);
}
[Fact]
public void Read_WhenTheLabelIsOnlyCarriedByTheExtendedTag_ShouldUseIt()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "extended-label.wav");
TestAudioFileFactory.CreateTaggedWav(path, file => TestAudioFileFactory.AddUserTextFrame(file, "LABEL", "The Extended Label"));
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.NotNull(result);
Assert.Equal("The Extended Label", result.Label);
}
[Fact]
public void Read_WhenTheAsinIsOnlyCarriedByTheExtendedTag_ShouldUseIt()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "extended-asin.wav");
TestAudioFileFactory.CreateTaggedWav(path, file => TestAudioFileFactory.AddUserTextFrame(file, "ASIN", "B000000001"));
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.NotNull(result);
Assert.Equal("B000000001", result.Asin);
}
[Fact]
public void Read_WhenTheLanguageUsesTheAlternativeKey_ShouldStillMapIt()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "tlan.wav");
TestAudioFileFactory.CreateTaggedWav(path, file => TestAudioFileFactory.AddUserTextFrame(file, "TLAN", "deu"));
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.NotNull(result);
Assert.Equal("deu", result.Language);
}
[Fact]
public void Read_WhenTheIsrcIsBothInTheDedicatedAndTheExtendedTag_ShouldKeepOnlyDistinctValues()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "isrc-merge.wav");
TestAudioFileFactory.CreateTaggedWav(path, file =>
{
file.Tag.ISRC = "GBAAA0000001";
TestAudioFileFactory.AddTextFrame(file, "TSRC", "GBAAA0000001", "USRC17607839");
});
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.NotNull(result);
Assert.Equal(["GBAAA0000001", "USRC17607839"], result.Isrcs);
}
[Fact]
public void Read_WhenSeveralReleaseTypesArePacked_ShouldSplitThemOnSemicolons()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "release-types.wav");
TestAudioFileFactory.CreateTaggedWav(path, file => file.Tag.MusicBrainzReleaseType = "album;live");
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.NotNull(result);
Assert.Equal(["album", "live"], result.ReleaseTypes);
}
[Fact]
public void Read_WhenTheWebsiteIsAUrlLinkFrame_ShouldMapIt()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "woar.wav");
TestAudioFileFactory.CreateTaggedWav(path, file => TestAudioFileFactory.AddUrlFrame(file, "WOAR", "https://artist.example"));
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.NotNull(result);
Assert.Equal("https://artist.example", result.Website);
}
[Fact]
public void Read_WhenAFrameCarriesNoDescription_ShouldIgnoreIt()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "no-description.wav");
TestAudioFileFactory.CreateTaggedWav(path, file =>
{
TestAudioFileFactory.AddUserTextFrame(file, "", "orphan");
file.Tag.Title = "The Track";
});
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.NotNull(result);
Assert.Equal("The Track", result.Title);
}
[Fact]
public void Read_WhenAppleStyleInvolvedPeopleKeysArePresent_ShouldMapThem()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "apple-people.wav");
TestAudioFileFactory.CreateTaggedWav(path, file =>
{
TestAudioFileFactory.AddUserTextFrame(file, "performer", "Performer Person");
TestAudioFileFactory.AddUserTextFrame(file, "PRODUCER", "Producer Person");
TestAudioFileFactory.AddUserTextFrame(file, "ENGINEER", "Engineer Person");
});
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.NotNull(result);
Assert.Equal([("performer", "Performer Person"), ("producer", "Producer Person"), ("engineer", "Engineer Person")], result.InvolvedPeople);
}
[Fact]
public void Read_WhenMoreThanTheCacheLimitFilesAreRead_ShouldEvictTheOldestSnapshot()
{
// Arrange
string[] paths = new string[513];
for (int index = 0; index < paths.Length; index++)
{
paths[index] = Path.Combine(_temporaryDirectory, $"cache-{index}.wav");
TestAudioFileFactory.CreateWav(paths[index], durationMs: 1);
}
Id3TagDto? firstBeforeEviction = _sut.Read(paths[0]);
// Act
for (int index = 1; index < paths.Length; index++)
_sut.Read(paths[index]);
Id3TagDto? firstAfterEviction = _sut.Read(paths[0]);
Id3TagDto? last = _sut.Read(paths[^1]);
// Assert
Assert.NotNull(firstBeforeEviction);
Assert.NotNull(firstAfterEviction);
// The first snapshot was evicted to make room, so reading it again produced a fresh snapshot.
Assert.NotSame(firstBeforeEviction, firstAfterEviction);
// The most recently read snapshot is still cached.
Assert.Same(_sut.Read(paths[^1]), last);
}
/// <summary>
/// Removes the temporary directory created for the test.
/// </summary>
public void Dispose()
{
if (Directory.Exists(_temporaryDirectory))
Directory.Delete(_temporaryDirectory, recursive: true);
GC.SuppressFinalize(this);
}
}
@@ -0,0 +1,49 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<AssemblyAttribute Include="Xunit.CollectionBehaviorAttribute">
<_Parameter1>DisableTestParallelization = true</_Parameter1>
<_Parameter1_IsLiteral>true</_Parameter1_IsLiteral>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoFixture.AutoNSubstitute" />
<PackageReference Include="AutoFixture.Xunit2" />
<PackageReference Include="Bogus" />
<PackageReference Include="coverlet.collector">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="TagLibSharp" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\plugins\Lumina.Plugins.ID3\Lumina.Plugins.ID3.csproj" />
<ProjectReference Include="..\..\..\src\Lumina.Plugins.Contracts\Lumina.Plugins.Contracts.csproj" />
<ProjectReference Include="..\..\Common\Lumina.Plugins.ID3.Fixtures\Lumina.Plugins.ID3.Fixtures.csproj" />
<ProjectReference Include="..\..\Common\Lumina.Contracts.Fixtures\Lumina.Contracts.Fixtures.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,74 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Plugins.Contracts.Core.Metadata;
using Lumina.Plugins.ID3.Common.DependencyInjection;
using Lumina.Plugins.ID3.Core.Tags;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Plugins.ID3.UnitTests.Common.DependencyInjection;
/// <summary>
/// Contains unit tests for the <see cref="Id3Services"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class Id3ServicesTests
{
[Fact]
public void AddId3MetadataProviders_WhenServicesIsNull_ShouldThrowArgumentNullException()
{
// Arrange
IServiceCollection services = null!;
// Act
Action act = () => services.AddId3MetadataProviders(pluginId: Guid.NewGuid());
// Assert
Assert.Throws<ArgumentNullException>(act);
}
[Fact]
public void AddId3MetadataProviders_WhenCalled_ShouldReturnTheSameServiceCollection()
{
// Arrange
ServiceCollection services = new();
// Act
IServiceCollection result = services.AddId3MetadataProviders(pluginId: Guid.NewGuid());
// Assert
Assert.Same(services, result);
}
[Fact]
public void AddId3MetadataProviders_WhenCalled_ShouldRegisterTheThreeMetadataProvidersForKeyedResolution()
{
// Arrange
Guid pluginId = Guid.NewGuid();
ServiceCollection services = new();
// Act
services.AddId3MetadataProviders(pluginId: pluginId);
ServiceProvider serviceProvider = services.BuildServiceProvider();
// Assert
Assert.Equal(3, serviceProvider.GetKeyedServices<IMetadataProvider>(pluginId).Count());
Assert.Empty(serviceProvider.GetKeyedServices<IMetadataProvider>(Guid.NewGuid()));
}
[Fact]
public void AddId3MetadataProviders_WhenCalled_ShouldRegisterTheTagReaderAsScoped()
{
// Arrange
ServiceCollection services = new();
// Act
services.AddId3MetadataProviders(pluginId: Guid.NewGuid());
// Assert
ServiceDescriptor tagReaderDescriptor = Assert.Single(services, descriptor => descriptor.ServiceType == typeof(Id3TagReader));
Assert.Equal(ServiceLifetime.Scoped, tagReaderDescriptor.Lifetime);
}
}
@@ -0,0 +1,83 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using Lumina.Plugins.ID3.Core;
using Lumina.Plugins.ID3.Core.Tags;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Plugins.ID3.UnitTests.Core;
/// <summary>
/// Contains unit tests for the <see cref="Id3AlbumMetadataProvider"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class Id3AlbumMetadataProviderTests
{
private readonly AlbumMetadataLookupDtoFixture _albumMetadataLookupDtoFixture = new();
private readonly Id3AlbumMetadataProvider _sut = new(new Id3TagReader());
[Fact]
public void Name_WhenCalled_ShouldReturnTheProviderDisplayName()
{
// Act
string result = _sut.Name;
// Assert
Assert.Equal("ID3", result);
}
[Fact]
public void SupportedLibraryTypes_WhenCalled_ShouldReturnMusic()
{
// Act
IReadOnlyList<LibraryType> result = _sut.SupportedLibraryTypes;
// Assert
Assert.Equal([LibraryType.Music], result);
}
[Fact]
public void RequiresWebAccess_WhenCalled_ShouldReturnFalse()
{
// Act
bool result = _sut.RequiresWebAccess;
// Assert
Assert.False(result);
}
[Fact]
public async Task GetMetadataAsync_WhenTheFileDoesNotExist_ShouldReturnNull()
{
// Arrange
string path = Path.Combine(Path.GetTempPath(), $"missing-{Guid.NewGuid():N}.wav");
AlbumMetadataLookupDto lookup = _albumMetadataLookupDtoFixture.Create(path: path, title: "The Album");
// Act
AlbumMetadataDto? result = await _sut.GetMetadataAsync(lookup, CancellationToken.None);
// Assert
Assert.Null(result);
}
[Fact]
public async Task GetSearchResultsAsync_WhenTheFileDoesNotExist_ShouldReturnAnEmptyCollection()
{
// Arrange
string path = Path.Combine(Path.GetTempPath(), $"missing-{Guid.NewGuid():N}.wav");
AlbumMetadataLookupDto lookup = _albumMetadataLookupDtoFixture.Create(path: path, title: "The Album");
// Act
IReadOnlyList<AlbumMetadataDto> result = await _sut.GetSearchResultsAsync(lookup, CancellationToken.None);
// Assert
Assert.Empty(result);
}
}
@@ -0,0 +1,83 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using Lumina.Plugins.ID3.Core;
using Lumina.Plugins.ID3.Core.Tags;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Plugins.ID3.UnitTests.Core;
/// <summary>
/// Contains unit tests for the <see cref="Id3ArtistMetadataProvider"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class Id3ArtistMetadataProviderTests
{
private readonly ArtistMetadataLookupDtoFixture _artistMetadataLookupDtoFixture = new();
private readonly Id3ArtistMetadataProvider _sut = new(new Id3TagReader());
[Fact]
public void Name_WhenCalled_ShouldReturnTheProviderDisplayName()
{
// Act
string result = _sut.Name;
// Assert
Assert.Equal("ID3", result);
}
[Fact]
public void SupportedLibraryTypes_WhenCalled_ShouldReturnMusic()
{
// Act
IReadOnlyList<LibraryType> result = _sut.SupportedLibraryTypes;
// Assert
Assert.Equal([LibraryType.Music], result);
}
[Fact]
public void RequiresWebAccess_WhenCalled_ShouldReturnFalse()
{
// Act
bool result = _sut.RequiresWebAccess;
// Assert
Assert.False(result);
}
[Fact]
public async Task GetMetadataAsync_WhenTheFileDoesNotExist_ShouldReturnNull()
{
// Arrange
string path = Path.Combine(Path.GetTempPath(), $"missing-{Guid.NewGuid():N}.wav");
ArtistMetadataLookupDto lookup = _artistMetadataLookupDtoFixture.Create(path: path, name: "The Artist");
// Act
ArtistMetadataDto? result = await _sut.GetMetadataAsync(lookup, CancellationToken.None);
// Assert
Assert.Null(result);
}
[Fact]
public async Task GetSearchResultsAsync_WhenTheFileDoesNotExist_ShouldReturnAnEmptyCollection()
{
// Arrange
string path = Path.Combine(Path.GetTempPath(), $"missing-{Guid.NewGuid():N}.wav");
ArtistMetadataLookupDto lookup = _artistMetadataLookupDtoFixture.Create(path: path, name: "The Artist");
// Act
IReadOnlyList<ArtistMetadataDto> result = await _sut.GetSearchResultsAsync(lookup, CancellationToken.None);
// Assert
Assert.Empty(result);
}
}
@@ -0,0 +1,112 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Plugins.Contracts.Common.Models.DTO.Settings;
using Lumina.Plugins.Contracts.Core.Metadata;
using Lumina.Plugins.ID3.Core;
using Lumina.Plugins.ID3.Core.Tags;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Plugins.ID3.UnitTests.Core;
/// <summary>
/// Contains unit tests for the <see cref="Id3Plugin"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class Id3PluginTests
{
private readonly Id3Plugin _sut = new();
[Fact]
public void Id_WhenCalled_ShouldReturnStablePluginIdentifier()
{
// Act
Guid result = _sut.Id;
// Assert
Assert.Equal(Id3Plugin.s_pluginId, result);
Assert.Equal(new Guid("a3f1c8d2-6b47-4e9a-8c15-2d7f9e4b6a03"), result);
}
[Fact]
public void Name_WhenCalled_ShouldReturnPluginDisplayName()
{
// Act
string result = _sut.Name;
// Assert
Assert.Equal("ID3 Metadata", result);
}
[Fact]
public void Author_WhenCalled_ShouldReturnPluginAuthor()
{
// Act
string result = _sut.Author;
// Assert
Assert.Equal("Lumina", result);
}
[Fact]
public void Version_WhenCalled_ShouldReturnPluginVersion()
{
// Act
Version result = _sut.Version;
// Assert
Assert.Equal(new Version(1, 0, 0), result);
}
[Fact]
public void Description_WhenCalled_ShouldReturnPluginDescription()
{
// Act
string result = _sut.Description;
// Assert
Assert.Equal("Populates artist, album and track metadata from the embedded tags of the audio files, without accessing the web.", result);
}
[Fact]
public void GetSettingsSchema_WhenCalled_ShouldReturnEmptySettingsSchema()
{
// Act
IReadOnlyList<PluginSettingDescriptorDto> result = _sut.GetSettingsSchema();
// Assert
Assert.Empty(result);
}
[Fact]
public void RegisterServices_WhenCalled_ShouldRegisterTheThreeKeyedMetadataProviders()
{
// Arrange
ServiceCollection services = new();
// Act
_sut.RegisterServices(services);
ServiceProvider serviceProvider = services.BuildServiceProvider();
// Assert
Assert.Equal(3, serviceProvider.GetKeyedServices<IMetadataProvider>(Id3Plugin.s_pluginId).Count());
Assert.Empty(serviceProvider.GetKeyedServices<IMetadataProvider>(Guid.NewGuid()));
}
[Fact]
public void RegisterServices_WhenCalled_ShouldRegisterTheTagReader()
{
// Arrange
ServiceCollection services = new();
// Act
_sut.RegisterServices(services);
ServiceProvider serviceProvider = services.BuildServiceProvider();
// Assert
Assert.NotNull(serviceProvider.GetService<Id3TagReader>());
}
}
@@ -0,0 +1,83 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using Lumina.Plugins.ID3.Core;
using Lumina.Plugins.ID3.Core.Tags;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Plugins.ID3.UnitTests.Core;
/// <summary>
/// Contains unit tests for the <see cref="Id3TrackMetadataProvider"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class Id3TrackMetadataProviderTests
{
private readonly TrackMetadataLookupDtoFixture _trackMetadataLookupDtoFixture = new();
private readonly Id3TrackMetadataProvider _sut = new(new Id3TagReader());
[Fact]
public void Name_WhenCalled_ShouldReturnTheProviderDisplayName()
{
// Act
string result = _sut.Name;
// Assert
Assert.Equal("ID3", result);
}
[Fact]
public void SupportedLibraryTypes_WhenCalled_ShouldReturnMusic()
{
// Act
IReadOnlyList<LibraryType> result = _sut.SupportedLibraryTypes;
// Assert
Assert.Equal([LibraryType.Music], result);
}
[Fact]
public void RequiresWebAccess_WhenCalled_ShouldReturnFalse()
{
// Act
bool result = _sut.RequiresWebAccess;
// Assert
Assert.False(result);
}
[Fact]
public async Task GetMetadataAsync_WhenTheFileDoesNotExist_ShouldReturnNull()
{
// Arrange
string path = Path.Combine(Path.GetTempPath(), $"missing-{Guid.NewGuid():N}.wav");
TrackMetadataLookupDto lookup = _trackMetadataLookupDtoFixture.Create(path: path, title: "The Track");
// Act
AudioMetadataDto? result = await _sut.GetMetadataAsync(lookup, CancellationToken.None);
// Assert
Assert.Null(result);
}
[Fact]
public async Task GetSearchResultsAsync_WhenTheFileDoesNotExist_ShouldReturnAnEmptyCollection()
{
// Arrange
string path = Path.Combine(Path.GetTempPath(), $"missing-{Guid.NewGuid():N}.wav");
TrackMetadataLookupDto lookup = _trackMetadataLookupDtoFixture.Create(path: path, title: "The Track");
// Act
IReadOnlyList<AudioMetadataDto> result = await _sut.GetSearchResultsAsync(lookup, CancellationToken.None);
// Assert
Assert.Empty(result);
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,73 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Plugins.ID3.Common.Models.DTO.Tags;
using Lumina.Plugins.ID3.Core.Tags;
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
#endregion
namespace Lumina.Plugins.ID3.UnitTests.Core.Tags;
/// <summary>
/// Contains unit tests for the <see cref="Id3TagReader"/> class, covering the guard branches that do not reach the tagging library.
/// </summary>
[ExcludeFromCodeCoverage]
public class Id3TagReaderTests : IDisposable
{
private readonly Id3TagReader _sut = new();
private readonly string _temporaryDirectory;
/// <summary>
/// Initializes a new instance of the <see cref="Id3TagReaderTests"/> class.
/// </summary>
public Id3TagReaderTests()
{
_temporaryDirectory = Path.Combine(Path.GetTempPath(), $"lumina-id3-reader-{Guid.NewGuid():N}");
Directory.CreateDirectory(_temporaryDirectory);
}
[Fact]
public void Read_WhenPathIsNull_ShouldReturnNull()
{
// Act
Id3TagDto? result = _sut.Read(null!);
// Assert
Assert.Null(result);
}
[Theory]
[InlineData("")] // an empty path
[InlineData(" ")] // a white space path
public void Read_WhenPathIsEmptyOrWhiteSpace_ShouldReturnNull(string path)
{
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.Null(result);
}
[Fact]
public void Read_WhenTheFileDoesNotExist_ShouldReturnNull()
{
// Arrange
string path = Path.Combine(_temporaryDirectory, "missing.wav");
// Act
Id3TagDto? result = _sut.Read(path);
// Assert
Assert.Null(result);
}
/// <summary>
/// Removes the temporary directory created for the test.
/// </summary>
public void Dispose()
{
if (Directory.Exists(_temporaryDirectory))
Directory.Delete(_temporaryDirectory, recursive: true);
GC.SuppressFinalize(this);
}
}
@@ -0,0 +1,49 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<AssemblyAttribute Include="Xunit.CollectionBehaviorAttribute">
<_Parameter1>DisableTestParallelization = true</_Parameter1>
<_Parameter1_IsLiteral>true</_Parameter1_IsLiteral>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoFixture.AutoNSubstitute" />
<PackageReference Include="AutoFixture.Xunit2" />
<PackageReference Include="Bogus" />
<PackageReference Include="coverlet.collector">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="TagLibSharp" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\plugins\Lumina.Plugins.ID3\Lumina.Plugins.ID3.csproj" />
<ProjectReference Include="..\..\..\src\Lumina.Plugins.Contracts\Lumina.Plugins.Contracts.csproj" />
<ProjectReference Include="..\..\Common\Lumina.Plugins.ID3.Fixtures\Lumina.Plugins.ID3.Fixtures.csproj" />
<ProjectReference Include="..\..\Common\Lumina.Contracts.Fixtures\Lumina.Contracts.Fixtures.csproj" />
</ItemGroup>
</Project>