I have been studying acceptance based tests and they look quite nice as they fit more naturally with feature based development.
The problem is that I do not know how to lay them out in code. I would like to try and avoid pulling in another framework to handle this so I am just looking for a simple way to get these tests up and running.
I am open to any changes needed to the code structure. I am also using specs to build up complex acceptance criteria.
Sample of what I am trying to do:
public class When_a_get_request_is_created
{
private readonly IHttpRequest _request;
public When_a_get_request_is_created()
{
_request = new HttpRequest();
}
// How to call this?
public void Given_the_method_assigned_is_get()
{
_request = _request.AsGet();
}
// What about this?
public void Given_the_method_assigned_is_not_get()
{
_request = _request.AsPost();
}
// It would be great to test different assumptions.
public void Assuming_default_headers_have_been_added()
{
_request = _request.WithDefaultHeaders();
}
[Fact]
public void It_Should_Satisfy_RequestIsGetSpec()
{
Assert.True(new RequestUsesGetMethodSpec().IsSatisfiedBy(_request));
}
}
I may be completely off the mark here but essentially I would like to be able to run tests with different assumptions and givens. I don't mind if I have to make more classes or minor duplication as long as I can point someone to the test to validate a given criteria.