【发布时间】:2010-09-23 10:00:19
【问题描述】:
public class RollBack : OnMethodBoundaryAspect // or another AOP for meth interception
{
public override void OnEntry(MethodExecutionEventArgs eventArgs)
{
try
{
ServiceConfig cfg = new ServiceConfig();
cfg.Transaction = TransactionOption.RequiresNew;
cfg.TrackingAppName = "Application Unit Tests";
cfg.TransactionDescription = "Application Unit Tests Transaction";
cfg.TransactionTimeout = 0x2710;
ServiceDomain.Enter(cfg);
}
catch (Exception exception)
{
Console.WriteLine("Could not enter into a new transaction:\n" + exception);
}
}
public override void OnExit(MethodExecutionEventArgs eventArgs)
{
try
{
if (ContextUtil.IsInTransaction)
{
ContextUtil.SetAbort();
}
ServiceDomain.Leave();
}
catch (Exception exception)
{
Console.WriteLine("Could not leave an existing transaction:\n" + exception);
}
}
}
【问题讨论】:
-
有什么问题 - 如何测试上面的代码?
-
您能否详细说明您要达到的目标?
-
你能给我们更多的信息吗?你的问题太笼统了。查看catb.org/~esr/faqs/smart-questions.html,了解如何提出好问题的技巧。它会增加您获得答案的机会。
标签: .net testing tdd continuous-integration integration