工具生成版本

This commit is contained in:
ShaoHua
2025-12-29 00:41:26 +08:00
commit e2fc6b5d61
244 changed files with 20445 additions and 0 deletions
@@ -0,0 +1,73 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Shouldly;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Modularity;
using Volo.Abp.Validation;
using Xunit;
namespace Hua.Abp.Demo.Books;
public abstract class BookAppService_Tests<TStartupModule> : DemoApplicationTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
private readonly IBookAppService _bookAppService;
protected BookAppService_Tests()
{
_bookAppService = GetRequiredService<IBookAppService>();
}
[Fact]
public async Task Should_Get_List_Of_Books()
{
//Act
var result = await _bookAppService.GetListAsync(
new PagedAndSortedResultRequestDto()
);
//Assert
result.TotalCount.ShouldBeGreaterThan(0);
result.Items.ShouldContain(b => b.Name == "1984");
}
[Fact]
public async Task Should_Create_A_Valid_Book()
{
//Act
var result = await _bookAppService.CreateAsync(
new CreateUpdateBookDto
{
Name = "New test book 42",
Price = 10,
PublishDate = DateTime.Now,
Type = BookType.ScienceFiction
}
);
//Assert
result.Id.ShouldNotBe(Guid.Empty);
result.Name.ShouldBe("New test book 42");
}
[Fact]
public async Task Should_Not_Create_A_Book_Without_Name()
{
var exception = await Assert.ThrowsAsync<AbpValidationException>(async () =>
{
await _bookAppService.CreateAsync(
new CreateUpdateBookDto
{
Name = "",
Price = 10,
PublishDate = DateTime.Now,
Type = BookType.ScienceFiction
}
);
});
exception.ValidationErrors
.ShouldContain(err => err.MemberNames.Any(mem => mem == "Name"));
}
}
@@ -0,0 +1,9 @@
using Volo.Abp.Modularity;
namespace Hua.Abp.Demo;
public abstract class DemoApplicationTestBase<TStartupModule> : DemoTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
}
@@ -0,0 +1,12 @@
using Volo.Abp.Modularity;
namespace Hua.Abp.Demo;
[DependsOn(
typeof(DemoApplicationModule),
typeof(DemoDomainTestModule)
)]
public class DemoApplicationTestModule : AbpModule
{
}
@@ -0,0 +1,3 @@
{
"role": "lib.test"
}
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace>Hua.Abp.Demo</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Hua.Abp.Demo.Application\Hua.Abp.Demo.Application.csproj" />
<ProjectReference Include="..\Hua.Abp.Demo.Domain.Tests\Hua.Abp.Demo.Domain.Tests.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
</ItemGroup>
</Project>
@@ -0,0 +1,34 @@
using Shouldly;
using System.Threading.Tasks;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
using Xunit;
namespace Hua.Abp.Demo.Samples;
/* This is just an example test class.
* Normally, you don't test code of the modules you are using
* (like IIdentityUserAppService here).
* Only test your own application services.
*/
public abstract class SampleAppServiceTests<TStartupModule> : DemoApplicationTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
private readonly IIdentityUserAppService _userAppService;
protected SampleAppServiceTests()
{
_userAppService = GetRequiredService<IIdentityUserAppService>();
}
[Fact]
public async Task Initial_Data_Should_Contain_Admin_User()
{
//Act
var result = await _userAppService.GetListAsync(new GetIdentityUsersInput());
//Assert
result.TotalCount.ShouldBeGreaterThan(0);
result.Items.ShouldContain(u => u.UserName == "admin");
}
}
@@ -0,0 +1,10 @@
using Volo.Abp.Modularity;
namespace Hua.Abp.Demo;
/* Inherit from this class for your domain layer tests. */
public abstract class DemoDomainTestBase<TStartupModule> : DemoTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
}
@@ -0,0 +1,12 @@
using Volo.Abp.Modularity;
namespace Hua.Abp.Demo;
[DependsOn(
typeof(DemoDomainModule),
typeof(DemoTestBaseModule)
)]
public class DemoDomainTestModule : AbpModule
{
}
@@ -0,0 +1,3 @@
{
"role": "lib.test"
}
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace>Hua.Abp.Demo</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Hua.Abp.Demo.Domain\Hua.Abp.Demo.Domain.csproj" />
<ProjectReference Include="..\Hua.Abp.Demo.TestBase\Hua.Abp.Demo.TestBase.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
</ItemGroup>
</Project>
@@ -0,0 +1,46 @@
using System.Threading.Tasks;
using Shouldly;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
using Xunit;
namespace Hua.Abp.Demo.Samples;
/* This is just an example test class.
* Normally, you don't test code of the modules you are using
* (like IdentityUserManager here).
* Only test your own domain services.
*/
public abstract class SampleDomainTests<TStartupModule> : DemoDomainTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
private readonly IIdentityUserRepository _identityUserRepository;
private readonly IdentityUserManager _identityUserManager;
protected SampleDomainTests()
{
_identityUserRepository = GetRequiredService<IIdentityUserRepository>();
_identityUserManager = GetRequiredService<IdentityUserManager>();
}
[Fact]
public async Task Should_Set_Email_Of_A_User()
{
IdentityUser adminUser;
/* Need to manually start Unit Of Work because
* FirstOrDefaultAsync should be executed while db connection / context is available.
*/
await WithUnitOfWorkAsync(async () =>
{
adminUser = await _identityUserRepository
.FindByNormalizedUserNameAsync("ADMIN");
await _identityUserManager.SetEmailAsync(adminUser, "newemail@abp.io");
await _identityUserRepository.UpdateAsync(adminUser);
});
adminUser = await _identityUserRepository.FindByNormalizedUserNameAsync("ADMIN");
adminUser.Email.ShouldBe("newemail@abp.io");
}
}
@@ -0,0 +1,10 @@
using Hua.Abp.Demo.Books;
using Xunit;
namespace Hua.Abp.Demo.EntityFrameworkCore.Applications.Books;
[Collection(DemoTestConsts.CollectionDefinitionName)]
public class EfCoreBookAppService_Tests : BookAppService_Tests<DemoEntityFrameworkCoreTestModule>
{
}
@@ -0,0 +1,10 @@
using Hua.Abp.Demo.Samples;
using Xunit;
namespace Hua.Abp.Demo.EntityFrameworkCore.Applications;
[Collection(DemoTestConsts.CollectionDefinitionName)]
public class EfCoreSampleAppServiceTests : SampleAppServiceTests<DemoEntityFrameworkCoreTestModule>
{
}
@@ -0,0 +1,9 @@
using Xunit;
namespace Hua.Abp.Demo.EntityFrameworkCore;
[CollectionDefinition(DemoTestConsts.CollectionDefinitionName)]
public class DemoEntityFrameworkCoreCollection : ICollectionFixture<DemoEntityFrameworkCoreFixture>
{
}
@@ -0,0 +1,9 @@
using Hua.Abp.Demo.EntityFrameworkCore;
using Xunit;
namespace Hua.Abp.Demo.EntityFrameworkCore;
public class DemoEntityFrameworkCoreCollectionFixtureBase : ICollectionFixture<DemoEntityFrameworkCoreFixture>
{
}
@@ -0,0 +1,11 @@
using System;
namespace Hua.Abp.Demo.EntityFrameworkCore;
public class DemoEntityFrameworkCoreFixture : IDisposable
{
public void Dispose()
{
}
}
@@ -0,0 +1,8 @@
using Volo.Abp;
namespace Hua.Abp.Demo.EntityFrameworkCore;
public abstract class DemoEntityFrameworkCoreTestBase : DemoTestBase<DemoEntityFrameworkCoreTestModule>
{
}
@@ -0,0 +1,77 @@
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Sqlite;
using Volo.Abp.FeatureManagement;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement;
using Volo.Abp.Uow;
namespace Hua.Abp.Demo.EntityFrameworkCore;
[DependsOn(
typeof(DemoApplicationTestModule),
typeof(DemoEntityFrameworkCoreModule),
typeof(AbpEntityFrameworkCoreSqliteModule)
)]
public class DemoEntityFrameworkCoreTestModule : AbpModule
{
private SqliteConnection? _sqliteConnection;
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<FeatureManagementOptions>(options =>
{
options.SaveStaticFeaturesToDatabase = false;
options.IsDynamicFeatureStoreEnabled = false;
});
Configure<PermissionManagementOptions>(options =>
{
options.SaveStaticPermissionsToDatabase = false;
options.IsDynamicPermissionStoreEnabled = false;
});
context.Services.AddAlwaysDisableUnitOfWorkTransaction();
ConfigureInMemorySqlite(context.Services);
}
private void ConfigureInMemorySqlite(IServiceCollection services)
{
_sqliteConnection = CreateDatabaseAndGetConnection();
services.Configure<AbpDbContextOptions>(options =>
{
options.Configure(context =>
{
context.DbContextOptions.UseSqlite(_sqliteConnection);
});
});
}
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
_sqliteConnection?.Dispose();
}
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<DemoDbContext>()
.UseSqlite(connection)
.Options;
using (var context = new DemoDbContext(options))
{
context.GetService<IRelationalDatabaseCreator>().CreateTables();
}
return connection;
}
}
@@ -0,0 +1,10 @@
using Hua.Abp.Demo.Samples;
using Xunit;
namespace Hua.Abp.Demo.EntityFrameworkCore.Domains;
[Collection(DemoTestConsts.CollectionDefinitionName)]
public class EfCoreSampleDomainTests : SampleDomainTests<DemoEntityFrameworkCoreTestModule>
{
}
@@ -0,0 +1,40 @@
using System;
using System.Threading.Tasks;
using Shouldly;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
using Xunit;
namespace Hua.Abp.Demo.EntityFrameworkCore.Samples;
/* This is just an example test class.
* Normally, you don't test ABP framework code
* Only test your custom repository methods.
*/
[Collection(DemoTestConsts.CollectionDefinitionName)]
public class SampleRepositoryTests : DemoEntityFrameworkCoreTestBase
{
private readonly IRepository<IdentityUser, Guid> _appUserRepository;
public SampleRepositoryTests()
{
_appUserRepository = GetRequiredService<IRepository<IdentityUser, Guid>>();
}
[Fact]
public async Task Should_Query_AppUser()
{
/* Need to manually start Unit Of Work because
* FirstOrDefaultAsync should be executed while db connection / context is available.
*/
await WithUnitOfWorkAsync(async () =>
{
//Act
var adminUser = await _appUserRepository
.FirstOrDefaultAsync(u => u.UserName == "admin");
//Assert
adminUser.ShouldNotBeNull();
});
}
}
@@ -0,0 +1,3 @@
{
"role": "lib.test"
}
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace>Hua.Abp.Demo</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Hua.Abp.Demo.EntityFrameworkCore\Hua.Abp.Demo.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\Hua.Abp.Demo.Application.Tests\Hua.Abp.Demo.Application.Tests.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.EntityFrameworkCore.Sqlite" Version="10.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
</ItemGroup>
</Project>
@@ -0,0 +1,38 @@
using System;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Identity;
using Volo.Abp.Account;
namespace Hua.Abp.Demo.HttpApi.Client.ConsoleTestApp;
public class ClientDemoService : ITransientDependency
{
private readonly IProfileAppService _profileAppService;
private readonly IIdentityUserAppService _identityUserAppService;
public ClientDemoService(
IProfileAppService profileAppService,
IIdentityUserAppService identityUserAppService)
{
_profileAppService = profileAppService;
_identityUserAppService = identityUserAppService;
}
public async Task RunAsync()
{
var profileDto = await _profileAppService.GetAsync();
Console.WriteLine($"UserName : {profileDto.UserName}");
Console.WriteLine($"Email : {profileDto.Email}");
Console.WriteLine($"Name : {profileDto.Name}");
Console.WriteLine($"Surname : {profileDto.Surname}");
Console.WriteLine();
var resultDto = await _identityUserAppService.GetListAsync(new GetIdentityUsersInput());
Console.WriteLine($"Total users: {resultDto.TotalCount}");
foreach (var identityUserDto in resultDto.Items)
{
Console.WriteLine($"- [{identityUserDto.Id}] {identityUserDto.Name}");
}
}
}
@@ -0,0 +1,30 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Polly;
using Volo.Abp.Autofac;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Client.IdentityModel;
using Volo.Abp.Modularity;
namespace Hua.Abp.Demo.HttpApi.Client.ConsoleTestApp;
[DependsOn(
typeof(AbpAutofacModule),
typeof(DemoHttpApiClientModule),
typeof(AbpHttpClientIdentityModelModule)
)]
public class DemoConsoleApiClientModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<AbpHttpClientBuilderOptions>(options =>
{
options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) =>
{
clientBuilder.AddTransientHttpErrorPolicy(
policyBuilder => policyBuilder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i)))
);
});
});
}
}
@@ -0,0 +1,3 @@
{
"role": "lib.test"
}
@@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.json" />
<Content Include="appsettings.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Remove="appsettings.secrets.json" />
<Content Include="appsettings.secrets.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Hua.Abp.Demo.HttpApi.Client\Hua.Abp.Demo.HttpApi.Client.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Autofac" Version="10.0.1" />
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel" Version="10.0.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="10.0.0" />
</ItemGroup>
<ItemGroup>
<None Remove="**\*.abppkg" />
<None Remove="**\*.abppkg.analyze.json" />
<Content Remove="$(UserProfile)\.nuget\packages\*\*\contentFiles\any\*\*.abppkg*" />
</ItemGroup>
</Project>
@@ -0,0 +1,33 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
namespace Hua.Abp.Demo.HttpApi.Client.ConsoleTestApp;
class Program
{
static async Task Main(string[] args)
{
using (var application = await AbpApplicationFactory.CreateAsync<DemoConsoleApiClientModule>(options =>
{
var builder = new ConfigurationBuilder();
builder.AddJsonFile("appsettings.json", false);
builder.AddJsonFile("appsettings.secrets.json", true);
options.Services.ReplaceConfiguration(builder.Build());
options.UseAutofac();
}))
{
await application.InitializeAsync();
var demo = application.ServiceProvider.GetRequiredService<ClientDemoService>();
await demo.RunAsync();
Console.WriteLine("Press ENTER to stop application...");
Console.ReadLine();
await application.ShutdownAsync();
}
}
}
@@ -0,0 +1,17 @@
{
"RemoteServices": {
"Default": {
"BaseUrl": "https://localhost:44322/"
}
},
"IdentityClients": {
"Default": {
"GrantType": "password",
"ClientId": "Demo_App",
"UserName": "admin",
"UserPassword": "1q2w3E*",
"Authority": "https://localhost:44322/",
"Scope": "Demo"
}
}
}
@@ -0,0 +1,67 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.Modularity;
using Volo.Abp.Uow;
using Volo.Abp.Testing;
namespace Hua.Abp.Demo;
public abstract class DemoTestBase<TStartupModule> : AbpIntegratedTest<TStartupModule>
where TStartupModule : IAbpModule
{
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options)
{
options.UseAutofac();
}
protected override void BeforeAddApplication(IServiceCollection services)
{
var builder = new ConfigurationBuilder();
builder.AddJsonFile("appsettings.json", false);
builder.AddJsonFile("appsettings.secrets.json", true);
services.ReplaceConfiguration(builder.Build());
}
protected virtual Task WithUnitOfWorkAsync(Func<Task> func)
{
return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func);
}
protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func<Task> action)
{
using (var scope = ServiceProvider.CreateScope())
{
var uowManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>();
using (var uow = uowManager.Begin(options))
{
await action();
await uow.CompleteAsync();
}
}
}
protected virtual Task<TResult> WithUnitOfWorkAsync<TResult>(Func<Task<TResult>> func)
{
return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func);
}
protected virtual async Task<TResult> WithUnitOfWorkAsync<TResult>(AbpUnitOfWorkOptions options, Func<Task<TResult>> func)
{
using (var scope = ServiceProvider.CreateScope())
{
var uowManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>();
using (var uow = uowManager.Begin(options))
{
var result = await func();
await uow.CompleteAsync();
return result;
}
}
}
}
@@ -0,0 +1,47 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.Authorization;
using Volo.Abp.Autofac;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
namespace Hua.Abp.Demo;
[DependsOn(
typeof(AbpAutofacModule),
typeof(AbpTestBaseModule),
typeof(AbpAuthorizationModule),
typeof(AbpBackgroundJobsAbstractionsModule)
)]
public class DemoTestBaseModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpBackgroundJobOptions>(options =>
{
options.IsJobExecutionEnabled = false;
});
context.Services.AddAlwaysAllowAuthorization();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
SeedTestData(context);
}
private static void SeedTestData(ApplicationInitializationContext context)
{
AsyncHelper.RunSync(async () =>
{
using (var scope = context.ServiceProvider.CreateScope())
{
await scope.ServiceProvider
.GetRequiredService<IDataSeeder>()
.SeedAsync();
}
});
}
}
@@ -0,0 +1,6 @@
namespace Hua.Abp.Demo;
public static class DemoTestConsts
{
public const string CollectionDefinitionName = "Demo collection";
}
@@ -0,0 +1,26 @@
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.MultiTenancy;
namespace Hua.Abp.Demo;
public class DemoTestDataSeedContributor : IDataSeedContributor, ITransientDependency
{
private readonly ICurrentTenant _currentTenant;
public DemoTestDataSeedContributor(ICurrentTenant currentTenant)
{
_currentTenant = currentTenant;
}
public Task SeedAsync(DataSeedContext context)
{
/* Seed additional test data... */
using (_currentTenant.Change(context?.TenantId))
{
return Task.CompletedTask;
}
}
}
@@ -0,0 +1,3 @@
{
"role": "lib.test"
}
@@ -0,0 +1,45 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace>Hua.Abp.Demo</RootNamespace>
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.json" />
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<None Remove="appsettings.secrets.json" />
<Content Include="appsettings.secrets.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Autofac" Version="10.0.1" />
<PackageReference Include="Volo.Abp.TestBase" Version="10.0.1" />
<PackageReference Include="Volo.Abp.Authorization" Version="10.0.1" />
<PackageReference Include="Volo.Abp.BackgroundJobs.Abstractions" Version="10.0.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="NSubstitute.Analyzers.CSharp" Version="1.0.17">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.extensibility.execution" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" />
</ItemGroup>
</Project>
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Security.Claims;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Security.Claims;
namespace Hua.Abp.Demo.Security;
[Dependency(ReplaceServices = true)]
public class FakeCurrentPrincipalAccessor : ThreadCurrentPrincipalAccessor
{
protected override ClaimsPrincipal GetClaimsPrincipal()
{
return GetPrincipal();
}
private ClaimsPrincipal GetPrincipal()
{
return new ClaimsPrincipal(new ClaimsIdentity(new List<Claim>
{
new Claim(AbpClaimTypes.UserId, "2e701e62-0953-4dd3-910b-dc6cc93ccb0d"),
new Claim(AbpClaimTypes.UserName, "admin"),
new Claim(AbpClaimTypes.Email, "admin@abp.io")
}));
}
}
@@ -0,0 +1,3 @@
{
}
@@ -0,0 +1,2 @@
{
}