我有一个 WCF REST 服务。我想为这些操作编写集成测试。我考虑使用 HttpWebRequest 来编写(如 Why does my C# client, POSTing to my WCF REST service, return (400) Bad Request? 中所述)。我的问题是:我能否将 HttpWebRequest 代码放在 transactionscope 中,以便在执行后回滚任何数据库操作,如下所示:
using (var scope = new TransactionScope(TransactionScopeOption.Required))
{
// use HttpWebRequest to execute REST service operation
}
这个行得通吗?