2021-05-07 22:33:24 +00:00
|
|
|
using System;
|
|
|
|
using Jellyfin.Api.Controllers;
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
namespace Jellyfin.Api.Tests.Controllers
|
|
|
|
{
|
|
|
|
public class DynamicHlsControllerTests
|
|
|
|
{
|
|
|
|
[Theory]
|
|
|
|
[MemberData(nameof(GetSegmentLengths_Success_TestData))]
|
|
|
|
public void GetSegmentLengths_Success(long runtimeTicks, int segmentlength, double[] expected)
|
|
|
|
{
|
|
|
|
var res = DynamicHlsController.GetSegmentLengthsInternal(runtimeTicks, segmentlength);
|
|
|
|
Assert.Equal(expected.Length, res.Length);
|
|
|
|
for (int i = 0; i < expected.Length; i++)
|
|
|
|
{
|
|
|
|
Assert.Equal(expected[i], res[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-11 20:31:24 +00:00
|
|
|
public static TheoryData<long, int, double[]> GetSegmentLengths_Success_TestData()
|
2021-05-07 22:33:24 +00:00
|
|
|
{
|
2021-09-11 20:31:24 +00:00
|
|
|
var data = new TheoryData<long, int, double[]>();
|
|
|
|
data.Add(0, 6, Array.Empty<double>());
|
|
|
|
data.Add(
|
2021-05-07 22:33:24 +00:00
|
|
|
TimeSpan.FromSeconds(3).Ticks,
|
|
|
|
6,
|
2021-09-11 20:31:24 +00:00
|
|
|
new double[] { 3 });
|
|
|
|
data.Add(
|
2021-05-07 22:33:24 +00:00
|
|
|
TimeSpan.FromSeconds(6).Ticks,
|
|
|
|
6,
|
2021-09-11 20:31:24 +00:00
|
|
|
new double[] { 6 });
|
|
|
|
data.Add(
|
2021-05-07 22:33:24 +00:00
|
|
|
TimeSpan.FromSeconds(3.3333333).Ticks,
|
|
|
|
6,
|
2021-09-11 20:31:24 +00:00
|
|
|
new double[] { 3.3333333 });
|
|
|
|
data.Add(
|
2021-05-07 22:33:24 +00:00
|
|
|
TimeSpan.FromSeconds(9.3333333).Ticks,
|
|
|
|
6,
|
2021-09-11 20:31:24 +00:00
|
|
|
new double[] { 6, 3.3333333 });
|
|
|
|
|
|
|
|
return data;
|
2021-05-07 22:33:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|