增加单元测试框架 (#726)

This commit is contained in:
nilaoda
2025-10-26 01:11:51 +08:00
committed by GitHub
parent fb7aab5285
commit 7309625fb7
3 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
using N_m3u8DL_RE.Common.Util;
namespace N_m3u8DL_RE.Tests.Common.Util;
public class HexUtilTests
{
[Fact]
public void BytesToHex_MultipleBytesWithDefaultSplit_ReturnsHexChars()
{
var result = HexUtil.BytesToHex([0xAB, 0xCD, 0xEF]);
Assert.Equal("ABCDEF", result);
}
[Fact]
public void BytesToHex_MultipleBytesWithCustomSplit_ReturnsHexChars()
{
var result = HexUtil.BytesToHex([0xAA, 0xBB, 0xCC], ":");
Assert.Equal("AA:BB:CC", result);
}
}

View File

@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>N_m3u8DL_RE.Tests</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageReference Include="xunit" Version="2.5.3"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3"/>
</ItemGroup>
<ItemGroup>
<Using Include="Xunit"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\N_m3u8DL-RE.Common\N_m3u8DL-RE.Common.csproj" />
</ItemGroup>
</Project>

View File

@@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "N_m3u8DL-RE.Common", "N_m3u
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "N_m3u8DL-RE.Parser", "N_m3u8DL-RE.Parser\N_m3u8DL-RE.Parser.csproj", "{0DA02925-AF3A-4598-AF01-91AE5539FCA1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "N_m3u8DL-RE.Tests", "N_m3u8DL-RE.Tests\N_m3u8DL-RE.Tests.csproj", "{CF51B8FF-E4EF-49D6-8595-AFAFD96D9253}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -27,6 +29,10 @@ Global
{0DA02925-AF3A-4598-AF01-91AE5539FCA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DA02925-AF3A-4598-AF01-91AE5539FCA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DA02925-AF3A-4598-AF01-91AE5539FCA1}.Release|Any CPU.Build.0 = Release|Any CPU
{CF51B8FF-E4EF-49D6-8595-AFAFD96D9253}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF51B8FF-E4EF-49D6-8595-AFAFD96D9253}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF51B8FF-E4EF-49D6-8595-AFAFD96D9253}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF51B8FF-E4EF-49D6-8595-AFAFD96D9253}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE