mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
Matching one form-urlencoded value #496
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @terryaney on GitHub (Mar 13, 2023).
Originally assigned to: @StefH on GitHub.
If I have a
IRequestBuilder, what do I do to make it only match when a single, specific form key/value is set?@StefH commented on GitHub (Mar 14, 2023):
Can you please give an example?
@terryaney commented on GitHub (Mar 14, 2023):
Well, below is what I came up with as a helper...where
ris my own object and it optionally has aDictionary<string, string> FormValuesproperty. If I set this property with a a dictionary of one or more items, I then make sure that the form value is present. I've only just started using WireMock so no idea if there are better solutions, but it seems to be working.@StefH commented on GitHub (Mar 14, 2023):
Your request contains a header "x-www-form-urlencoded" and the body looks like:
?
@StefH commented on GitHub (Mar 15, 2023):
https://github.com/WireMock-Net/WireMock.Net/pull/903
@StefH commented on GitHub (Mar 15, 2023):
@terryaney
You should now be able to use
WithBody(Func<IDictionary<string, string>?, bool> func);Use NuGet preview version :
1.5.18-ci-17167Info --> https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions
@terryaney commented on GitHub (Mar 15, 2023):
As you've probably guessed, yes, that is what
IBodyData.BodyAsStringreturned.@StefH commented on GitHub (Mar 15, 2023):
Did you manage to install the preview?
@terryaney commented on GitHub (Mar 15, 2023):
No....
Then when I go to NuGet Gallery and pick WireMock.Net...
I'm not seeing anything in any of the 'output windows'. Any idea where to look for diagnostic info? I guess I could maybe try the cli, assuming there is a way to specify which NuGet source to use.
@StefH commented on GitHub (Mar 15, 2023):
@terryaney
Make sure to select "preview":
@terryaney commented on GitHub (Mar 15, 2023):
Hmm, the same. Wonder if VS Code has different 'schema' or something?
@StefH commented on GitHub (Mar 16, 2023):
@terryaney
It seems that custom sources (at least MyGet) is not (yet) supported. (https://github.com/pcislo/vscode-nuget-gallery/issues/19)
For now if you want to keep working in VSCode, you can add a nuget.config file :
@terryaney commented on GitHub (Mar 16, 2023):
Wow this is hard :) Still no love.
No WireMock.Net in dropdown, not sure if there is supposed to be...and neither
dotnet-WireMockorWireMock.Nethave 1.5.18-* versions.My NuGet.config looks like this, you can see the path in the bread crumbs...I assume that is the file you wanted me to modify and additionally, I added in
activePackageSourceas well when it wasn't working in 'only' thepackageSources, but neither attempt worked.I guess I can just wait until you release a proper version or if you want to drop a dll that I should replace here I could try that too if you wanted me to test it for you.
@StefH commented on GitHub (Mar 17, 2023):
I've added this unit test:
Which scenario you also will use I think.
A new normal NuGet version will be released later today / tomorrow.
@StefH commented on GitHub (Mar 17, 2023):
https://github.com/WireMock-Net/WireMock.Net/pull/903
@terryaney commented on GitHub (Mar 22, 2023):
Thanks for the update. I tested, and I think you need to use
WebUtility.UrlDecodefor the values?valuesis your Dictionary andFormValuesis my setup dictionary. Let me know what you think.@StefH commented on GitHub (Mar 22, 2023):
@terryaney
Thanks for testing, you are correct. I'll fix this and release a new version.
@StefH commented on GitHub (Mar 22, 2023):
new NuGet should be available soon