< Summary - Jellyfin

Information
Class: MediaBrowser.Model.Drawing.ImageFormatExtensions
Assembly: MediaBrowser.Model
File(s): /srv/git/jellyfin/MediaBrowser.Model/Drawing/ImageFormatExtensions.cs
Line coverage
100%
Covered lines: 20
Uncovered lines: 0
Coverable lines: 20
Total lines: 46
Line coverage: 100%
Branch coverage
100%
Covered branches: 14
Total branches: 14
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetMimeType(...)100%77100%
GetExtension(...)100%77100%

File(s)

/srv/git/jellyfin/MediaBrowser.Model/Drawing/ImageFormatExtensions.cs

#LineLine coverage
 1using System.ComponentModel;
 2using System.Net.Mime;
 3
 4namespace MediaBrowser.Model.Drawing;
 5
 6/// <summary>
 7/// Extension class for the <see cref="ImageFormat" /> enum.
 8/// </summary>
 9public static class ImageFormatExtensions
 10{
 11    /// <summary>
 12    /// Returns the correct mime type for this <see cref="ImageFormat" />.
 13    /// </summary>
 14    /// <param name="format">This <see cref="ImageFormat" />.</param>
 15    /// <exception cref="InvalidEnumArgumentException">The <paramref name="format"/> is an invalid enumeration value.</e
 16    /// <returns>The correct mime type for this <see cref="ImageFormat" />.</returns>
 17    public static string GetMimeType(this ImageFormat format)
 1218        => format switch
 1219        {
 120            ImageFormat.Bmp => "image/bmp",
 121            ImageFormat.Gif => MediaTypeNames.Image.Gif,
 322            ImageFormat.Jpg => MediaTypeNames.Image.Jpeg,
 123            ImageFormat.Png => "image/png",
 124            ImageFormat.Webp => "image/webp",
 125            ImageFormat.Svg => "image/svg+xml",
 426            _ => throw new InvalidEnumArgumentException(nameof(format), (int)format, typeof(ImageFormat))
 1227        };
 28
 29    /// <summary>
 30    /// Returns the correct extension for this <see cref="ImageFormat" />.
 31    /// </summary>
 32    /// <param name="format">This <see cref="ImageFormat" />.</param>
 33    /// <exception cref="InvalidEnumArgumentException">The <paramref name="format"/> is an invalid enumeration value.</e
 34    /// <returns>The correct extension for this <see cref="ImageFormat" />.</returns>
 35    public static string GetExtension(this ImageFormat format)
 1036        => format switch
 1037        {
 138            ImageFormat.Bmp => ".bmp",
 139            ImageFormat.Gif => ".gif",
 140            ImageFormat.Jpg => ".jpg",
 141            ImageFormat.Png => ".png",
 142            ImageFormat.Webp => ".webp",
 143            ImageFormat.Svg => ".svg",
 444            _ => throw new InvalidEnumArgumentException(nameof(format), (int)format, typeof(ImageFormat))
 1045        };
 46}