-
Notifications
You must be signed in to change notification settings - Fork 109
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
How do you Mock a bad request using ProblemdetailsFactory #171
Comments
Hi @developer9969! 👋🏻
What's the crash? Any errors or details worth mentioning? I have little to go on here...
It would probably be much better to run in-memory integration tests for these scenarios. |
Hi @khellang
I was wondering that too, but because where I work all the other controller tests that do not use problemdetails (I introduced it) have unit tests with MOQ testing for badrequest- not result found etc.. I found myself struggling mocking problem details... I
I dont get the error when mocking using the microsoft problem details.. but still not sure if you can actually mock bad request etc... or I should just give up on those.? If is possible do you have a snippet? |
I was facing error: Source=Castle.Core
#pragma warning disable CS0618 // 'Do not use this test-only method that modifies static production state. Instead, enable unit test mocking by providing an interface-wrapped instance of the type you need to vary as a constructor parameter.'
#if NETFRAMEWORK #pragma warning disable CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
#endif
|
Hi
I would like to create a set of unit test using MOQ and would like to mock simple things like badRequest -NotFound etc...
I have tried a few things like below to set up the mock
But I Crash when I map the mockProblemFactory.Object. How do you test BadRequest with your middleware?
`
Thanks for any suggestions
The text was updated successfully, but these errors were encountered: