[InlineData(InvariantDialoguePrefix + "start {\\fnFont Name}text1 {\\fs10}text2{\\fs}{\\fn} {\\1c&H112233}text3{\\1c} end", "start <font face=\"Font Name\">text1 <font size=\"10\">text2</font></font> <font color=\"#332211\">text3</font> end")] // nested formatting public void Parse(string ssa, string expectedText) { using (Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(ssa))) { SubtitleTrackInfo subtitleTrackInfo = parser.Parse(stream, CancellationToken.None); SubtitleTrackEvent actual = subtitleTrackInfo.TrackEvents[0]; Assert.Equal(expectedText, actual.Text); } }
public void Parse_MultipleDialogues_Success(string ssa, IReadOnlyList <SubtitleTrackEvent> expectedSubtitleTrackEvents) { using (Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(ssa))) { SubtitleTrackInfo subtitleTrackInfo = _parser.Parse(stream, CancellationToken.None); Assert.Equal(expectedSubtitleTrackEvents.Count, subtitleTrackInfo.TrackEvents.Count); for (int i = 0; i < expectedSubtitleTrackEvents.Count; ++i) { SubtitleTrackEvent expected = expectedSubtitleTrackEvents[i]; SubtitleTrackEvent actual = subtitleTrackInfo.TrackEvents[i]; Assert.Equal(expected.Id, actual.Id); Assert.Equal(expected.Text, actual.Text); Assert.Equal(expected.StartPositionTicks, actual.StartPositionTicks); Assert.Equal(expected.EndPositionTicks, actual.EndPositionTicks); } } }
public void TestParse() { var expectedSubs = new SubtitleTrackInfo { TrackEvents = new List <SubtitleTrackEvent> { new SubtitleTrackEvent { Id = "1", StartPositionTicks = 24000000, EndPositionTicks = 72000000, Text = "Senator, we're <br />making our final <br />approach into Coruscant." }, new SubtitleTrackEvent { Id = "2", StartPositionTicks = 97100000, EndPositionTicks = 133900000, Text = "Very good, Lieutenant." }, new SubtitleTrackEvent { Id = "3", StartPositionTicks = 150400000, EndPositionTicks = 180400000, Text = "It's <br />a <br />trap!" } } }; var sut = new SsaParser(); var stream = File.OpenRead(@"MediaEncoding\Subtitles\TestSubtitles\data.ssa"); var result = sut.Parse(stream, CancellationToken.None); Assert.IsNotNull(result); Assert.AreEqual(expectedSubs.TrackEvents.Count, result.TrackEvents.Count); for (int i = 0; i < expectedSubs.TrackEvents.Count; i++) { Assert.AreEqual(expectedSubs.TrackEvents[i].Id, result.TrackEvents[i].Id); Assert.AreEqual(expectedSubs.TrackEvents[i].StartPositionTicks, result.TrackEvents[i].StartPositionTicks); Assert.AreEqual(expectedSubs.TrackEvents[i].EndPositionTicks, result.TrackEvents[i].EndPositionTicks); Assert.AreEqual(expectedSubs.TrackEvents[i].Text, result.TrackEvents[i].Text); } }