add: 单元测试项目
This commit is contained in:
		
							
								
								
									
										27
									
								
								LeetCodeSharp.Tests/LeetCodeSharp.Tests.csproj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								LeetCodeSharp.Tests/LeetCodeSharp.Tests.csproj
									
									
									
									
									
										Normal 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>
 | 
			
		||||
							
								
								
									
										22
									
								
								LeetCodeSharp.Tests/P589Tests.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								LeetCodeSharp.Tests/P589Tests.cs
									
									
									
									
									
										Normal 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));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -3,9 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
 | 
			
		||||
# Visual Studio Version 17
 | 
			
		||||
VisualStudioVersion = 17.9.34607.119
 | 
			
		||||
MinimumVisualStudioVersion = 10.0.40219.1
 | 
			
		||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeetCodeSharp", "LeetCodeSharp\LeetCodeSharp.csproj", "{EB1DDDC1-A2FC-4AAB-A21A-59FAAFF656DD}"
 | 
			
		||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LeetCodeSharp", "LeetCodeSharp\LeetCodeSharp.csproj", "{EB1DDDC1-A2FC-4AAB-A21A-59FAAFF656DD}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeetCodeSharp.Fetcher", "LeetCodeSharp.Fetcher\LeetCodeSharp.Fetcher.csproj", "{5D45BB2A-E512-4353-8746-6F0B79282C76}"
 | 
			
		||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LeetCodeSharp.Fetcher", "LeetCodeSharp.Fetcher\LeetCodeSharp.Fetcher.csproj", "{5D45BB2A-E512-4353-8746-6F0B79282C76}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeetCodeSharp.Tests", "LeetCodeSharp.Tests\LeetCodeSharp.Tests.csproj", "{97E271FD-7244-4DD2-982C-103DF1E92B7C}"
 | 
			
		||||
EndProject
 | 
			
		||||
Global
 | 
			
		||||
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 | 
			
		||||
@@ -21,6 +23,10 @@ Global
 | 
			
		||||
		{5D45BB2A-E512-4353-8746-6F0B79282C76}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{5D45BB2A-E512-4353-8746-6F0B79282C76}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{5D45BB2A-E512-4353-8746-6F0B79282C76}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{97E271FD-7244-4DD2-982C-103DF1E92B7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{97E271FD-7244-4DD2-982C-103DF1E92B7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{97E271FD-7244-4DD2-982C-103DF1E92B7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{97E271FD-7244-4DD2-982C-103DF1E92B7C}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
	EndGlobalSection
 | 
			
		||||
	GlobalSection(SolutionProperties) = preSolution
 | 
			
		||||
		HideSolutionNode = FALSE
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@ namespace LeetCodeSharp.Utils
 | 
			
		||||
        public Node(int _val)
 | 
			
		||||
        {
 | 
			
		||||
            val = _val;
 | 
			
		||||
            children = new List<Node>();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Node(int _val, IList<Node> _children)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user