views:

15

answers:

1

I have code like this:

[Fact]
public void should_return_at_least_3_users()
{
  Rest.Call("http://localhost/admin/users/makeasfree/3");

  var response = Rest.Call<List<Users>>("http://localhost/admin/freeusers");
  response.Count.ShouldBeGreaterThan(0);
}

I've tried to surround this with TransactionScope but does not work. There is any way to roll back test changes without doing whole database restore?

A: 

It is unlikely that there are any good solutions to this problem as supporting distributed two phase commit transactions across HTTP requests would violate the stateless nature of http requests. Transactions can live behind a REST interface, but they should not be put in front.

I realize that you may only want the transactions to allow you to do integration testing, but do you really want to be doing integration testing using an environment that is not the same as your production environment.

And if you still are not convinced, then you should watch this video :-).

Darrel Miller