You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we are currently starting out with testing. We want to write some new end-to-end tests, however we stumbled upon a major roadblock.
currently we fork our middleware via ConnectionInfo.LocalPort like this:
bool AppACondition(HttpContext ctx) => ctx.Connection.LocalPort == 5012;
bool AppBCondition(HttpContext ctx) => ctx.Connection.LocalPort is 5007 or 5010 or 5011;
app.MapWhen(
AppACondition,
offer => ConfigureAppA(offer, env));
app.MapWhen(
AppBCondition,
other => ConfigureAppB(other, env, antiforgery));
However the local port with the WebApplicationFactory test is always zero. We tried to overwrite it like that:
protected override TestServer CreateServer(IWebHostBuilder builder)
{
var features = new FeatureCollection();
features.Set<IHttpConnectionFeature>(new HttpConnectionFeature
{
LocalPort = 5010,
});
return new (builder, features);
}
however it does not look like the connectionfeature gets picked up by the ClientHandler is there any way to do that?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
we are currently starting out with testing. We want to write some new end-to-end tests, however we stumbled upon a major roadblock.
currently we fork our middleware via ConnectionInfo.LocalPort like this:
However the local port with the
WebApplicationFactory
test is always zero. We tried to overwrite it like that:however it does not look like the connectionfeature gets picked up by the
ClientHandler
is there any way to do that?Beta Was this translation helpful? Give feedback.
All reactions