markvincze / Stubbery

Library for creating Api stubs in .NET. https://markvincze.github.io/Stubbery/
MIT License
74 stars 14 forks source link

Update preconditions.md #11

Closed joeylad closed 6 years ago

joeylad commented 6 years ago

The IfBody method is no longer available, I noticed this playing around with the library. It is a handy function, just a question what was the motivation for removing this? Possible to reintroduce it? I like the idea of being able to use the following for my posts :- stub.Post("/api/path/action") .IfBody(s => s.ReadAsString().Contains("foo") && !s.ReadAsString().Contains("bar")); .Response((request, args) => "foo response");

stub.Post("/api/path/action") .IfBody(s => s.ReadAsString().Contains("foo") && s.ReadAsString().Contains("bar")); .Response((request, args) => "foobar response");

markvincze commented 6 years ago

Hi @joeylad,

Thanks for the submission!
The body precondition was removed because it cause bugs in certain cases due to reading the request stream possibly multiple times.

I'll merge this and will release the docs for now, and later I'll look for a way to reintroduce this feature (also requested in #12).