I would strongly recommend using an ATDD framework like SpecFlow
or even MSpec
for creating tests of this nature. Implementing SpecFlow
is then a case of writing your specification using domain specific language, in collaboration with domain expert(s) if that's approriate, and then satisfying the scenario steps defined in the feature through code. It's difficult to pad out the code aspect without understanding more about your exact requirements, but a sample feature might look something like this:
Feature: HTTP Requests
In order to validate that HTTP requests use the correct methods
As a client application
I want specific requests to use specific methods
Scenario Outline: Making HTTP Requests
Given I am making a request
When the method assigned is <Method>
And the <Header> header is sent
Then it should satisfy the requirement for a <Method> request
Examples:
| Method | Header |
| Get | Header 1 |
| Get | Header 2 |
| Get | Header 3 |
| Post | Header 1 |
Then in your steps that are bound to the feature you can write the code that satisfies the specification steps. Here's one example:
[Binding]
public class HttpRequestSteps
{
[When(@"the method assigned is (.*)")]
public void WhenTheMethodAssignedIs(string method)
{
// not sure what this should be returning, but you can store it in ScenarioContext and retrieve it in a later step binding by casting back based on key
// e.g. var request = (HttpRequest)ScenarioContext.Current["Request"]
ScenarioContent.Current["Request"] = _request.AsGet();
}
}