How can I use ClientWebSocket to connect to a WebApplicationFactory test host?

114 Views Asked by At

I am creating a test server for integration tests like so, and this works well for all HttpClient requests...

Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "IntegrationTesting");
var appBuilder = new WebApplicationFactory<Program>()
    .WithWebHostBuilder(builder =>
    {
        builder.ConfigureTestServices(services =>
        {
            services.AddScoped(sp => MockUserMessagingService.Object);
            services.AddSingleton(sp => MockDealerStrategy.Object);
        });
        builder.UseSetting("https_port", "8080");
    });

HttpClient = appBuilder.CreateClient();

I now also need to connect a ClientWebSocket to that test server. Can someone tell me how that is done?

0

There are 0 best solutions below