重构单元测试和集成测试

This commit is contained in:
administrator committed 2025-03-15 17:33:37 +08:00
1 parent e7e9afe11b
commit 81c8f608dc
34 files changed
+135 -300

No files matched your search

@@ -0,0 +1,18 @@
// Copyright (c) HelloShop Corporation. All rights reserved.
// See the license file in the project root for more information.
using HelloShop.ProductService.Infrastructure;
using Microsoft.EntityFrameworkCore;
namespace HelloShop.ProductService.UnitTests.Helpers
{
public class FakeDbContextFactory : IDbContextFactory<ProductServiceDbContext>
{
public ProductServiceDbContext CreateDbContext()
{
var options = new DbContextOptionsBuilder<ProductServiceDbContext>().UseInMemoryDatabase($"InMemoryTestDb-{DateTimeOffset.UtcNow.ToFileTime()}").Options;
return new ProductServiceDbContext(options);
}
}
}