Files
blog.stevanfreeborn.com/test/Blog.Tests/EndToEnd/BlogHostFactory.cs
T

29 lines
812 B
C#
Raw Normal View History

2024-04-08 23:34:32 -05:00
namespace Blog.Tests.EndToEnd;
public class BlogHostFactory<TProgram> : WebApplicationFactory<TProgram> where TProgram : class
{
public BlogHostFactory()
2024-04-08 23:34:32 -05:00
{
UseKestrel(server => server.Listen(IPAddress.Loopback, 0));
2024-04-08 23:34:32 -05:00
}
public string ServerAddress
{
get
{
StartServer();
2024-04-08 23:34:32 -05:00
return ClientOptions.BaseAddress.ToString();
}
}
protected override void ConfigureWebHost(IWebHostBuilder builder)
2024-04-10 01:28:38 -05:00
{
builder.ConfigureLogging(config => config.ClearProviders());
builder.ConfigureTestServices(services =>
{
var postsDirectory = Path.Combine(Directory.GetCurrentDirectory(), "TestPosts");
var postServiceOptions = new FilePostServiceOptions() { PostsDirectory = postsDirectory };
services.AddSingleton(Options.Create(postServiceOptions));
});
2024-04-08 23:34:32 -05:00
}
}