A simple and efficient tool for testing your API endpoints without any hassle. Just create and add your request endpoints, then run the tests.
First, we create a class that inherits from the base class RequestEndpoint
For example:
[Endpoint("/todos")]internalclassJsonPlaseholderTest:RequestEndpoint{publicoverrideasyncTask<IEndpointResult>Handle(IEndpointResultpreviousResult){vartodos=awaitGetAsync();if(todos.IsSuccessStatusCode)returnTestSucceeded(todos);returnTestFailed(todos);}}Each RequestEndpoint provides two functions for sending the final response: TestSucceeded and TestFailed. You send the response generated in the current test as input to these functions so that it remains available for subsequent tests. For example, if you want to retrieve a todo item by its ID, which was created from the response of the previous test, you can access it using the previousResult object from parameter
It also has functions to send requests to specified endpoints such as
GetAsyncPostAsync
and..
is
But note that entering the functions does not require entering the request address
Finally, to set up the request pipeline, you need to add your tests in your console application with MapFromAssembly and execute the RunTests function
varbaseAddress=newUri("https://jsonplaceholder.typicode.com");varbuilder=newRequesterBuilder(baseAddress).MapFromAssembly(typeof(Program).Assembly);varapp=builder.Build();awaitapp.RunTests();