feat: 完善单元测试
parent
5800f7167b
commit
2fdb95e350
|
|
@ -14,6 +14,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserPointManagement.Model",
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserPointManagement.Tests", "test\UserPointManagement.Tests\UserPointManagement.Tests.csproj", "{F831F9D1-54CD-4566-ADBB-BAE879A78488}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserPointManagement.Persistence.Tests", "test\UserPointManagement.Persistence.Tests\UserPointManagement.Persistence.Tests.csproj", "{5FAB91B4-2C42-4A41-A0B0-ED5887C82C15}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserPointManagement.Application.Tests", "test\UserPointManagement.Application.Tests\UserPointManagement.Application.Tests.csproj", "{5770D3E5-9B3E-40FC-8209-62F0B4B45BD4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -40,6 +44,14 @@ Global
|
|||
{F831F9D1-54CD-4566-ADBB-BAE879A78488}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F831F9D1-54CD-4566-ADBB-BAE879A78488}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F831F9D1-54CD-4566-ADBB-BAE879A78488}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5FAB91B4-2C42-4A41-A0B0-ED5887C82C15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5FAB91B4-2C42-4A41-A0B0-ED5887C82C15}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5FAB91B4-2C42-4A41-A0B0-ED5887C82C15}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5FAB91B4-2C42-4A41-A0B0-ED5887C82C15}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5770D3E5-9B3E-40FC-8209-62F0B4B45BD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5770D3E5-9B3E-40FC-8209-62F0B4B45BD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5770D3E5-9B3E-40FC-8209-62F0B4B45BD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5770D3E5-9B3E-40FC-8209-62F0B4B45BD4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{F76FAFB7-B604-4CD6-AF5D-B7BB47F34EFC} = {14E4E7B1-DAC3-4F63-9C6F-3875AE5C7502}
|
||||
|
|
@ -47,5 +59,7 @@ Global
|
|||
{F7D6BA14-96C2-4DA9-8BC7-F50DFA14EC66} = {14E4E7B1-DAC3-4F63-9C6F-3875AE5C7502}
|
||||
{75EC6A62-86F4-4D0C-A222-9BA11AA82A0E} = {14E4E7B1-DAC3-4F63-9C6F-3875AE5C7502}
|
||||
{F831F9D1-54CD-4566-ADBB-BAE879A78488} = {EB952040-7FE7-492A-BBAA-E347A3C049F1}
|
||||
{5FAB91B4-2C42-4A41-A0B0-ED5887C82C15} = {EB952040-7FE7-492A-BBAA-E347A3C049F1}
|
||||
{5770D3E5-9B3E-40FC-8209-62F0B4B45BD4} = {EB952040-7FE7-492A-BBAA-E347A3C049F1}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Services" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\UserPointManagement.Tests\UserPointManagement.Tests.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<XunitStartupAssembly>UserPointManagement.Tests</XunitStartupAssembly>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\UserPointManagement.Persistence\UserPointManagement.Persistence.csproj" />
|
||||
<ProjectReference Include="..\UserPointManagement.Tests\UserPointManagement.Tests.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<XunitStartupAssembly>UserPointManagement.Tests</XunitStartupAssembly>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Xunit;
|
||||
|
||||
namespace UserPointManagement.Persistence.Tests;
|
||||
|
||||
public class UserPointManagementDbContextTest
|
||||
{
|
||||
private readonly UserPointManagementDbContext _userPointManagementDbContext;
|
||||
|
||||
public UserPointManagementDbContextTest(UserPointManagementDbContext userPointManagementDbContext)
|
||||
{
|
||||
_userPointManagementDbContext = userPointManagementDbContext;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Test()
|
||||
{
|
||||
await _userPointManagementDbContext.Users.AnyAsync().ConfigureAwait(false);
|
||||
|
||||
Assert.True(true);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue