Skip to content

Commit e347f5d

Browse files
committed
Added MSSExtractorTest
1 parent 7378732 commit e347f5d

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
using System.Reflection;
2+
using FluentAssertions;
3+
using N_m3u8DL_RE.Parser.Config;
4+
using N_m3u8DL_RE.Parser.Extractor;
5+
6+
7+
namespace N_m3u8DL_RE.Parser.Tests.Extractor;
8+
9+
[TestClass]
10+
public class MSSExtractorTest
11+
{
12+
[TestMethod]
13+
public void TestMethod1()
14+
{
15+
var uri = getResourceUri("Extractor/SuperSpeedway_720.ism.manifest.xml");
16+
var rawText = File.ReadAllText(uri.LocalPath);
17+
var parserConfig = new ParserConfig
18+
{
19+
Url = uri.AbsoluteUri,
20+
OriginalUrl = uri.AbsoluteUri
21+
};
22+
var extractor = new MSSExtractor(parserConfig);
23+
var streamSpecs = extractor.ExtractStreamsAsync(rawText).Result;
24+
streamSpecs.Should().HaveCount(9);
25+
var streamSpec0 = streamSpecs[0];
26+
streamSpec0.PeriodId.Should().Be("0");
27+
streamSpec0.GroupId.Should().Be("video");
28+
streamSpec0.Bandwidth.Should().Be(2962000);
29+
streamSpec0.Codecs.Should().Be("avc1.64001F");
30+
streamSpec0.Resolution.Should().Be("1280x720");
31+
streamSpec0.Channels.Should().Be(null);
32+
streamSpec0.MSSData.SamplingRate.Should().Be(48000);
33+
streamSpec0.MSSData.BitsPerSample.Should().Be(16);
34+
streamSpec0.MSSData.NalUnitLengthField.Should().Be(4);
35+
36+
var streamSpec1 = streamSpecs[1];
37+
streamSpec1.PeriodId.Should().Be("1");
38+
streamSpec1.GroupId.Should().Be("video");
39+
streamSpec1.Bandwidth.Should().Be(2056000);
40+
streamSpec1.Codecs.Should().Be("avc1.64001F");
41+
streamSpec1.Resolution.Should().Be("992x560");
42+
streamSpec1.Channels.Should().Be(null);
43+
streamSpec1.MSSData!.SamplingRate.Should().Be(48000);
44+
streamSpec1.MSSData.BitsPerSample.Should().Be(16);
45+
streamSpec1.MSSData.NalUnitLengthField.Should().Be(4);
46+
47+
var streamSpec5 = streamSpecs[5];
48+
streamSpec5.PeriodId.Should().Be("5");
49+
streamSpec5.GroupId.Should().Be("video");
50+
streamSpec5.Bandwidth.Should().Be(477000);
51+
streamSpec5.Codecs.Should().Be("avc1.64000D");
52+
streamSpec5.Resolution.Should().Be("368x208");
53+
streamSpec5.Channels.Should().Be(null);
54+
streamSpec5.MSSData!.SamplingRate.Should().Be(48000);
55+
streamSpec5.MSSData.BitsPerSample.Should().Be(16);
56+
streamSpec5.MSSData.NalUnitLengthField.Should().Be(4);
57+
58+
var streamSpec8 = streamSpecs[8];
59+
streamSpec8.PeriodId.Should().Be(null);
60+
streamSpec8.GroupId.Should().Be("audio");
61+
streamSpec8.Bandwidth.Should().Be(128000);
62+
streamSpec8.Codecs.Should().Be("mp4a.40.2");
63+
streamSpec8.Resolution.Should().Be(null);
64+
streamSpec8.Channels.Should().Be("2");
65+
streamSpec8.MSSData!.SamplingRate.Should().Be(44100);
66+
streamSpec8.MSSData.BitsPerSample.Should().Be(16);
67+
streamSpec8.MSSData.NalUnitLengthField.Should().Be(4);
68+
}
69+
70+
private Uri getResourceUri(string resourceName)
71+
{
72+
var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
73+
var path = System.IO.Path.Combine(directory, resourceName);
74+
return new Uri("file://" + path);
75+
}
76+
}
Binary file not shown.

src/N_m3u8DL-RE.Parser.Tests/N_m3u8DL-RE.Parser.Tests.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14+
<PackageReference Include="FluentAssertions" Version="6.12.1" />
1415
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/>
1516
<PackageReference Include="MSTest.TestAdapter" Version="3.0.4"/>
1617
<PackageReference Include="MSTest.TestFramework" Version="3.0.4"/>
@@ -21,4 +22,10 @@
2122
<ProjectReference Include="..\N_m3u8DL-RE.Parser\N_m3u8DL-RE.Parser.csproj" />
2223
</ItemGroup>
2324

25+
<ItemGroup>
26+
<None Update="Extractor\SuperSpeedway_720.ism.manifest.xml">
27+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
28+
</None>
29+
</ItemGroup>
30+
2431
</Project>

0 commit comments

Comments
 (0)