markvincze / Stubbery

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

Add the capability to specify the Headers with a lambda (#28) #29

Closed dstj closed 3 years ago

dstj commented 4 years ago

Add ability to do this:

Add single header

sut.Get("/testget", (req, args) => "testresponse")
                    .Header((req, args) => args.Query.testquery == "Success"
                        ? new KeyValuePair<string, string>("HeaderSuccess", "HeaderValueSuccess")
                        : new KeyValuePair<string, string>("HeaderFailure", "HeaderValueFailure"));

and

Multiple headers

sut.Get("/testget", (req, args) => "testresponse")
                   .Headers((req, args) => args.Query.testquery == "Success"
                       ? new[] {
                           new KeyValuePair<string, string>("HeaderSuccess1", "HeaderValueSuccess1"),
                           new KeyValuePair<string, string>("HeaderSuccess2", "HeaderValueSuccess2"),
                       }
                       : new[] {
                           new KeyValuePair<string, string>("HeaderFailure1", "HeaderValueFailure1"),
                           new KeyValuePair<string, string>("HeaderFailure2", "HeaderValueFailure2"),
                       });
dstj commented 3 years ago

Was reworked in #30