aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonFlagEnumTests.cs
blob: c8652b3233e7f3a5fb282f2f9dbf7490e87f264d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System.Text.Json;
using Jellyfin.Extensions.Json.Converters;
using MediaBrowser.Model.Session;
using Xunit;

namespace Jellyfin.Extensions.Tests.Json.Converters;

public class JsonFlagEnumTests
{
    private readonly JsonSerializerOptions _jsonOptions = new()
    {
        Converters =
        {
            new JsonFlagEnumConverter<TranscodeReason>()
        }
    };

    [Theory]
    [InlineData(TranscodeReason.AudioIsExternal | TranscodeReason.ContainerNotSupported, "[\"ContainerNotSupported\",\"AudioIsExternal\"]")]
    [InlineData(TranscodeReason.AudioIsExternal | TranscodeReason.ContainerNotSupported | TranscodeReason.VideoBitDepthNotSupported, "[\"ContainerNotSupported\",\"AudioIsExternal\",\"VideoBitDepthNotSupported\"]")]
    [InlineData((TranscodeReason)0, "[]")]
    public void Serialize_Transcode_Reason(TranscodeReason transcodeReason, string output)
    {
        var result = JsonSerializer.Serialize(transcodeReason, _jsonOptions);

        Assert.Equal(output, result);
    }
}