2021-11-13 02:01:03 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO.Pipelines;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using BililiveRecorder.Flv.Parser;
|
|
|
|
using VerifyTests;
|
|
|
|
using VerifyXunit;
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
namespace BililiveRecorder.Flv.Tests.FlvTests
|
|
|
|
{
|
|
|
|
[UsesVerify]
|
|
|
|
[ExpectationPath("FlvParser")]
|
|
|
|
public class ParserTest
|
|
|
|
{
|
|
|
|
[Theory]
|
|
|
|
[Expectation("XmlOutput")]
|
2022-06-07 19:50:34 +08:00
|
|
|
[SampleFileTestData("../data/flv/TestData/Flv", "*.flv")]
|
2021-11-13 02:01:03 +08:00
|
|
|
public async Task ParserOutputIsCurrectAsync(string path)
|
|
|
|
{
|
|
|
|
var fullPath = SampleFileLoader.GetFullPath(path);
|
|
|
|
var tags = new List<Tag>();
|
|
|
|
var reader = new FlvTagPipeReader(PipeReader.Create(File.OpenRead(fullPath)), new TestRecyclableMemoryStreamProvider(), skipData: false, leaveOpen: false, logger: null);
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
var tag = await reader.ReadTagAsync(default).ConfigureAwait(false);
|
|
|
|
if (tag is null) break;
|
|
|
|
tags.Add(tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
await Verifier.Verify(tags.SerializeXml()).UseExtension("xml").UseParameters(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|