DEV Community

Discussion on: Introduction to ASP.NET Core Integration Testing

Collapse
 
sakinala1 profile image
sakinala1 • Edited

nice post..thanks for the knowledge sharing...hey can you give examples with passing parameters..please and if possible can you please explain briefly more about this topic

Collapse
 
kaos profile image
Kai Oswald

I didn' want to cover this, because these are general Testing basics.
But to pass parameters to your tests you can use the DataRow attribute.

This maps the values in your Datarows to the test method params.

[DataRow(1)]
[DataRow(2)]
void Test(int id) 
{

}
Collapse
 
sakinala1 profile image
sakinala1

iam using webapplicationfactory

calling methods as
var response = await _client.GetStringAsync("api/controller/method");

here how to pass parameters...to that method..hope you understand

Thread Thread
 
kaos profile image
Kai Oswald

You can just use string interpolation.

var url = $"api/controller/method/{id}?param1={param1}&param2={param2}";
var response = await _client.GetStringAsync(url);