First commit. Include junk from template to remove

This commit is contained in:
Dominic Villemure
2024-03-09 20:25:30 -05:00
commit bbcefcf76f
140 changed files with 8151 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
using System.Data.Common;
using Hutopy.Application.Common.Interfaces;
using Hutopy.Infrastructure.Data;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.AspNetCore.TestHost;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Hutopy.Application.FunctionalTests;
using static Testing;
public class CustomWebApplicationFactory : 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);
});
});
}
}