You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
3.0 KiB
84 lines
3.0 KiB
3 years ago
|
using System;
|
||
|
using System.Globalization;
|
||
|
using System.IO;
|
||
|
using System.Threading;
|
||
|
using System.Threading.Tasks;
|
||
|
using AutoFixture;
|
||
|
using AutoFixture.AutoMoq;
|
||
|
using MediaBrowser.Common.Configuration;
|
||
|
using MediaBrowser.Common.Extensions;
|
||
|
using MediaBrowser.Common.Net;
|
||
|
using MediaBrowser.Controller.Entities;
|
||
|
using MediaBrowser.Controller.Library;
|
||
|
using MediaBrowser.Controller.MediaEncoding;
|
||
|
using MediaBrowser.MediaEncoding.Subtitles;
|
||
|
using MediaBrowser.Model.Dto;
|
||
|
using MediaBrowser.Model.Entities;
|
||
|
using MediaBrowser.Model.IO;
|
||
|
using MediaBrowser.Model.MediaInfo;
|
||
|
using Microsoft.Extensions.Logging.Abstractions;
|
||
|
using Moq;
|
||
|
using Xunit;
|
||
|
|
||
|
namespace Jellyfin.MediaEncoding.Subtitles.Tests
|
||
|
{
|
||
|
public class SubtitleEncoderTests
|
||
|
{
|
||
|
internal static TheoryData<MediaSourceInfo, MediaStream, SubtitleEncoder.SubtitleInfo> GetReadableFile_Valid_TestData()
|
||
|
{
|
||
|
var data = new TheoryData<MediaSourceInfo, MediaStream, SubtitleEncoder.SubtitleInfo>();
|
||
|
|
||
|
data.Add(
|
||
|
new MediaSourceInfo()
|
||
|
{
|
||
|
Protocol = MediaProtocol.File
|
||
|
},
|
||
|
new MediaStream()
|
||
|
{
|
||
|
Path = "/media/sub.ass",
|
||
|
IsExternal = true
|
||
|
},
|
||
|
new SubtitleEncoder.SubtitleInfo("/media/sub.ass", MediaProtocol.File, "ass", true));
|
||
|
|
||
|
data.Add(
|
||
|
new MediaSourceInfo()
|
||
|
{
|
||
|
Protocol = MediaProtocol.File
|
||
|
},
|
||
|
new MediaStream()
|
||
|
{
|
||
|
Path = "/media/sub.ssa",
|
||
|
IsExternal = true
|
||
|
},
|
||
|
new SubtitleEncoder.SubtitleInfo("/media/sub.ssa", MediaProtocol.File, "ssa", true));
|
||
|
|
||
|
data.Add(
|
||
|
new MediaSourceInfo()
|
||
|
{
|
||
|
Protocol = MediaProtocol.File
|
||
|
},
|
||
|
new MediaStream()
|
||
|
{
|
||
|
Path = "/media/sub.srt",
|
||
|
IsExternal = true
|
||
|
},
|
||
|
new SubtitleEncoder.SubtitleInfo("/media/sub.srt", MediaProtocol.File, "srt", true));
|
||
|
|
||
|
return data;
|
||
|
}
|
||
|
|
||
|
[Theory]
|
||
|
[MemberData(nameof(GetReadableFile_Valid_TestData))]
|
||
|
internal async Task GetReadableFile_Valid_Success(MediaSourceInfo mediaSource, MediaStream subtitleStream, SubtitleEncoder.SubtitleInfo subtitleInfo)
|
||
|
{
|
||
|
var fixture = new Fixture().Customize(new AutoMoqCustomization { ConfigureMembers = true });
|
||
|
var subtitleEncoder = fixture.Create<SubtitleEncoder>();
|
||
|
var result = await subtitleEncoder.GetReadableFile(mediaSource, subtitleStream, CancellationToken.None).ConfigureAwait(false);
|
||
|
Assert.Equal(subtitleInfo.Path, result.Path);
|
||
|
Assert.Equal(subtitleInfo.Protocol, result.Protocol);
|
||
|
Assert.Equal(subtitleInfo.Format, result.Format);
|
||
|
Assert.Equal(subtitleInfo.IsExternal, result.IsExternal);
|
||
|
}
|
||
|
}
|
||
|
}
|