You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.5 KiB
43 lines
1.5 KiB
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Mvc.Testing;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.eShopWeb.Infrastructure.Data;
|
|
using Microsoft.eShopWeb.Infrastructure.Identity;
|
|
using Microsoft.eShopWeb.PublicApi.AuthEndpoints;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
namespace Microsoft.eShopWeb.FunctionalTests.PublicApi;
|
|
|
|
public class TestApiApplication : WebApplicationFactory<Authenticate>
|
|
{
|
|
private readonly string _environment = "Testing";
|
|
|
|
protected override IHost CreateHost(IHostBuilder builder)
|
|
{
|
|
builder.UseEnvironment(_environment);
|
|
|
|
// Add mock/test services to the builder here
|
|
builder.ConfigureServices(services =>
|
|
{
|
|
services.AddScoped(sp =>
|
|
{
|
|
// Replace SQLite with in-memory database for tests
|
|
return new DbContextOptionsBuilder<CatalogContext>()
|
|
.UseInMemoryDatabase("DbForPublicApi")
|
|
.UseApplicationServiceProvider(sp)
|
|
.Options;
|
|
});
|
|
services.AddScoped(sp =>
|
|
{
|
|
// Replace SQLite with in-memory database for tests
|
|
return new DbContextOptionsBuilder<AppIdentityDbContext>()
|
|
.UseInMemoryDatabase("IdentityDbForPublicApi")
|
|
.UseApplicationServiceProvider(sp)
|
|
.Options;
|
|
});
|
|
});
|
|
|
|
return base.CreateHost(builder);
|
|
}
|
|
}
|
|
|