jellyfin-server/tests/Jellyfin.MediaEncoding.Tests/Subtitles/AssParserTests.cs

30 lines
1.1 KiB
C#
Raw Normal View History

2020-12-28 14:33:36 +00:00
using System;
using System.Globalization;
using System.IO;
using System.Threading;
using MediaBrowser.MediaEncoding.Subtitles;
2021-01-08 22:21:50 +00:00
using Microsoft.Extensions.Logging.Abstractions;
2020-12-28 14:33:36 +00:00
using Xunit;
namespace Jellyfin.MediaEncoding.Subtitles.Tests
{
public class AssParserTests
{
[Fact]
public void Parse_Valid_Success()
{
using (var stream = File.OpenRead("Test Data/example.ass"))
{
2021-01-08 22:21:50 +00:00
var parsed = new AssParser(new NullLogger<AssParser>()).Parse(stream, CancellationToken.None);
2020-12-28 14:33:36 +00:00
Assert.Single(parsed.TrackEvents);
var trackEvent = parsed.TrackEvents[0];
Assert.Equal("1", trackEvent.Id);
Assert.Equal(TimeSpan.Parse("00:00:01.18", CultureInfo.InvariantCulture).Ticks, trackEvent.StartPositionTicks);
Assert.Equal(TimeSpan.Parse("00:00:06.85", CultureInfo.InvariantCulture).Ticks, trackEvent.EndPositionTicks);
2021-01-08 22:23:48 +00:00
Assert.Equal("{\\pos(400,570)}Like an Angel with pity on nobody" + Environment.NewLine + "The second line in subtitle", trackEvent.Text);
2020-12-28 14:33:36 +00:00
}
}
}
}