-
Notifications
You must be signed in to change notification settings - Fork 4
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 to get the API response to use in subsequent tests? #2
Comments
Hi, I work with Adam. If we just add a property to RestResponse: public IApiClientResponse ApiResponse => Context.Response; Then we can: Thanks, Mark |
I have added a couple of PRs that allow this to be done (in different ways). Adam |
hey guys @adarmus @marktilleytlc As you figured it out, there is not built in way to do what you need. And thanks for creating the Action Rule. However I feel that "Action" breaks a little bit the "Fluent" syntax and the Assertion intention of the framework. I understand the benefit of an action before and after a request, but also an easy way for people to add custom validations. So do you reckon that the example below would be helpful for you all?
I will see if I can crack some of this code this weekend :) |
Hi - I understand your concerns, and your suggestion looks good. Thanks, Adam |
I have uploaded the new package that includes the before and after request events and also a ReturnsModel that allows you to write inline validation. You should still be able to use your custom rules if you added them as part of your project.
And
|
Thank you Douglas, I have updated our code to use AfterRequest and it is working well.
Regards
Mark
From: Douglas Jimenez <notifications@github.com>
Sent: 18 November 2018 03:20
To: djmnz/RestFluencing <RestFluencing@noreply.github.com>
Cc: Mark Tilley <Mark.Tilley@systemc.com>; Mention <mention@noreply.github.com>
Subject: Re: [djmnz/RestFluencing] How to get the API response to use in subsequent tests? (#2)
I have uploaded the new package that includes the before and after request events and also a ReturnsModel that allows you to write inline validation.
You should still be able to use your custom rules if you added them as part of your project.
// Arrange
bool callFromRequest = false;
var config = RestConfigurationHelper.Default();
var request = config.Get("/null")
.AfterRequest(context => { callFromRequest = true; });
// Act
request.Response().Assert();
// Assert
Assert.IsTrue(callFromRequest);
And
Rest.Get("/product/apple", _configuration)
.Response()
.ReturnsModel<Product>(product => {
return
product.Name == "Apple";
}, "My custom error message")
.Execute()
.ShouldPass();
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#2 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ANhW6ExRoqXlCwnkmxovAUFpCSLp0qcRks5uwNHYgaJpZM4Ybj-Y>.
This email, and any attachments transmitted with it, is confidential and protected by copyright. If you are not the intended recipient you must not use, disseminate, distribute or copy this e-mail or any attachment. If you have received this email in error please notify the sender and delete this email, and any attachments, completely from your system. Any views or opinions expressed within this email are those of the author, and do not necessarily represent those of System C. System C has scanned this email for viruses but does not accept any responsibility once this email has been transmitted. You should scan attachments (if any) for viruses. Registered Address: System C Healthcare Ltd, The Maidstone Studios, Vinters Business Park, New Cut Road, Maidstone, Kent ME14 5NZ. Registered in England: 1754990
|
Great - thanks. Adam |
Hi - love the library.
We want to use the ID from one request to construct a second request. How can we access the response model from the first outside of an "assert" expression?
Thanks, Adam
The text was updated successfully, but these errors were encountered: