JsonFlagEnumTests.cs 1015 B

12345678910111213141516171819202122232425262728
  1. using System.Text.Json;
  2. using Jellyfin.Extensions.Json.Converters;
  3. using MediaBrowser.Model.Session;
  4. using Xunit;
  5. namespace Jellyfin.Extensions.Tests.Json.Converters;
  6. public class JsonFlagEnumTests
  7. {
  8. private readonly JsonSerializerOptions _jsonOptions = new()
  9. {
  10. Converters =
  11. {
  12. new JsonFlagEnumConverter<TranscodeReason>()
  13. }
  14. };
  15. [Theory]
  16. [InlineData(TranscodeReason.AudioIsExternal | TranscodeReason.ContainerNotSupported, "[\"ContainerNotSupported\",\"AudioIsExternal\"]")]
  17. [InlineData(TranscodeReason.AudioIsExternal | TranscodeReason.ContainerNotSupported | TranscodeReason.VideoBitDepthNotSupported, "[\"ContainerNotSupported\",\"AudioIsExternal\",\"VideoBitDepthNotSupported\"]")]
  18. [InlineData((TranscodeReason)0, "[]")]
  19. public void Serialize_Transcode_Reason(TranscodeReason transcodeReason, string output)
  20. {
  21. var result = JsonSerializer.Serialize(transcodeReason, _jsonOptions);
  22. Assert.Equal(output, result);
  23. }
  24. }