The ultimate solution for quick API Integration testing.
This library allows developers and test engineers to quickly build API Integration tests without having to repeatedly wire up endpoints. Instead, it utilizes a simple context configuration to specify inputs and automatically forward-feeds inputs from previous requests.
(It feels very similar to Entity Framework -- but for APIs)
Check out the wiki for a more in-depth overview!
The main purpose of this library is to allow sequential API execution and testing without the necessity of re-writing code to wire up ModelA to ModelB.
This forward-feeding implementation is simple, yet creating complete end-to-end workflows can be done very quickly since wiring up of models only needs to happen once.
You have two endpoints.
- Fetch Users /api/Users
- Fetch User Account Information by Id /api/Users?Id={Users.Id}
Traditionally, if you had to execute these endpoints in succession, you would need to
- Create each model.
- Make Http Requests.
- Wire up inputs for next endpoint payload.
- Repeat for remaining endpoints.
With APIFlow, step 2 & 3 is removed as the forward-feed capabilities is automatic with a one-time configuration setup.
User Context /users
public class User{
public int Id { get; set; }
}
public class UserContext : ApiContext<List<User>, HTTPDataExtender>
{
[HttpGet()]
[Route("https://aef3c493-6ff3-47a2-be7f-150688405f7e.mock.pstmn.io/Users")]
public override void ApplyContext(EndpointInputModel model)
{
}
public override void ConfigureClient(ref HttpClientWrapper wrapper)
{
base.ConfigureClient(ref wrapper);
// Add necessary headers etc.
}
public UserContext(List<User> baseObject,
EndpointInputModel inputModel) : base(baseObject, inputModel)
{
}
}
User Information Context /users?id={id}
public class UserInformation{
public int Id { get; set; }
public int Email { get; set; }
}
public class UserInformationContext : ApiContext<UserInformation, HTTPDataExtender>
{
public override void ConfigureEndpoint(ref string endpoint, EndpointInputModel inputModel, bool randomizedInput = false)
{
// Add Query Parameter ?id={UserId.Id}
base.ConfigureEndpoint<UserContext>("Id", (u) => u.Value?[0].Id??0);
}
[HttpGet()]
[Route("https://aef3c493-6ff3-47a2-be7f-150688405f7e.mock.pstmn.io/UserInformation")]
public override void ApplyContext(EndpointInputModel inputModel)
{
// Configure model {User.Id} => {UserInformationContext.Id}
base.ConfigureModel<UserContext>((u, o) => o.Id = u.Value?[0].Id??0);
}
public UserInformationContext(UserInformation baseObject, EndpointInputModel inputModel) : base(baseObject, inputModel)
{
}
}
var apiCpntext = new APIFlowContext();
apiContext.Execute<UserContext>()
.Execute<UserInformationContext>();