+ Memberships
- DDD
- FutureCreator
- UserTransactions
This commit is contained in:
2024-10-20 14:01:58 -04:00
parent 3d10427821
commit 28d74503df
117 changed files with 2149 additions and 1999 deletions

View File

@@ -1,5 +1,4 @@
using System.Data.Common;
using Hutopy.Application.Common.Interfaces;
using Hutopy.Infrastructure.Data;
using Hutopy.Web;
using Microsoft.AspNetCore.Hosting;
@@ -14,29 +13,20 @@ namespace Hutopy.Application.FunctionalTests;
using static Testing;
public class CustomWebApplicationFactory : WebApplicationFactory<Program>
public class CustomWebApplicationFactory(
DbConnection connection)
: WebApplicationFactory<Program>
{
private readonly DbConnection _connection;
public CustomWebApplicationFactory(DbConnection connection)
{
_connection = connection;
}
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
builder.ConfigureTestServices(services =>
{
services
.RemoveAll<IUser>()
.AddTransient(provider => Mock.Of<IUser>(s => s.Id == GetUserId()));
services
.RemoveAll<DbContextOptions<ApplicationDbContext>>()
.AddDbContext<ApplicationDbContext>((sp, options) =>
{
options.AddInterceptors(sp.GetServices<ISaveChangesInterceptor>());
options.UseSqlServer(_connection);
options.UseSqlServer(connection);
});
});
}