переход на реальное api

This commit is contained in:
gorbenko.pavel
2026-07-24 12:27:42 +05:00
parent 2759c1ef7d
commit fa13e93190
24 changed files with 271 additions and 99 deletions
@@ -3,14 +3,18 @@ using Microsoft.Extensions.DependencyInjection;
using Tnsu.ApprovalRoute.Application;
using Tnsu.ApprovalRoute.Application.Common.Interfaces;
using Tnsu.ApprovalRoute.Infrastructure;
using Tnsu.ApprovalRoute.Infrastructure.TnsuPortal;
namespace Tnsu.ApprovalRoute.IntegrationTests.Infrastructure;
// Собирает такой же DI-контейнер, как реальное приложение (те же extension-методы, что в Program.cs),
// но с тестовой БД и тестовым ICurrentUser вместо HttpContext-based реализации.
// но с тестовой БД, тестовым ICurrentUser и подменяемым (Moq) клиентом api.tnsu.kz.
internal static class TestServiceProviderFactory
{
public static ServiceProvider Build(string connectionString, string? currentUserEmail = "initiator@tnsu.kz")
public static ServiceProvider Build(
string connectionString,
string? currentUserEmail = "initiator@tnsu.kz",
ITnsuPortalClient? portalClient = null)
{
var configuration = new ConfigurationBuilder()
.AddInMemoryCollection(new Dictionary<string, string?>
@@ -24,6 +28,9 @@ internal static class TestServiceProviderFactory
services.AddApprovalRouteApplication();
services.AddSingleton<ICurrentUser>(new TestCurrentUser(currentUserEmail));
if (portalClient is not null)
services.AddSingleton(portalClient);
return services.BuildServiceProvider();
}
}