Files
meezi/tests/Meezi.API.Tests/Integration/MeeziWebApplicationFactory.cs
T
soroush.asadi ef15fd6247 feat(api): .NET 10 multi-tenant REST API
Full backend implementation:
- Multi-tenant cafe/restaurant management (menus, orders, tables, staff)
- POS order flow with ZarinPal and Snappfood payment integration
- OTP authentication via Kavenegar SMS
- QR digital menu with public discover/finder endpoints
- Customer loyalty, coupons, CRM
- PostgreSQL via EF Core, Redis for caching/sessions
- Background jobs, webhook handlers
- Full migration history

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-05-27 21:33:48 +03:30

50 lines
1.7 KiB
C#

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.AspNetCore.TestHost;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Meezi.API;
using Meezi.Infrastructure.Data;
namespace Meezi.API.Tests.Integration;
public class MeeziWebApplicationFactory : WebApplicationFactory<Program>
{
protected override IHost CreateHost(IHostBuilder builder)
{
var app = Program.BuildWebApplication(
Array.Empty<string>(),
ConfigureTestingBeforeServices,
ConfigureTestingAfterServices);
app.StartAsync().GetAwaiter().GetResult();
return app;
}
private static void ConfigureTestingBeforeServices(WebApplicationBuilder webBuilder)
{
webBuilder.Environment.EnvironmentName = "Testing";
webBuilder.WebHost.UseTestServer();
webBuilder.Configuration.AddInMemoryCollection(new Dictionary<string, string?>
{
["Testing:Enabled"] = "true",
["Testing:SkipSeed"] = "true",
["RUN_MIGRATIONS"] = "false",
["ConnectionStrings:Redis"] = "127.0.0.1:6379"
});
}
private static void ConfigureTestingAfterServices(WebApplicationBuilder webBuilder)
{
var dbDescriptor = webBuilder.Services.SingleOrDefault(d =>
d.ServiceType == typeof(DbContextOptions<AppDbContext>));
if (dbDescriptor is not null)
webBuilder.Services.Remove(dbDescriptor);
webBuilder.Services.AddDbContext<AppDbContext>(options =>
options.UseInMemoryDatabase("meezi_test_db"));
}
}