build: 升级目标框架到net10.0并完善模板配置
1. 将Hua.Cli.Tests、项目共享库、模块项目等所有项目的TargetFramework从net8.0/net9.0升级到net10.0 2. 完善dotnet-tools.json、模板配置文件,添加必要的构建和发布配置 3. 新增微服务、网关、应用程序的启动脚本和基础配置文件 4. 补充产品管理模块的领域、应用、Web层基础代码和多语言资源
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RootNamespace />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ProductManagement.EntityFrameworkCore.Tests\ProductManagement.EntityFrameworkCore.Tests.csproj" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Volo.Abp.Uow;
|
||||
|
||||
namespace ProductManagement
|
||||
{
|
||||
public abstract class ProductManagementDomainTestBase : ProductManagementTestBase<ProductManagementDomainTestModule>
|
||||
{
|
||||
#region WithUnitOfWork
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
using ProductManagement.EntityFrameworkCore;
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace ProductManagement
|
||||
{
|
||||
[DependsOn(
|
||||
typeof(ProductManagementEntityFrameworkCoreTestModule)
|
||||
)]
|
||||
public class ProductManagementDomainTestModule : AbpModule
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
using System.Threading.Tasks;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
|
||||
namespace ProductManagement
|
||||
{
|
||||
public class ProductManager_Tests : ProductManagementDomainTestBase
|
||||
{
|
||||
private readonly ProductManager _productManager;
|
||||
|
||||
public ProductManager_Tests()
|
||||
{
|
||||
_productManager = GetRequiredService<ProductManager>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Should_Create_A_Valid_Product()
|
||||
{
|
||||
//Act
|
||||
var product = await WithUnitOfWorkAsync(
|
||||
async () =>
|
||||
{
|
||||
return await _productManager.CreateAsync("P000837212", "My Product 837212", stockCount: 42);
|
||||
}
|
||||
);
|
||||
|
||||
//Assert
|
||||
product.Code.ShouldBe("P000837212");
|
||||
product.Name.ShouldBe("My Product 837212");
|
||||
product.Price.ShouldBe(0.0f);
|
||||
product.StockCount.ShouldBe(42);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user