mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 18:57:24 +00:00
Reorganizes the shared media library enumerations and adds the image file extension helper
This commit is contained in:
1 parent
ed96046769
commit
5529e99024
11 files changed
+286
-50
No files matched your search
@@ -1,22 +0,0 @@
|
||||
namespace Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration for the status of the artwork enrichment of a book artwork.
|
||||
/// </summary>
|
||||
public enum ArtworkStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// The artwork of the book has not been resolved yet.
|
||||
/// </summary>
|
||||
Pending,
|
||||
|
||||
/// <summary>
|
||||
/// The artwork of the book has been successfully resolved.
|
||||
/// </summary>
|
||||
Enriched,
|
||||
|
||||
/// <summary>
|
||||
/// The artwork resolution of the book failed.
|
||||
/// </summary>
|
||||
Failed
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
namespace Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration for the status of the metadata enrichment of a book.
|
||||
/// </summary>
|
||||
public enum MetadataStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// The metadata of the book has not been enriched yet.
|
||||
/// </summary>
|
||||
Pending,
|
||||
|
||||
/// <summary>
|
||||
/// The metadata of the book has been successfully enriched.
|
||||
/// </summary>
|
||||
Enriched,
|
||||
|
||||
/// <summary>
|
||||
/// The metadata enrichment of the book failed.
|
||||
/// </summary>
|
||||
Failed
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using System.Diagnostics;
|
||||
namespace Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration for the country of a media release, using the ISO 3166-1 alpha-2 country codes.
|
||||
/// Enumeration for the country of a media release, using the ISO 3166-1 alpha-2 country codes, together with the MusicBrainz special codes for releases issued across Europe or worldwide.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
public enum ReleaseCountry
|
||||
@@ -988,5 +988,20 @@ public enum ReleaseCountry
|
||||
/// <summary>
|
||||
/// The ISO 3166-1 alpha-2 code of Zimbabwe.
|
||||
/// </summary>
|
||||
ZW
|
||||
ZW,
|
||||
|
||||
/// <summary>
|
||||
/// The ISO 3166-1 alpha-2 code of the Netherlands Antilles, withdrawn in 2010.
|
||||
/// </summary>
|
||||
AN,
|
||||
|
||||
/// <summary>
|
||||
/// The MusicBrainz code for a release issued across Europe.
|
||||
/// </summary>
|
||||
XE,
|
||||
|
||||
/// <summary>
|
||||
/// The MusicBrainz code for a release issued worldwide.
|
||||
/// </summary>
|
||||
XW
|
||||
}
|
||||
+6
-1
@@ -176,5 +176,10 @@ public enum MediaContributorRole
|
||||
/// <summary>
|
||||
/// The contributor orchestrated the music of the media item.
|
||||
/// </summary>
|
||||
Orchestrator
|
||||
Orchestrator,
|
||||
|
||||
/// <summary>
|
||||
/// The contributor performed the media item, without a more specific role being known.
|
||||
/// </summary>
|
||||
Performer
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration for the status of the artwork enrichment of a media library item.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
public enum ArtworkStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// The artwork of the media library item has not been resolved yet.
|
||||
/// </summary>
|
||||
Pending,
|
||||
|
||||
/// <summary>
|
||||
/// The artwork of the media library item has been successfully resolved.
|
||||
/// </summary>
|
||||
Enriched,
|
||||
|
||||
/// <summary>
|
||||
/// The artwork of the media library item was searched for, and no artwork exists for it.
|
||||
/// </summary>
|
||||
NotAvailable,
|
||||
|
||||
/// <summary>
|
||||
/// The artwork resolution of the media library item failed, because an error prevented the artwork from being retrieved.
|
||||
/// </summary>
|
||||
Failed
|
||||
}
|
||||
@@ -16,5 +16,85 @@ public enum ArtworkType
|
||||
/// <summary>
|
||||
/// The main artwork of the media library item, like the cover of a book.
|
||||
/// </summary>
|
||||
Cover
|
||||
Cover,
|
||||
|
||||
/// <summary>
|
||||
/// The front of the artwork of the media library item, when it is stored separately from the cover.
|
||||
/// </summary>
|
||||
Front,
|
||||
|
||||
/// <summary>
|
||||
/// The back of the artwork of the media library item.
|
||||
/// </summary>
|
||||
Back,
|
||||
|
||||
/// <summary>
|
||||
/// A page of the booklet of the media library item.
|
||||
/// </summary>
|
||||
Booklet,
|
||||
|
||||
/// <summary>
|
||||
/// The artwork printed on the medium of the media library item, like a disc label.
|
||||
/// </summary>
|
||||
Medium,
|
||||
|
||||
/// <summary>
|
||||
/// The artwork printed on the tray of the media library item.
|
||||
/// </summary>
|
||||
Tray,
|
||||
|
||||
/// <summary>
|
||||
/// The artwork printed on the spine of the media library item.
|
||||
/// </summary>
|
||||
Spine,
|
||||
|
||||
/// <summary>
|
||||
/// The obi strip of the media library item.
|
||||
/// </summary>
|
||||
Obi,
|
||||
|
||||
/// <summary>
|
||||
/// The sticker of the media library item.
|
||||
/// </summary>
|
||||
Sticker,
|
||||
|
||||
/// <summary>
|
||||
/// The poster of the media library item.
|
||||
/// </summary>
|
||||
Poster,
|
||||
|
||||
/// <summary>
|
||||
/// The liner notes of the media library item.
|
||||
/// </summary>
|
||||
Liner,
|
||||
|
||||
/// <summary>
|
||||
/// A watermark carried by the artwork of the media library item.
|
||||
/// </summary>
|
||||
Watermark,
|
||||
|
||||
/// <summary>
|
||||
/// The backdrop, or fanart, of the media library item.
|
||||
/// </summary>
|
||||
Backdrop,
|
||||
|
||||
/// <summary>
|
||||
/// The banner of the media library item.
|
||||
/// </summary>
|
||||
Banner,
|
||||
|
||||
/// <summary>
|
||||
/// The logo of the media library item.
|
||||
/// </summary>
|
||||
Logo,
|
||||
|
||||
/// <summary>
|
||||
/// The thumbnail of the media library item.
|
||||
/// </summary>
|
||||
Thumb,
|
||||
|
||||
/// <summary>
|
||||
/// Any other artwork of the media library item.
|
||||
/// </summary>
|
||||
Other
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration for the status of the metadata enrichment of a media library item.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
public enum MetadataStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// The metadata of the media library item has not been enriched yet.
|
||||
/// </summary>
|
||||
Pending,
|
||||
|
||||
/// <summary>
|
||||
/// The metadata of the media library item has been successfully enriched.
|
||||
/// </summary>
|
||||
Enriched,
|
||||
|
||||
/// <summary>
|
||||
/// The metadata enrichment of the media library item failed.
|
||||
/// </summary>
|
||||
Failed
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Common.Utilities;
|
||||
|
||||
/// <summary>
|
||||
/// Provides helpers for the <see cref="ImageType"/> enumeration.
|
||||
/// </summary>
|
||||
public static class ImageTypeUtilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the conventional file extension of the provided <paramref name="imageType"/>, without the leading dot.
|
||||
/// </summary>
|
||||
/// <param name="imageType">The image type whose file extension is resolved.</param>
|
||||
/// <returns>The file extension of the image type, or <c>bin</c> when the type is not a recognized image.</returns>
|
||||
public static string ToFileExtension(this ImageType imageType)
|
||||
{
|
||||
return imageType switch
|
||||
{
|
||||
ImageType.BMP => "bmp",
|
||||
ImageType.GIF => "gif",
|
||||
ImageType.PNG => "png",
|
||||
ImageType.TIFF => "tiff",
|
||||
ImageType.JPEG or ImageType.JPEG_CANON or ImageType.JPEG_UNKNOWN => "jpg",
|
||||
ImageType.PICT => "pct",
|
||||
ImageType.ICO => "ico",
|
||||
ImageType.PSD => "psd",
|
||||
ImageType.JPEG2000 => "jp2",
|
||||
ImageType.AVIF => "avif",
|
||||
ImageType.WEBP => "webp",
|
||||
ImageType.TGA => "tga",
|
||||
ImageType.SVG => "svg",
|
||||
_ => "bin"
|
||||
};
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.UnitTests.Common.Enums.MediaLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ArtworkStatus"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ArtworkStatusTests
|
||||
{
|
||||
[Fact]
|
||||
public void ArtworkStatus_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
ArtworkStatus[] values = Enum.GetValues<ArtworkStatus>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.UnitTests.Common.Enums.BookLibrary;
|
||||
namespace Lumina.Domain.SharedKernel.UnitTests.Common.Enums.MediaLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="MetadataStatus"/> enumeration.
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
using Lumina.Infrastructure.Common.Utilities;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.UnitTests.Common.Utilities;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ImageTypeUtilities"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ImageTypeUtilitiesTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(ImageType.BMP, "bmp")] // bitmap image
|
||||
[InlineData(ImageType.GIF, "gif")] // graphics interchange format
|
||||
[InlineData(ImageType.PNG, "png")] // portable network graphics
|
||||
[InlineData(ImageType.TIFF, "tiff")] // tagged image file format
|
||||
[InlineData(ImageType.PICT, "pct")] // macintosh picture
|
||||
[InlineData(ImageType.ICO, "ico")] // icon format
|
||||
[InlineData(ImageType.PSD, "psd")] // photoshop document
|
||||
[InlineData(ImageType.JPEG2000, "jp2")] // jpeg 2000
|
||||
[InlineData(ImageType.AVIF, "avif")] // av1 image file format
|
||||
[InlineData(ImageType.WEBP, "webp")] // web picture format
|
||||
[InlineData(ImageType.TGA, "tga")] // truevision tga
|
||||
[InlineData(ImageType.SVG, "svg")] // scalable vector graphics
|
||||
public void ToFileExtension_WhenTypeIsRecognized_ShouldReturnConventionalExtension(ImageType imageType, string expectedExtension)
|
||||
{
|
||||
// Act
|
||||
string result = imageType.ToFileExtension();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedExtension, result);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(ImageType.JPEG)] // joint photographic experts group
|
||||
[InlineData(ImageType.JPEG_CANON)] // canon-specific jpeg
|
||||
[InlineData(ImageType.JPEG_UNKNOWN)] // unknown jpeg
|
||||
public void ToFileExtension_WhenTypeIsAnyJpeg_ShouldReturnJpg(ImageType imageType)
|
||||
{
|
||||
// Act
|
||||
string result = imageType.ToFileExtension();
|
||||
|
||||
// Assert
|
||||
Assert.Equal("jpg", result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToFileExtension_WhenTypeIsNotARecognizedImage_ShouldReturnBin()
|
||||
{
|
||||
// Act
|
||||
string result = ImageType.None.ToFileExtension();
|
||||
|
||||
// Assert
|
||||
Assert.Equal("bin", result);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user