- Introduced a new social-service in the Docker Compose configuration for local development, including build context, environment variables, and health checks. - Updated architecture documentation to reflect the new storage service structure and its components, including user storage quotas and file management. - Enhanced README files to provide clearer instructions on service setup, configuration, and API endpoints for file storage management. - Implemented caching mechanisms in the IAM service client for improved performance and reduced latency in user information retrieval. - Updated appsettings for development to include caching settings for IAM service interactions.
44 lines
1.6 KiB
C#
44 lines
1.6 KiB
C#
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Mvc.Testing;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using MembershipService.Infrastructure;
|
|
|
|
namespace MembershipService.FunctionalTests;
|
|
|
|
/// <summary>
|
|
/// EN: Custom WebApplicationFactory for functional tests.
|
|
/// VI: WebApplicationFactory tùy chỉnh cho functional tests.
|
|
/// </summary>
|
|
public class CustomWebApplicationFactory : WebApplicationFactory<Program>
|
|
{
|
|
protected override void ConfigureWebHost(IWebHostBuilder builder)
|
|
{
|
|
builder.UseEnvironment("Testing");
|
|
|
|
builder.ConfigureServices(services =>
|
|
{
|
|
// EN: Remove ALL DbContext registrations (including Npgsql)
|
|
// VI: Xóa TẤT CẢ các đăng ký DbContext (bao gồm Npgsql)
|
|
var descriptorsToRemove = services.Where(
|
|
d => d.ServiceType == typeof(DbContextOptions<MembershipServiceContext>) ||
|
|
d.ServiceType == typeof(MembershipServiceContext) ||
|
|
d.ServiceType.FullName?.Contains("EntityFrameworkCore") == true ||
|
|
d.ServiceType.FullName?.Contains("Npgsql") == true)
|
|
.ToList();
|
|
|
|
foreach (var descriptor in descriptorsToRemove)
|
|
{
|
|
services.Remove(descriptor);
|
|
}
|
|
|
|
// EN: Add in-memory database for testing
|
|
// VI: Thêm in-memory database để test
|
|
services.AddDbContext<MembershipServiceContext>(options =>
|
|
{
|
|
options.UseInMemoryDatabase("TestDatabase_" + Guid.NewGuid().ToString());
|
|
});
|
|
});
|
|
}
|
|
}
|