+ Tips
+ Memberships - DDD - FutureCreator - UserTransactions
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user