-
Notifications
You must be signed in to change notification settings - Fork 11
StepDefnition: Create New Employee
Mahmoud A. Zaid edited this page Mar 17, 2019
·
3 revisions
After what we have done in the previous lesson by creating a feature file for the creating employee test case, Now, we need to create a new Model for Create
API and implement the step definition of the feature file
public string name { get; set; }
public string salary { get; set; }
public string age { get; set; }
When I create a request body with the following values
implement the step with the below code
[When(@"I create a request body with the following values")]
public void WhenICreateRequestBodyWithFollowingValues(Table table)
{
new_emloyee = table.CreateInstance<Create>();
var obj = new Create()
{
name = new_emloyee.name,
salary= new_emloyee.salary,
age=new_emloyee.age
};
JsonSerializer serializer = new JsonSerializer();
jsonBody = serializer.Serialize(obj);
}
[When(@"Add the serialized body to the API request")]
public void WhenAddTheCreatedBodyToTheAPIRequest()
{
SharedSteps.request.AddJsonBody(jsonBody);
}
And Execute API
Then returned status code will be "200"
Mahmoud A. Zaid
- Introduction
- HTTP Methods
- HTTP Request
- API Parameters
- HTTP Response
- HTTP Status Code
- Methods Examples
- Idempotence