零度框架升级到 Aspire 13.0 版本

This commit is contained in:
administrator committed 2025-12-16 22:26:14 +08:00
1 parent 41f6c147d5
commit b11ba4f6a5
50 files changed
+336 -446

No files matched your search

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
@@ -7,6 +7,7 @@ using HelloShop.ProductService.Entities.Products;
using HelloShop.ProductService.Models.Products;
using HelloShop.ProductService.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging.Abstractions;
using Moq;
namespace HelloShop.ProductService.UnitTests
@@ -22,7 +23,7 @@ namespace HelloShop.ProductService.UnitTests
mock.Setup(m => m.FindAsync(It.Is<int>(id => id == 1), It.IsAny<CancellationToken>())).ReturnsAsync((Product?)null);
// Act
IMapper mapper = new Mapper(new MapperConfiguration(cfg => cfg.CreateMap<Product, ProductDetailsResponse>()));
IMapper mapper = new Mapper(new MapperConfiguration(cfg => cfg.CreateMap<Product, ProductDetailsResponse>(), new NullLoggerFactory()));
MockProductsController mockProductsController = new(mock.Object, mapper);
ActionResult<ProductDetailsResponse> result = await mockProductsController.GetProduct(1);
@@ -44,7 +45,7 @@ namespace HelloShop.ProductService.UnitTests
mock.Setup(m => m.GetAllAsync(It.IsAny<CancellationToken>())).ReturnsAsync(mockProducts);
// Act
IMapper mapper = new Mapper(new MapperConfiguration(cfg => cfg.CreateMap<Product, ProductListItem>()));
IMapper mapper = new Mapper(new MapperConfiguration(cfg => cfg.CreateMap<Product, ProductListItem>(), new NullLoggerFactory()));
MockProductsController mockProductsController = new(mock.Object, mapper);
ActionResult<IEnumerable<ProductListItem>> result = await mockProductsController.GetProducts();
@@ -9,6 +9,7 @@ using HelloShop.ProductService.Infrastructure;
using HelloShop.ProductService.Models.Products;
using HelloShop.ProductService.UnitTests.Helpers;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Time.Testing;
namespace HelloShop.ProductService.UnitTests
@@ -25,7 +26,7 @@ namespace HelloShop.ProductService.UnitTests
await dbContext.SaveChangesAsync();
IMapper mapper = new MapperConfiguration(configure => configure.CreateMap<Product, ProductDetailsResponse>()).CreateMapper();
IMapper mapper = new Mapper(new MapperConfiguration(cfg => cfg.CreateMap<Product, ProductListItem>(), new NullLoggerFactory()));
ProductsController productsController = new(dbContext, mapper);
@@ -45,7 +46,7 @@ namespace HelloShop.ProductService.UnitTests
// Arrange
await using ProductServiceDbContext dbContext = new FakeDbContextFactory().CreateDbContext();
IMapper mapper = new MapperConfiguration(configure => configure.AddProfile<ProductsMapConfiguration>()).CreateMapper();
IMapper mapper = new MapperConfiguration(configure => configure.AddProfile<ProductsMapConfiguration>(),new NullLoggerFactory()).CreateMapper();
ProductsController productsController = new(dbContext, mapper);