I do not think it's appropriate to be testing the end result of your web service with a unit test. Also, what you are trying to do is called an "integration test", and not a unit test.
What you can do, however, is to:
- Write unit tests to check if your data access layer (DAL) is working properly
- Write unit tests to see if your web method is properly accessing your DAL
You might also want to look at a question I raised before: How do I unit test persistence? to provide you more insight.
If you really are adamant to be able to do this however, it is possible to create such unit tests using MbUnit, which has the Rollback
attribute.
[Rollback]
public void Test_database_persistence()
{
//any database access you perform here will be put inside a transaction
//and rolled back afterwards
}
MbUnit is totally compatible with NUnit, so you could still use tests you've already written with NUnit.