之前用的是 xUnit.net ,在集成测试中是这样 seed data 的
public class MsgWebApplicationFactory : WebApplicationFactory<Program>
{
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
builder.Configure(app =>
{
var context = app.ApplicationServices.GetRequiredService<MessageContext>();
context.SeedDataAsync().Wait();
});
}
}
现在迁移到 TUnit,有没有更好的方法进行 seed data?