add: 单元测试项目

This commit is contained in:
2024-02-18 14:47:25 +08:00
parent 51f3d4c12f
commit c62e7a9706
4 changed files with 58 additions and 2 deletions

View File

@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<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>
<ProjectReference Include="..\LeetCodeSharp\LeetCodeSharp.csproj" />
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,22 @@
using LeetCodeSharp.Problems;
using LeetCodeSharp.Utils;
namespace LeetCodeSharp.Tests;
public class P589Tests
{
[Fact]
public void Test1()
{
Node root = new Node(1, [
new Node(3),
new Node(2),
new Node(4),
]);
IList<int> except = [1, 3, 2, 4];
var solution = new Solution();
Assert.Equal(except, solution.Preorder(root));
}
}