49 lines
1.8 KiB
C#
49 lines
1.8 KiB
C#
using System.Collections.Generic;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using UserPointManagement.Application;
|
|
using UserPointManagement.Persistence;
|
|
using Xunit.DependencyInjection;
|
|
using Xunit.DependencyInjection.Logging;
|
|
|
|
namespace UserPointManagement.Tests
|
|
{
|
|
public class Startup
|
|
{
|
|
public void ConfigureHost(IHostBuilder hostBuilder)
|
|
{
|
|
hostBuilder
|
|
.ConfigureAppConfiguration(builder =>
|
|
{
|
|
// 注册配置
|
|
builder
|
|
.AddInMemoryCollection(new List<KeyValuePair<string, string>>
|
|
{
|
|
new ("Connection:UserPointManagement", "Server=67.230.184.225;Port=58007;UserId=postgres;Password=postgres;Database=tiamo;"),
|
|
}).Build();
|
|
})
|
|
.ConfigureServices((context, services) =>
|
|
{
|
|
// 注册自定义服务
|
|
services.AddDbContext<UserPointManagementDbContext>(option =>
|
|
{
|
|
option.UseNpgsql(context.Configuration["Connection:UserPointManagement"])
|
|
.UseSnakeCaseNamingConvention();
|
|
});
|
|
|
|
services.AddServices();
|
|
services.AddRepositories();
|
|
|
|
});
|
|
}
|
|
|
|
public void Configure(ILoggerFactory loggerFactory, ITestOutputHelperAccessor accessor)
|
|
{
|
|
using var provider = new XunitTestOutputLoggerProvider(accessor);
|
|
loggerFactory.AddProvider(provider);
|
|
}
|
|
}
|
|
} |