Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataContext in the middleware Invoke function #33039

Open
ragavendra opened this issue Jul 10, 2024 · 1 comment
Open

DataContext in the middleware Invoke function #33039

ragavendra opened this issue Jul 10, 2024 · 1 comment

Comments

@ragavendra
Copy link

Description

[Enter feedback here]
First of all, thanks for this documentation, I was able to almost test one middle ware.

However, I was trying to write unit tests for another one which uses DataContext or is DI injested in the Invoke method. The DataContext is however resolved, but the model say Blog does not have any data entries in it. I am assuming this to be the case as I am using the UseTestServer() in the beginning.

Is there a way or any alternative way as well of injesting data to the DataContext so that the middleware can be tested?

Page URL

https://learn.microsoft.com/en-us/aspnet/core/test/middleware?view=aspnetcore-8.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/test/middleware.md

Document ID

8415adee-793e-2ba7-b97b-672b493ba42b

Article author

@Tratcher

@tdykstra
Copy link
Contributor

@andrejpk I noticed you contributed to this article recently -- can you help with this question?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants