Closed xps closed 8 months ago
Hi @xps
Sorry for the delay and thank you for your suggestion and interest in using the library.
I agree with you, not only the headers but also, the session, form, cookie, and form are case-insensitive.
You can find the fix on the latest version 1.6.0
https://github.com/tiagodaraujo/HttpContextMoq/commit/74fc2fb3c133fe111b48570f27c5fe6f2d9495b4
Thank You
Hi @tiagodaraujo,
That's great, thank you. I tested the latest version and I can confirm the fix.
Closing this issue.
Hi, and thanks for this great library.
In the ASP.NET Core runtime, getting the headers by key is case-insensitive. For example, this will be true:
You can see here that the dictionary uses a
StringComparer.OrdinalIgnoreCase
: https://source.dot.net/#Microsoft.AspNetCore.Http/HeaderDictionary.cs,53However, in HttpContextMoq, the following test fails:
This fails even if a
StringComparer.OrdinalIgnoreCase
is passed to the dictionary constructor:One way to fix this and make sure the mock always behave like the original would be to add the missing
StringComparer.OrdinalIgnoreCase
to the constructors:It seems like the best approach to me, but it is a breaking change. If you're happy with that, I can submit a PR. If not, let me know what you think would be a good fix.
Thanks