jellyfin-server/tests/Jellyfin.Model.Tests/Drawing/ImageFormatExtensionsTests.cs

34 lines
994 B
C#
Raw Normal View History

2022-01-04 09:40:16 +00:00
using System;
using System.ComponentModel;
using MediaBrowser.Model.Drawing;
using Xunit;
namespace Jellyfin.Model.Drawing;
public static class ImageFormatExtensionsTests
{
2022-08-14 17:20:01 +00:00
public static TheoryData<ImageFormat> GetAllImageFormats()
2022-01-04 09:40:16 +00:00
{
var theoryTypes = new TheoryData<ImageFormat>();
foreach (var x in Enum.GetValues<ImageFormat>())
{
theoryTypes.Add(x);
}
return theoryTypes;
}
[Theory]
[MemberData(nameof(GetAllImageFormats))]
public static void GetMimeType_Valid_Valid(ImageFormat format)
=> Assert.Null(Record.Exception(() => format.GetMimeType()));
[Theory]
[InlineData((ImageFormat)int.MinValue)]
[InlineData((ImageFormat)int.MaxValue)]
[InlineData((ImageFormat)(-1))]
[InlineData((ImageFormat)5)]
public static void GetMimeType_Valid_ThrowsInvalidEnumArgumentException(ImageFormat format)
=> Assert.Throws<InvalidEnumArgumentException>(() => format.GetMimeType());
}