Skip to content

Commit aadd729

Browse files
fix: add UseTestServer() to HostBuilder configuration
The migration from WebHostBuilder to HostBuilder omitted the .UseTestServer() call, causing the test host to create a real Kestrel server instead of a TestServer. This resulted in an InvalidCastException when GetTestServer() tried to cast KestrelServerImpl to TestServer. Added .UseTestServer() in both the StartupClass and Middleware configuration paths. Signed-off-by: Shashwat Sinha <shashwat.sinha2003@gmail.com>
1 parent 3c65629 commit aadd729

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/Lucene.Net.Tests.Replicator/ReplicatorTestCase.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public static TestServer NewHttpServer(IReplicationService service, MockErrorCon
8989
var hostBuilder = new HostBuilder()
9090
.ConfigureWebHostDefaults(webBuilder =>
9191
{
92+
webBuilder.UseTestServer();
9293
webBuilder.ConfigureServices(container =>
9394
{
9495
container.AddSingleton(service);
@@ -115,6 +116,7 @@ public static TestServer NewHttpServer(IReplicationService service, MockErrorCon
115116
var hostBuilder = new HostBuilder()
116117
.ConfigureWebHostDefaults(webBuilder =>
117118
{
119+
webBuilder.UseTestServer();
118120
webBuilder.ConfigureServices(container =>
119121
{
120122
container.AddRouting();

0 commit comments

Comments
 (0)