-
Notifications
You must be signed in to change notification settings - Fork 11
SharedSteps Defention Class
Mahmoud A. Zaid edited this page Mar 15, 2019
·
4 revisions
In the previous lesson we are created our first feature file and generate the step definitions methods now we will implement those methods you will find the final implemented class here
public static RestClient api = new RestClient(ConfigurationManager.AppSettings["RestAPI"]);
public static RestRequest request;
public static IRestResponse apiResult;
[Given(@"Create Request ""(.*)"" with ""(.*)"" method")]
public void GivenCreateRequestWithMethod(string _request, Method _method)
{
request = new RestRequest(_request, _method);
request.RequestFormat = DataFormat.Json;
}
[When(@"Create URL segment for ""(.*)"" with parameter (.*)")]
public void ThenCreateURLSegmentForWithParameter(string _segment, string _parameter)
{
request.AddUrlSegment(_segment, _parameter);
}
[When(@"Execute API")]
public void ThenExecuteAPI()
{
apiResult = api.Execute(request);
}
[Then(@"returned status code will be ""(.*)""")]
public void ThenReturnedStatusCodeWillBe(int _status)
{
var code = apiResult.StatusCode;
code.Should().Be(_status);
}
Mahmoud A. Zaid
- Introduction
- HTTP Methods
- HTTP Request
- API Parameters
- HTTP Response
- HTTP Status Code
- Methods Examples
- Idempotence