3

I have a WCF REST service. I would like to write integration tests for the operations. I was thinking to write those by using HttpWebRequest (as described in Why does my C# client, POSTing to my WCF REST service, return (400) Bad Request?).

My question is: can I put the HttpWebRequest code in a transactionscope, so that any database operations are rolled back after execution, like:

using (var scope = new TransactionScope(TransactionScopeOption.Required))
{
   // use HttpWebRequest to execute REST service operation
}

Would this work?

Community
  • 1
  • 1
L-Four
  • 13,345
  • 9
  • 65
  • 109

1 Answers1

7

REST does not support propagation of transactions from the client to the service.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • ok thanks, so there is no (easy) way to write integration test for a REST service? – L-Four Dec 05 '11 at 16:50
  • Not if you require transactions. One way would be to not require transactions (e.g., use a test database, not the real one, so you can make all the changes you like). – John Saunders Dec 05 '11 at 17:02