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:
+17
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RootNamespace />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\ProductManagement.Application\ProductManagement.Application.csproj" />
|
||||
<ProjectReference Include="..\ProductManagement.Domain.Tests\ProductManagement.Domain.Tests.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Shouldly;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Xunit;
|
||||
|
||||
namespace ProductManagement
|
||||
{
|
||||
public class ProductAppService_Tests : ProductManagementApplicationTestBase
|
||||
{
|
||||
private readonly IProductAppService _productAppService;
|
||||
private readonly IRepository<Product, Guid> _productRepository;
|
||||
private readonly ProductManagementTestData _testData;
|
||||
|
||||
public ProductAppService_Tests()
|
||||
{
|
||||
_productAppService = GetRequiredService<IProductAppService>();
|
||||
_productRepository = GetRequiredService<IRepository<Product, Guid>>();
|
||||
_testData = GetRequiredService<ProductManagementTestData>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetListPagedAsync()
|
||||
{
|
||||
var result = await _productAppService.GetListPagedAsync(new PagedAndSortedResultRequestDto());
|
||||
|
||||
result.Items.Count.ShouldBeGreaterThan(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetListAsync()
|
||||
{
|
||||
var result = await _productAppService.GetListAsync();
|
||||
|
||||
result.Items.Count.ShouldBeGreaterThan(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetAsync()
|
||||
{
|
||||
var product = (await _productRepository.GetListAsync()).FirstOrDefault();
|
||||
|
||||
var result = await _productAppService.GetAsync(product.Id);
|
||||
|
||||
result.ShouldNotBeNull();
|
||||
result.Name.ShouldBe(_testData.ProductName1);
|
||||
result.Code.ShouldBe(_testData.ProductCode1);
|
||||
result.Price.ShouldBe(_testData.ProductPrice1);
|
||||
result.StockCount.ShouldBe(_testData.ProductStockCount1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CreateAsync()
|
||||
{
|
||||
var result = await _productAppService.CreateAsync(new CreateProductDto()
|
||||
{
|
||||
Code = "Code",
|
||||
Name = "Name",
|
||||
Price = 15,
|
||||
StockCount = 14
|
||||
});
|
||||
|
||||
result.ShouldNotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UpdateAsync()
|
||||
{
|
||||
var product = (await _productRepository.GetListAsync()).FirstOrDefault();
|
||||
|
||||
var result = await _productAppService.UpdateAsync(product.Id, new UpdateProductDto()
|
||||
{
|
||||
Name = nameof(Product.Name),
|
||||
Price = 15,
|
||||
StockCount = 14
|
||||
});
|
||||
|
||||
result.ShouldNotBeNull();
|
||||
result.Name.ShouldBe(nameof(Product.Name));
|
||||
result.Price.ShouldBe(15);
|
||||
result.StockCount.ShouldBe(14);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeleteAsync()
|
||||
{
|
||||
var product = (await _productRepository.GetListAsync()).LastOrDefault();
|
||||
|
||||
await _productAppService.DeleteAsync(product.Id);
|
||||
|
||||
var result = await _productRepository.FindAsync(product.Id);
|
||||
|
||||
result.ShouldBeNull();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using ProductManagement.EntityFrameworkCore;
|
||||
|
||||
namespace ProductManagement
|
||||
{
|
||||
public abstract class ProductManagementApplicationTestBase : ProductManagementTestBase<ProductManagementApplicationTestModule>
|
||||
{
|
||||
protected virtual void UsingDbContext(Action<IProductManagementDbContext> action)
|
||||
{
|
||||
using (var dbContext = GetRequiredService<IProductManagementDbContext>())
|
||||
{
|
||||
action.Invoke(dbContext);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual T UsingDbContext<T>(Func<IProductManagementDbContext, T> action)
|
||||
{
|
||||
using (var dbContext = GetRequiredService<IProductManagementDbContext>())
|
||||
{
|
||||
return action.Invoke(dbContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace ProductManagement
|
||||
{
|
||||
[DependsOn(
|
||||
typeof(ProductManagementApplicationModule),
|
||||
typeof(ProductManagementDomainTestModule)
|
||||
)]
|
||||
public class ProductManagementApplicationTestModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
context.Services.AddAlwaysAllowAuthorization();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user