I am new to C# and i am writing a test framework with Specflow,xunit and restsharp. My Step is as below
When I make a <ServiceName><Method> request
Then I should get a success 200
Here as you can see the second step is common step which can be used in may features hence i am writing that in common step class. The challenge here is that how can i write a generic method for first and second step. In first a generic method to send request for any service and in second step to accept response from any service.
If i write just one method my code is like this
RestClient restClient = new RestClient();
RestRequest restRequest = new RestRequest(getUrl);
RestResponse<Root> result = client.ExecuteGet<Root>(request);
Debug.WriteLine($"response status code-{result.StatusCode}");
Debug.WriteLine($"response status code-{result.Content}");
As i am writing a framework i want to set client at one class and use it everywhere and same with request and response. Also i am not able to share the context of test steps. I want any feature to access any step in solution. Please guide.