2024-10-25 14:33:26 -04:00
|
|
|
// Copyright (C) 2024 Intro-Skipper contributors <intro-skipper.org>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-only.
|
2024-10-25 13:42:34 -04:00
|
|
|
|
2022-06-15 01:00:03 -05:00
|
|
|
using System;
|
2024-10-20 13:56:09 +02:00
|
|
|
using IntroSkipper.Data;
|
2022-06-15 01:00:03 -05:00
|
|
|
using Xunit;
|
|
|
|
|
2024-10-20 13:56:09 +02:00
|
|
|
namespace IntroSkipper.Tests;
|
2022-06-15 01:00:03 -05:00
|
|
|
|
|
|
|
public class TestEdl
|
|
|
|
{
|
|
|
|
// Test data is from https://kodi.wiki/view/Edit_decision_list#MPlayer_EDL
|
|
|
|
[Theory]
|
|
|
|
[InlineData(5.3, 7.1, EdlAction.Cut, "5.3 7.1 0")]
|
|
|
|
[InlineData(15, 16.7, EdlAction.Mute, "15 16.7 1")]
|
|
|
|
[InlineData(420, 822, EdlAction.CommercialBreak, "420 822 3")]
|
|
|
|
[InlineData(1, 255.3, EdlAction.SceneMarker, "1 255.3 2")]
|
|
|
|
[InlineData(1.123456789, 5.654647987, EdlAction.CommercialBreak, "1.12 5.65 3")]
|
|
|
|
public void TestEdlSerialization(double start, double end, EdlAction action, string expected)
|
|
|
|
{
|
|
|
|
var intro = MakeIntro(start, end);
|
|
|
|
var actual = intro.ToEdl(action);
|
|
|
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestEdlInvalidSerialization()
|
|
|
|
{
|
2024-10-09 19:03:17 +02:00
|
|
|
Assert.Throws<ArgumentException>(() =>
|
|
|
|
{
|
2022-06-15 01:00:03 -05:00
|
|
|
var intro = MakeIntro(0, 5);
|
|
|
|
intro.ToEdl(EdlAction.None);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
[InlineData("Death Note - S01E12 - Love.mkv", "Death Note - S01E12 - Love.edl")]
|
|
|
|
[InlineData("/full/path/to/file.rm", "/full/path/to/file.edl")]
|
|
|
|
public void TestEdlPath(string mediaPath, string edlPath)
|
|
|
|
{
|
|
|
|
Assert.Equal(edlPath, EdlManager.GetEdlPath(mediaPath));
|
|
|
|
}
|
|
|
|
|
2024-09-25 17:23:25 +02:00
|
|
|
private static Segment MakeIntro(double start, double end)
|
2022-06-15 01:00:03 -05:00
|
|
|
{
|
2024-09-12 08:37:47 +00:00
|
|
|
return new Segment(Guid.Empty, new TimeRange(start, end));
|
2022-06-15 01:00:03 -05:00
|
|
|
}
|
|
|
|
}
|