Integration test does not serialise my request
See original GitHub issueI can’t pinpoint why my integration test is not working; it seems somewhere the request object doesn’t get serialised into my Endpoint method.
I hope you can give me some clues where to find the issue.
I am using a middleware just to see whether the json object is posted. That is the case. But in the end the HandleAsync(Request req, CancellationToken ct) req object stays empty.
I am using XUNIT.
Using this class definition public class EndpointFixture : WebApplicationFactory<Program>
to get my unit testing to work.
The unit test class itself
public class EndpointTests : IClassFixture<EndpointFixture>
[Fact]
public void LoginForUnknownUser()
{
var client = _fixture.GetAnonymousClient("en");
var (_, result) = client
.POSTAsync<Endpoint, Request, Response>(
new Request
{
Email = "unknown@user.com"
}).GetAwaiter().GetResult();
// leaving out my assertions here
}
the GetAnonymousClient is coming from the EndpointFixture class
public HttpClient GetAnonymousClient(string language)
{
var client = Server.CreateClient();
client.DefaultRequestHeaders.Add("X-Request", "XXXXXXX");
client.DefaultRequestHeaders.Add("X-Language", language);
return client;
}
As said, when I place break points, my Endpoint is called OK (so the client basically is working, and using my discovered endpoints)
By my request object - the properties of it - are all null while I know 100% sure (my debugging my Middleware) that I get the correct json with the Email field filled-in.
Can you point me in a direction / hook where I can see when the request object is filled so I can debug through it?
Debug print of the response body:
Same call, outside the unit test:
where my request is filled in.
public class Request
{
public string Email { get; set; }
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (12 by maintainers)
Top GitHub Comments
v3.11.0-beta3
releasedyeah making the change now… will push out next beta in a few minutes! this check was an old relic from some past code which is no longer necessary…